ListProtectionEventsByMessage returns every screening event recorded against a message, newest first — the breakdown a reviewer sees for a held item.
(ctx context.Context, messageID string)
| 86 | // ListProtectionEventsByMessage returns every screening event recorded against a |
| 87 | // message, newest first — the breakdown a reviewer sees for a held item. |
| 88 | func (s *Store) ListProtectionEventsByMessage(ctx context.Context, messageID string) ([]ProtectionEvent, error) { |
| 89 | rows, err := s.pool.Query(ctx, |
| 90 | `SELECT id, message_id, agent_id, direction, source, reason, action, |
| 91 | subject_addr, detector, score, categories, spans, raw, created_at |
| 92 | FROM protection_events |
| 93 | WHERE message_id = $1 |
| 94 | ORDER BY created_at DESC, id`, |
| 95 | messageID, |
| 96 | ) |
| 97 | if err != nil { |
| 98 | return nil, fmt.Errorf("list screening events by message: %w", err) |
| 99 | } |
| 100 | defer rows.Close() |
| 101 | return scanProtectionEvents(rows) |
| 102 | } |
| 103 | |
| 104 | // ListProtectionEventsByAgent returns an agent's most recent screening events |
| 105 | // (newest first, capped by limit) for the security/analytics view. |