Files
creator-hub/internal/creator/event_cover_update.go
T
rogee 360bf96bab
douyin-release-gate / verify (push) Failing after 18m0s
feat: push Douyin events through shared WebSocket and SSE
2026-10-07 23:45:32 +08:00

38 lines
1.1 KiB
Go

package creator
import "context"
// Cover completion cannot rewrite an event, a delivery cursor, or its history flag.
func (s *Store) UpdateListenerEventCovers(ctx context.Context, accountID, generation string, items []ListenerDelivery) error {
tx, err := s.db.BeginTx(ctx, nil)
if err != nil {
return err
}
defer tx.Rollback()
var id int64
var enabled bool
var current string
err = tx.QueryRowContext(ctx, `SELECT l.account_id,l.enabled,l.generation FROM creator_account_listener l
JOIN social_account a ON a.id=l.account_id WHERE a.account_id=$1 FOR UPDATE OF l`, accountID).Scan(&id, &enabled, &current)
if err != nil {
return rowError(err)
}
if !enabled || current != generation {
return ErrConflict
}
for _, d := range items {
if d.Notice == nil || d.Notice.WorkID == "" {
continue
}
n := d.Notice
if err := d.Validate(); err != nil {
return err
}
_, err = tx.ExecContext(ctx, `UPDATE creator_account_event SET work_cover_error=$1 WHERE account_id=$2 AND event_key=$3 AND work_id=$4 AND work_author_uid=$5`, n.WorkCoverError, id, n.EventKey, n.WorkID, n.WorkAuthorUID)
if err != nil {
return err
}
}
return tx.Commit()
}