DeterministicProtectionEventID derives a stable id from the dedupe key (message + source + reason + detector) so that re-screening the same message — e.g. an MTA-retried inbound delivery — inserts the SAME row via ON CONFLICT DO NOTHING instead of a duplicate. Mirrors webhookpub.DeterministicEventID
(messageID, source, reason, detector string)
| 55 | // an MTA-retried inbound delivery — inserts the SAME row via ON CONFLICT DO NOTHING |
| 56 | // instead of a duplicate. Mirrors webhookpub.DeterministicEventID. |
| 57 | func DeterministicProtectionEventID(messageID, source, reason, detector string) string { |
| 58 | h := sha256.Sum256([]byte(messageID + "|" + source + "|" + reason + "|" + detector)) |
| 59 | return "scr_" + hex.EncodeToString(h[:16]) |
| 60 | } |
| 61 | |
| 62 | // CreateProtectionEvent appends a screening event. The insert is idempotent on the |
| 63 | // primary key: callers that set a DeterministicProtectionEventID get exactly-once |
no outgoing calls