package delivery import "time" // ShouldRepeat — PURE: given the last send ts, whether the send was acked, the // current time, and the repeat interval, decide whether to re-send a sev4 // telegram nudge. // // "telegram, repeat til ack" — a disk-fire alarm at 2am repeats on telegram // until the user acknowledges. this is the decision the daemon's tick loop // calls each cycle (via Dispatcher.RepeatUnacked). acked ⇒ stop. interval // elapsed since last send ⇒ re-send. otherwise wait. // // lastSent.IsZero() ⇒ never sent; the INITIAL dispatch handles that (not the // repeat path). returning true here is harmless — the caller will send and // MarkSent, which sets the clock. fail-safe: when in doubt, send (a missed // disk-fire alarm is the cost we're optimizing against). func ShouldRepeat(lastSent time.Time, acked bool, now time.Time, interval time.Duration) bool { if acked { return false } if lastSent.IsZero() { return true } return now.Sub(lastSent) >= interval }