Skip to content

Presence aggregation + deferred push suppression#264

Merged
jevolk merged 9 commits into
matrix-construct:mainfrom
lhjt:feat/presence-aggregation
Jan 22, 2026
Merged

Presence aggregation + deferred push suppression#264
jevolk merged 9 commits into
matrix-construct:mainfrom
lhjt:feat/presence-aggregation

Conversation

@lhjt
Copy link
Copy Markdown
Contributor

@lhjt lhjt commented Jan 20, 2026

Summary

  • Aggregate per-device presence into a single user presence state with refresh-window logic. This means that multiple devices reporting different presences will no longer cause the user's presence to flip frequently between updates.
  • Make presence timers abortable and resilient to stale timer fires.
  • Add in deferred push notifications, as is in other platforms like Discord. The current implementation is in-memory only to avoid having to making a schema change whilst this feature is being evaluated. Example:
    1. push notification is suppressed
    2. user goes unavailable/offline (no longer online)
    3. any unread messages that arrived and were suppressed will be pushed to the user as push notifications

Key changes

  • Presence update pipeline extracted to src/service/presence/pipeline.rs
  • New aggregation module src/service/presence/aggregate.rs and unit tests
  • Presence timers now abort/reschedule safely; stale timers are ignored
  • Deferred push suppression queue reintroduced (src/service/pusher/suppressed.rs) with enqueue/flush/clear hooks
  • Presence inactivity now triggers suppressed push flush

Behaviour notes

  • Refresh-skip now requires last_active_ago to be present; missing values will write a new event instead of skipping
  • Aggregation returns Offline immediately when all devices are pruned

Tests

  • cargo test -p tuwunel_service presence

@lhjt lhjt marked this pull request as ready for review January 20, 2026 19:58
@jevolk jevolk self-assigned this Jan 20, 2026
@jevolk jevolk merged commit b849bca into matrix-construct:main Jan 22, 2026
45 checks passed
@jevolk
Copy link
Copy Markdown
Member

jevolk commented Jan 22, 2026

This is amazing work 😍

Thank you!!! 🙇🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants