You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: notify.go
    path of file: ./repos/portmaster/broadcasts
    
    the code of the file until where you have to start completion: package broadcasts

import (
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"os"
	"strings"
	"sync"
	"time"

	"github.com/ghodss/yaml"

	"github.com/safing/portbase/database"
	"github.com/safing/portbase/database/accessor"
	"github.com/safing/portbase/database/query"
	"github.com/safing/portbase/log"
	"github.com/safing/portbase/modules"
	"github.com/safing/portbase/notifications"
	"github.com/safing/portmaster/updates"
)

const (
	broadcastsResourcePath = "intel/portmaster/notifications.yaml"

	broadcastNotificationIDPrefix = "broadcasts:"

	minRepeatDuration = 1 * time.Hour
)

// Errors.
var (
	ErrSkip                  = errors.New("broadcast skipped")
	ErrSkipDoesNotMatch      = fmt.Errorf("%w: does not match", ErrSkip)
	ErrSkipAlreadyActive     = fmt.Errorf("%w: already active", ErrSkip)
	ErrSkipAlreadyShown      = fmt.Errorf("%w: already shown", ErrSkip)
	ErrSkipRemovedByMismatch = fmt.Errorf("%w: removed due to mismatch", ErrSkip)
	ErrSkipRemovedBySource   = fmt.Errorf("%w: removed by source", E
    
func markBroadcastAsRead(ctx context.Context, n *notifications.Notification) error {
	// Lock persisting broadcast state.
	savingBroadcastStateLock.Lock()
	defer savingBroadcastStateLock.Unlock()

	// Get notification data.
	var broadcastID, actionID string
	func() {
		n.Lock()
		defer n.Unlock()
		broadcastID = strings.TrimPrefix(n.EventID, broadcastNotificationIDPrefix)
		actionID = n.SelectedActionID
	}()

	// Check response.
	switch actionID {
	case "ack":
	case "":
		return fmt.Errorf("no action ID for %s", broadcastID)
	default:
		return fmt.Errorf("unexpected action ID for %s: %s", broadcastID, actionID)
	}

	// Get broadcast notification states.
	bss, err := getBroadcastStates()
	if err != nil {
		if !errors.Is(err, database.ErrNotFound) {
			return fmt.Errorf("failed to get broadcast notifications states: %w", err)
		}
		bss = newBroadcastStates()
	}

	// Get state for this notification.
	bs, ok := bss.States[broadcastID]
	if !ok {
		bs = &BroadcastState{}
		bss.States[broadcastID] = bs
	}

	// Delete to allow for timely repeats.
	n.Delete()

	// Mark as read and save to DB.
	log.Infof("broadcasts: user acknowledged broadcast %s", broadcastID)
	bs.Read = time.Now()
	return bss.save()
}