fix: 补提交校验、停用检查、入群过滤与按完成时刻清理

This commit is contained in:
Nixevol
2026-09-30 16:21:05 +08:00
parent 2461bec3b6
commit 659373e142
8 changed files with 247 additions and 11 deletions
+9 -1
View File
@@ -86,7 +86,15 @@ WHERE d.state = 'pending' AND d.pushed_conn IS NULL
cutoff := nowMs - int64(a.lim.RecordRetentionDays)*24*3600*1000
if _, err := tx.Exec(`
DELETE FROM messages WHERE seq IN (
SELECT seq FROM messages WHERE state = 'completed' AND created_at < ? LIMIT 5000
SELECT seq FROM (
SELECT m.seq FROM messages m
WHERE m.state = 'completed'
AND COALESCE(
(SELECT MAX(d.updated_at) FROM deliveries d WHERE d.seq = m.seq),
m.send_at
) < ?
LIMIT 5000
)
)`, cutoff); err != nil {
return err
}