hub: review fix 4 — the hub writes the household's receipt; a box cannot word it or flood it (D84)
offsite_end_scheduled bypasses the household's switches and went through the ordinary customer leg: subject and body were the box's own sentence, and 50 invented subjects gave 50 mails. - processReceipt: the details must name a checked app (app-name shape, not reserved) and two parsed dates; the mail is rendered only from the hub's bundle with that app and the parsed end date — never the box's message. - The cooldown key is the checked app + the parsed time of the press. - At most 5 receipts per household in 24 hours, counted in the hub's sent log; drops are said once a day; old receipt keys leave the cooldown map. - Pinned: a blocked household and a household with no address get none. Tests seen red before the fix; 12 mutations seen red, 3 after a redo (documentation/audits/build-release-4-2026-11-15/A/redproof-review-4.txt). Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
1 parent
875c339cf5
commit
be272b7cf4
10 files changed
+455
-26
No files matched your search
@@ -405,3 +405,12 @@ func (s *Store) BackdateOffsiteWindowForTest(id int64, by time.Duration) error {
|
||||
_, err := s.db.Exec(`UPDATE offsite_windows SET opened_at = ? WHERE id = ?`, time.Now().UTC().Add(-by).Format("2006-01-02 15:04:05"), id)
|
||||
return err
|
||||
}
|
||||
|
||||
// CountCustomerSentSince counts the mails of one type the hub's own log says were SENT to a household since `since`
|
||||
// (the receipt's daily limit — it survives a hub restart, which a counter in memory would not).
|
||||
func (s *Store) CountCustomerSentSince(customerID, eventType string, since time.Time) (int, error) {
|
||||
var n int
|
||||
err := s.db.QueryRow(`SELECT COUNT(*) FROM notification_log WHERE customer_id = ? AND event_type = ? AND channel = 'customer' AND status = 'sent' AND created_at >= ?`,
|
||||
customerID, eventType, since.UTC().Format("2006-01-02 15:04:05")).Scan(&n)
|
||||
return n, err
|
||||
}
|
||||
Reference in new issue
Block a user