This commit is contained in:
ponzischeme89
2026-08-19 21:30:44 +12:00
parent 0782545013
commit 769fe01c84
24 changed files with 1131 additions and 500 deletions
+25
View File
@@ -354,3 +354,28 @@ func (s *Store) DismissNotification(ctx context.Context, userID string, id int64
WHERE id = $1 AND emby_user_id = $2`, id, userID)
return err
}
// DismissNotifications clears several of one viewer's notifications at once and reports how
// many rows it actually took.
//
// The count is the whole reason this is a route rather than the client's loop: "cleared 7"
// is what the log line and the activity record are worth reading for, and a television
// counting the requests it made would be counting what it asked for rather than what
// happened — a row somebody dismissed on another set in the meantime is one this must not
// claim. Already-dismissed rows are excluded rather than re-stamped, so a repeated press
// honestly reports nothing left to clear.
func (s *Store) DismissNotifications(
ctx context.Context, userID string, ids []int64,
) (int, error) {
if len(ids) == 0 {
return 0, nil
}
tag, err := s.pool.Exec(ctx, `
UPDATE user_notifications SET dismissed_at = now()
WHERE emby_user_id = $1 AND id = ANY($2::bigint[]) AND dismissed_at IS NULL`,
userID, ids)
if err != nil {
return 0, fmt.Errorf("store: dismiss notifications: %w", err)
}
return int(tag.RowsAffected()), nil
}