Karta.Suppressions.Policy (Karta v1.0.0)

A server's suppression policy: when an address goes onto its list by itself, and how long an entry of each reason lasts. The settings are columns of the server (Karta.Servers.Server), changed on its settings page and over the API.

Temporary failures. suppression_soft_bounce_threshold (default 0, never) temporary failures of one address reported to Karta — a soft bounce, recorded in the bounces table — within suppression_soft_bounce_window_days (default 30) days suppress it with the reason hard_bounce and the source "soft_bounce_policy". The failure being recorded counts: a threshold of 3 suppresses on the third report.

Expiry. suppression_hard_bounce_days, suppression_complaint_days, suppression_unsubscribe_days and suppression_manual_days say how many days an entry of that reason lasts from the moment it takes that reason; 0 means never. An expired entry stays on the list but no longer counts (Karta.Suppressions.suppressed/2): nothing is ever removed without someone asking.

The policy only ever adds a suppression or sets when one ends; it never removes one. An address whose entry expires is sent to again — which is the point of an expiry — and the next failure, complaint or unsubscribe counts anew.

Summary

Functions

When an entry of reason for a server ends, or nil for never: the server's days for the reason, counted from now. server is the row or its id.

True when the address has reached the server's soft-bounce threshold: at least that many soft bounces of it were recorded (in the bounces table) within the window, up to and including now. False when the threshold is off or the address cannot be read.

Functions

expiry(server, reason, now)

@spec expiry(Karta.Servers.Server.t() | Ecto.UUID.t(), atom(), DateTime.t()) ::
  DateTime.t() | nil

When an entry of reason for a server ends, or nil for never: the server's days for the reason, counted from now. server is the row or its id.

soft_bounce_reached?(server, address, now)

@spec soft_bounce_reached?(
  Karta.Servers.Server.t() | Ecto.UUID.t(),
  String.t(),
  DateTime.t()
) ::
  boolean()

True when the address has reached the server's soft-bounce threshold: at least that many soft bounces of it were recorded (in the bounces table) within the window, up to and including now. False when the threshold is off or the address cannot be read.