package backthink // eventRedundant reports whether tr is a duplicate of the immediately preceding // event-driven push (same source + summary), so a repeating device/reminder event // does not spam the owner (防刷). It is the one guard that still applies to an // event-driven push while the PushGate itself is bypassed for events (owner // mandate: "该发就发" — a genuine event goes out, only a true duplicate is held). // // It atomically records tr as the latest event key when the push proceeds, and // clears the key on any non-event push (heartbeat) so a later repeat of a prior // event is not spuriously suppressed by an intervening reflection. // // The caller runs it before handing the push to the Pusher; a true duplicate is // recorded as suppressed (RouteNone) rather than delivered. func (b *Backthink) eventRedundant(tr Trigger) bool { if tr.Kind != TriggerEvent { // A non-event push (heartbeat) breaks the same-event chain. b.eventMu.Lock() b.lastEventKey = "" b.eventMu.Unlock() return false } key := tr.Source + "\x00" + tr.Summary b.eventMu.Lock() defer b.eventMu.Unlock() if b.lastEventKey == key { return true } b.lastEventKey = key return false }