feat(logs): populate send log detail and fix dedup re-claim condition

- dispatch: attach per-send detail (title/url/description/match/provider)
  so the admin log view shows message context, not just a bare ok flag
- idempotency: compare dedup expiry against claimed_at instead of the new
  expires_at so non-expired duplicates are rejected and expired keys re-claim
This commit is contained in:
RhenCloud 2026-08-18 10:29:10 +08:00
parent c6198e855f
commit c955db03c3
No known key found for this signature in database
GPG key ID: A574A617378C4E0B
3 changed files with 14 additions and 2 deletions

View file

@ -43,7 +43,7 @@ export function d1IdempotencyStore(db: D1Database): IdempotencyStore {
`INSERT INTO dedup_keys (key, claimed_at, expires_at) VALUES (?, ?, ?)
ON CONFLICT(key) DO UPDATE SET
claimed_at = excluded.claimed_at, expires_at = excluded.expires_at
WHERE dedup_keys.expires_at < excluded.expires_at`,
WHERE dedup_keys.expires_at < excluded.claimed_at`,
)
.bind(key, now, now + ttlSeconds * 1000)
.run();