pub struct Service {
services: Arc<OnceServices>,
notification_increment_mutex: MutexMap<(OwnedRoomId, OwnedUserId), ()>,
highlight_increment_mutex: MutexMap<(OwnedRoomId, OwnedUserId), ()>,
db: Data,
suppressed: SuppressedQueue,
sent_badges: SentBadges,
email_wakes: Wakes,
email_locks: MutexMap<(OwnedUserId, SmallString<[u8; 48]>), ()>,
}Expand description
Stores pushers and delivers the notifications they ask for.
HTTP pushers are pushed through the sending queue, and email pushers are mailed by this service’s worker.
Fields§
§services: Arc<OnceServices>§notification_increment_mutex: MutexMap<(OwnedRoomId, OwnedUserId), ()>§highlight_increment_mutex: MutexMap<(OwnedRoomId, OwnedUserId), ()>§db: Data§suppressed: SuppressedQueue§sent_badges: SentBadges§email_wakes: Wakes§email_locks: MutexMap<(OwnedUserId, SmallString<[u8; 48]>), ()>Implementations§
Source§impl Service
impl Service
Sourcepub(crate) async fn append_pdu(&self, pdu_id: RawPduId, pdu: &Pdu) -> Result
pub(crate) async fn append_pdu(&self, pdu_id: RawPduId, pdu: &Pdu) -> Result
Called by timeline append_pdu.
Source§impl Service
impl Service
Sourceasync fn invite_notifiable(&self, pdu: &Pdu, user_id: &UserId) -> bool
async fn invite_notifiable(&self, pdu: &Pdu, user_id: &UserId) -> bool
MSC4155: whether an invite may notify the user it names.
Every other membership transition notifies as before; only an invite the recipient ignores or blocks is withheld, matching what sync serves them.
Source§impl Service
impl Service
Sourcefn keyed_pushers<'a>(
&'a self,
user: &'a UserId,
) -> impl Stream<Item = (&'a str, Option<Pusher>)> + Send + 'a
fn keyed_pushers<'a>( &'a self, user: &'a UserId, ) -> impl Stream<Item = (&'a str, Option<Pusher>)> + Send + 'a
The user’s pushers by pushkey, each None when it cannot be decoded.
The pushkey comes from the row’s key, so a pusher that cannot be decoded is still known by it.
Source§impl Service
impl Service
Sourcefn dispatch_push(
&self,
user: &UserId,
pdu_id: &RawPduId,
pushkey: &str,
pusher: Option<Pusher>,
mailable: bool,
)
fn dispatch_push( &self, user: &UserId, pdu_id: &RawPduId, pushkey: &str, pusher: Option<Pusher>, mailable: bool, )
Hands one appended event to one of the user’s pushers, by kind.
An email pusher wakes the email worker when there is a recorded notification to mail, and an HTTP pusher queues a push. A pusher that cannot be decoded is queued a push too, and its delivery reports the fault.
Source§impl Service
impl Service
async fn increment_notificationcount(&self, room_id: &RoomId, user_id: &UserId)
Source§impl Service
impl Service
async fn increment_highlightcount(&self, room_id: &RoomId, user_id: &UserId)
Source§impl Service
impl Service
async fn increment_thread_notificationcount( &self, room_id: &RoomId, user_id: &UserId, thread_root: &EventId, )
Source§impl Service
impl Service
async fn increment_thread_highlightcount( &self, room_id: &RoomId, user_id: &UserId, thread_root: &EventId, )
Source§impl Service
impl Service
Sourcepub(super) fn sent_badge(&self, user_id: &UserId, pushkey: &str) -> Option<UInt>
pub(super) fn sent_badge(&self, user_id: &UserId, pushkey: &str) -> Option<UInt>
Return the unread total last accepted by this pusher’s gateway.
None means no delivery has been confirmed since startup, and the caller
must send rather than assume agreement.
Source§impl Service
impl Service
Sourcepub(super) fn record_sent_badge(
&self,
user_id: &UserId,
pushkey: &str,
unread: UInt,
)
pub(super) fn record_sent_badge( &self, user_id: &UserId, pushkey: &str, unread: UInt, )
Record the unread total a pusher’s gateway just accepted.
Call only after a successful delivery; recording an attempt would make a failed send look reconciled and suppress the retry’s refresh.
Source§impl Service
impl Service
Sourcepub(super) fn forget_sent_badge(&self, user_id: &UserId, pushkey: &str)
pub(super) fn forget_sent_badge(&self, user_id: &UserId, pushkey: &str)
Forget the delivery record for one pusher.
A deleted or replaced pusher leaves the device state unknown, so the next refresh must send unconditionally.
Source§impl Service
impl Service
Sourcepub async fn evaluate_email(
&self,
user_id: &UserId,
pushkey: &str,
now: u64,
) -> Outcome
pub async fn evaluate_email( &self, user_id: &UserId, pushkey: &str, now: u64, ) -> Outcome
Evaluates one email pusher at now, in milliseconds.
A notification after the pusher’s cursor counts if it still notifies, is unread, and is in a room the user has joined or been invited to. Each waits out the delay and its room’s throttle; once the earliest is due, all of them go out in one mail and the cursor moves past them. A notification still being written brings the pusher back after the delay or one second, whichever is longer.
Source§impl Service
impl Service
Sourceasync fn email_target(
&self,
user_id: &UserId,
pushkey: &str,
) -> Result<(Address, EmailPusherData), Outcome>
async fn email_target( &self, user_id: &UserId, pushkey: &str, ) -> Result<(Address, EmailPusherData), Outcome>
The address an email pusher mails and the pusher’s data, or the outcome ending its evaluation.
A pusher that is gone, or no longer an email pusher, takes its rows with it. One whose address is no longer verified on the account, or is not a valid address, is deleted, as removing the address deletes it in Synapse.
Source§impl Service
impl Service
Sourcepub(super) async fn email_pusher(
&self,
user_id: &UserId,
pushkey: &str,
) -> Result<Option<EmailPusherData>>
pub(super) async fn email_pusher( &self, user_id: &UserId, pushkey: &str, ) -> Result<Option<EmailPusherData>>
The pusher’s email data, or None when it is gone or is not an email
pusher.
Failing to read the pusher is an error, never taken for its absence.
Source§impl Service
impl Service
Sourceasync fn forget_orphan(&self, user_id: &UserId, pushkey: &str)
async fn forget_orphan(&self, user_id: &UserId, pushkey: &str)
Deletes the cursor and room throttles of a pusher that is gone or no longer mails.
The pusher is read again under its lock, so one created again since keeps its new cursor.
Source§impl Service
impl Service
Sourceasync fn forget_unbound(&self, user_id: &UserId, pushkey: &str)
async fn forget_unbound(&self, user_id: &UserId, pushkey: &str)
Deletes an email pusher whose address is no longer verified on the account or is not a valid address.
The pusher and its binding are read again under the pusher’s lock, so a pusher replaced in the meantime, or one whose address was verified again, survives.
Source§impl Service
impl Service
Sourceasync fn scan_pending(
&self,
user_id: &UserId,
cursor: u64,
frontier: u64,
) -> Result<Scan>
async fn scan_pending( &self, user_id: &UserId, cursor: u64, frontier: u64, ) -> Result<Scan>
Gathers the notifications to mail between the cursor and the retired
frontier.
A row past the frontier may sit above one still being written, so the scan stops before it. It reads every row up to there, a backlog the throttle cap keeps to about a day of notifications. A row, event or membership whose read may succeed on a retry ends the scan with its error; one unreadable for good is skipped.
Source§impl Service
impl Service
Sourceasync fn scanned(
&self,
user_id: &UserId,
count: u64,
notified: Notified,
) -> Result<Option<Pending>>
async fn scanned( &self, user_id: &UserId, count: u64, notified: Notified, ) -> Result<Option<Pending>>
The notification as a pending mail, or None once it no longer warrants
one.
It must still notify, survive unredacted, be unread, and be in a room the user is still joined to, or invited to when the notification is that invite. An event or membership whose read may succeed on a retry is an error; one missing or unreadable for good is skipped.
Source§impl Service
impl Service
Sourceasync fn notified_past(&self, user_id: &UserId, frontier: u64) -> Result<bool>
async fn notified_past(&self, user_id: &UserId, frontier: u64) -> Result<bool>
Whether the user has a notification row past the retired frontier.
Such a row may sit above one still being written, which a later evaluation must not skip. A row whose read may succeed on a retry is an error, and one unreadable for good is skipped.
Source§impl Service
impl Service
Sourceasync fn room_throttles<'a>(
&self,
user_id: &UserId,
pushkey: &str,
rooms: &'a BTreeMap<ShortRoomId, (OwnedRoomId, u64)>,
) -> Result<BTreeMap<ShortRoomId, (&'a RoomId, Throttle)>>
async fn room_throttles<'a>( &self, user_id: &UserId, pushkey: &str, rooms: &'a BTreeMap<ShortRoomId, (OwnedRoomId, u64)>, ) -> Result<BTreeMap<ShortRoomId, (&'a RoomId, Throttle)>>
Each pending room’s throttle as it applies now.
A room the user has read since the last mail naming it has its throttle reset. A read that may succeed on a retry returns an error, while a throttle unreadable for good counts as none.
Source§impl Service
impl Service
async fn room_throttle<'a>( &self, user_id: &UserId, pushkey: &str, sroomid: ShortRoomId, room_id: &'a RoomId, ) -> Result<(ShortRoomId, (&'a RoomId, Throttle))>
Source§impl Service
impl Service
Sourceasync fn record_state<'a, Rooms>(
&self,
user_id: &UserId,
pushkey: &str,
stored: u64,
cursor: u64,
rooms: Rooms,
)
async fn record_state<'a, Rooms>( &self, user_id: &UserId, pushkey: &str, stored: u64, cursor: u64, rooms: Rooms, )
Moves the pusher’s cursor on from stored and stores the throttles of the
rooms a mail named, unless the cursor has changed since the evaluation read
it.
Deleting the pusher, or creating it again, changes the cursor, so a result computed from the old one is dropped; the lock keeps either from landing between the check and the write. A cursor that cannot be read counts as unchanged: dropping the result would mail the same notifications again, while writing it at worst leaves a deleted pusher’s cursor for its next evaluation to delete, or sets a pusher created since back to this cursor, so it also mails what came before it to the same address.
Source§impl Service
impl Service
Sourcepub(super) async fn render_email(
&self,
user_id: &UserId,
address: &Address,
brand: &str,
scan: &Scan,
) -> Mail
pub(super) async fn render_email( &self, user_id: &UserId, address: &Address, brand: &str, scan: &Scan, ) -> Mail
Renders the email for a scan’s newest pending notifications.
Rooms come most recent first and each lists its notifications newest first; the scan’s remaining notifications are counted after them, and the subject counts every room in the scan. A lone pending invite names its inviter in the subject.
Source§impl Service
impl Service
Sourceasync fn sender_name(&self, room_id: &RoomId, sender: &UserId) -> String
async fn sender_name(&self, room_id: &RoomId, sender: &UserId) -> String
The sender’s name in the room, else in their profile, else their ID.
Clients label a sender with the name set for the room, so the mail does too. Each name is put on one line first, and one left with no text falls through to the next.
Source§impl Service
impl Service
Sourcepub(super) async fn put_pusher(
&self,
user_id: &UserId,
pushkey: &str,
action: &PusherAction,
)
pub(super) async fn put_pusher( &self, user_id: &UserId, pushkey: &str, action: &PusherAction, )
Stores a pusher under its email lock, starting a new email pusher’s cursor past every notification counted so far.
A stored pusher that is already an email pusher, or cannot be read, keeps its cursor, so nothing it has yet to mail is skipped; a new one drops any room throttles left by an earlier pusher with its pushkey. Taking the lock for every kind orders the store against the worker deleting the pusher it replaces.
Source§impl Service
impl Service
pub(super) async fn email_lock( &self, user_id: &UserId, pushkey: &str, ) -> MutexMapGuard<(OwnedUserId, SmallString<[u8; 48]>), ()>
Source§impl Service
impl Service
Sourcepub(super) async fn forget_email_state(&self, user_id: &UserId, pushkey: &str)
pub(super) async fn forget_email_state(&self, user_id: &UserId, pushkey: &str)
Deletes a pusher’s cursor and room throttles.
Callers hold the pusher’s lock.
Source§impl Service
impl Service
Sourceasync fn forget_throttles(&self, user_id: &UserId, pushkey: &str)
async fn forget_throttles(&self, user_id: &UserId, pushkey: &str)
Deletes a pusher’s room throttles.
Callers hold the pusher’s lock.
Source§impl Service
impl Service
Sourcefn put_cursor(&self, user_id: &UserId, pushkey: &str, cursor: u64)
fn put_cursor(&self, user_id: &UserId, pushkey: &str, cursor: u64)
Writes a pusher’s cursor, the count of the last notification row it processed.
Callers hold the pusher’s lock.
Source§impl Service
impl Service
Sourcepub(super) fn wake_email(&self, user_id: &UserId, pushkey: &str)
pub(super) fn wake_email(&self, user_id: &UserId, pushkey: &str)
Wakes the worker for one notification an email pusher may mail.
Nothing is sent while mail is off, so no pusher starts a cursor that would later mail everything since; a wake sent after the worker has stopped is dropped.
Source§impl Service
impl Service
Sourcepub(super) fn close_email_wakes(&self)
pub(super) fn close_email_wakes(&self)
Closes the worker’s channel, which ends the worker.
The worker first handles the wakes already sent.
Source§impl Service
impl Service
Sourcepub(super) async fn email_worker(&self)
pub(super) async fn email_worker(&self)
Service worker: schedules woken email pushers and evaluates each when due.
Evaluations run one at a time. Once the channel closes at shutdown, the worker finishes the evaluation in flight and starts no other. It still handles every wake already sent, so each woken pusher keeps its cursor.
Source§impl Service
impl Service
Sourceasync fn wait_next(
&self,
schedule: &BTreeMap<(OwnedUserId, SmallString<[u8; 48]>), Entry>,
) -> Option<Next>
async fn wait_next( &self, schedule: &BTreeMap<(OwnedUserId, SmallString<[u8; 48]>), Entry>, ) -> Option<Next>
Waits for the next wake, or for the earliest scheduled pusher to fall due.
A pusher already due is returned before any waiting wake, so a steady run
of wakes cannot hold it back. Once the channel is closed, only the wakes
already sent are returned, then None.
Source§impl Service
impl Service
Sourceasync fn schedule_wake(
&self,
schedule: BTreeMap<(OwnedUserId, SmallString<[u8; 48]>), Entry>,
__arg2: ((OwnedUserId, SmallString<[u8; 48]>), u64),
) -> BTreeMap<(OwnedUserId, SmallString<[u8; 48]>), Entry>
async fn schedule_wake( &self, schedule: BTreeMap<(OwnedUserId, SmallString<[u8; 48]>), Entry>, __arg2: ((OwnedUserId, SmallString<[u8; 48]>), u64), ) -> BTreeMap<(OwnedUserId, SmallString<[u8; 48]>), Entry>
Schedules a woken pusher one delay out, unless it is already due sooner or backing off.
It first starts the pusher’s cursor when it has none, at the earliest frontier kept by a wake that could not read the cursor, else at this wake’s.
Source§impl Service
impl Service
Sourceasync fn start_cursor(
&self,
key: &(OwnedUserId, SmallString<[u8; 48]>),
frontier: u64,
) -> Option<u64>
async fn start_cursor( &self, key: &(OwnedUserId, SmallString<[u8; 48]>), frontier: u64, ) -> Option<u64>
Starts the cursor of a woken pusher that has none, at frontier, returning
the frontier when its read fails but may succeed on a retry.
A pusher stored before email notifications existed has none, so nothing written before its first wake is mailed, while a notification still being written when the wake was sent is. A pusher deleted since the wake gets one too, which its evaluation deletes. A returned frontier is kept to start the cursor again, since evaluating without one would skip the notification, while a cursor unreadable for good is left alone.
Source§impl Service
impl Service
Sourceasync fn evaluate_due(
&self,
schedule: BTreeMap<(OwnedUserId, SmallString<[u8; 48]>), Entry>,
key: (OwnedUserId, SmallString<[u8; 48]>),
) -> BTreeMap<(OwnedUserId, SmallString<[u8; 48]>), Entry>
async fn evaluate_due( &self, schedule: BTreeMap<(OwnedUserId, SmallString<[u8; 48]>), Entry>, key: (OwnedUserId, SmallString<[u8; 48]>), ) -> BTreeMap<(OwnedUserId, SmallString<[u8; 48]>), Entry>
Evaluates a pusher that has fallen due.
A frontier kept by an earlier wake starts the cursor first. While that still fails, the pusher backs off unevaluated, keeping the frontier.
Source§impl Service
impl Service
Sourcepub async fn reset_notification_counts(
&self,
user_id: &UserId,
room_id: &RoomId,
)
pub async fn reset_notification_counts( &self, user_id: &UserId, room_id: &RoomId, )
Reset the room’s main-timeline notification counts.
The last-read stamp gates sync output; callers dispatch the badge refresh after every reset.
Source§impl Service
impl Service
Sourcepub async fn reset_thread_notification_counts(
&self,
user_id: &UserId,
room_id: &RoomId,
thread_root: &EventId,
)
pub async fn reset_thread_notification_counts( &self, user_id: &UserId, room_id: &RoomId, thread_root: &EventId, )
Reset counts for a single thread within a room.
The last-read stamp gates sync output.
Source§impl Service
impl Service
Sourcepub async fn clear_all_thread_notification_counts(
&self,
user_id: &UserId,
room_id: &RoomId,
)
pub async fn clear_all_thread_notification_counts( &self, user_id: &UserId, room_id: &RoomId, )
Clear all per-thread notification state for this user and room.
The Interfix prefix excludes the main row. The notification-count sweep
runs under the increment mutex so a concurrent read-modify-write cannot
resurrect a cleared row.
Source§impl Service
impl Service
Sourcepub async fn reset_notification_counts_for_thread(
&self,
user_id: &UserId,
room_id: &RoomId,
acknowledged: Option<&EventId>,
thread: &ReceiptThread,
)
pub async fn reset_notification_counts_for_thread( &self, user_id: &UserId, room_id: &RoomId, acknowledged: Option<&EventId>, thread: &ReceiptThread, )
Dispatcher: route a receipt’s ReceiptThread to the matching reset path.
Unthreaded clears all room and thread counts; Main clears only the
main-timeline counts; Thread(id) clears just that thread unless the
acknowledged event is the thread root. None denotes a non-receipt reset.
Source§impl Service
impl Service
pub async fn notification_count( &self, user_id: &UserId, room_id: &RoomId, ) -> u64
Source§impl Service
impl Service
Sourcepub async fn global_notification_count(&self, user_id: &UserId) -> u64
pub async fn global_notification_count(&self, user_id: &UserId) -> u64
Return the user’s account-wide unread notification count.
Joined main and thread rows contribute to a saturating total. A row whose key or count cannot be read is logged and contributes nothing.
Source§impl Service
impl Service
pub async fn highlight_count(&self, user_id: &UserId, room_id: &RoomId) -> u64
Source§impl Service
impl Service
Sourcepub async fn thread_notification_counts(
&self,
user_id: &UserId,
room_id: &RoomId,
) -> BTreeMap<OwnedEventId, (u64, u64)>
pub async fn thread_notification_counts( &self, user_id: &UserId, room_id: &RoomId, ) -> BTreeMap<OwnedEventId, (u64, u64)>
Per-thread (notification, highlight) counts for one room and user.
Interfix excludes the legacy 2-tuple main row from the scan; only
3-tuple (user, room, root) rows match.
Source§impl Service
impl Service
Sourcepub async fn notification_read<E>(
&self,
user_id: &UserId,
event: &E,
count: u64,
) -> boolwhere
E: Event,
pub async fn notification_read<E>(
&self,
user_id: &UserId,
event: &E,
count: u64,
) -> boolwhere
E: Event,
Whether the user has read past one notified event.
The room’s main watermark covers every notification up to it, and a
notification in a thread is also read once that thread’s watermark passes
it. count is the event’s position, comparable with both.
Source§impl Service
impl Service
pub async fn last_notification_read( &self, user_id: &UserId, room_id: &RoomId, ) -> Result<u64>
Source§impl Service
impl Service
Sourcepub async fn last_thread_notification_read(
&self,
user_id: &UserId,
room_id: &RoomId,
thread_root: &EventId,
) -> Result<u64>
pub async fn last_thread_notification_read( &self, user_id: &UserId, room_id: &RoomId, thread_root: &EventId, ) -> Result<u64>
Read the last notification watermark for one thread.
Uses the same room, user and thread key as thread count resets.
Source§impl Service
impl Service
Sourcepub async fn thread_last_notification_reads(
&self,
user_id: &UserId,
room_id: &RoomId,
) -> BTreeMap<OwnedEventId, u64>
pub async fn thread_last_notification_reads( &self, user_id: &UserId, room_id: &RoomId, ) -> BTreeMap<OwnedEventId, u64>
Per-thread last-read counts for one room and user. Interfix keeps the
scan to 3-tuple (room, user, root) rows; the legacy 2-tuple main row
is excluded by construction and lives behind last_notification_read.
Source§impl Service
impl Service
pub async fn delete_room_notification_read(&self, room_id: &RoomId) -> Result
Source§impl Service
impl Service
Sourcepub(crate) async fn redact_pdu(
&self,
pdu_id: &RawPduId,
event_id: &EventId,
pdu: &CanonicalJsonObject,
)
pub(crate) async fn redact_pdu( &self, pdu_id: &RawPduId, event_id: &EventId, pdu: &CanonicalJsonObject, )
Takes a redacted event out of each local member’s unread counts.
As Synapse deletes a redacted event’s push actions, each member’s
notification record for the event is removed, and the counts the event
raised drop by one while they still count it. Removing the record first
makes a second redaction of the event a no-op. Runs before
timeline::redact_pdu strips the relations the thread lookup reads.
Source§impl Service
impl Service
Sourceasync fn uncount(
&self,
counter: Counter<'_>,
actions: &[Action],
user: &UserId,
redacted: Redacted<'_>,
)
async fn uncount( &self, counter: Counter<'_>, actions: &[Action], user: &UserId, redacted: Redacted<'_>, )
Subtract the event from one of the user’s counters if its actions raised that counter and it still counts the event.
Runs under the counter’s increment lock, which the notification reset also holds while it zeroes its counter. The highlight reset takes no lock, so a receipt racing a redaction can lose its zero, as it can racing an increment.
Source§impl Service
impl Service
Sourceasync fn still_counted(
&self,
counter: Counter<'_>,
user: &UserId,
redacted: Redacted<'_>,
value: u64,
) -> bool
async fn still_counted( &self, counter: Counter<'_>, user: &UserId, redacted: Redacted<'_>, value: u64, ) -> bool
Whether a counter holding value still counts the redacted event.
Every reset zeroes a whole counter, so it holds just its notifying events since the last reset. A thread’s own stamp dates that reset, because an unthreaded receipt deletes the thread stamps as it clears their counts. The room stamp dates it for the main timeline, but a main-timeline receipt also moves it without clearing threads, so a thread event behind it is settled by the thread’s later replies.
Source§impl Service
impl Service
Sourceasync fn counted_by_replies(
&self,
counter: Counter<'_>,
user: &UserId,
__arg3: Redacted<'_>,
root: &EventId,
value: u64,
) -> bool
async fn counted_by_replies( &self, counter: Counter<'_>, user: &UserId, __arg3: Redacted<'_>, root: &EventId, value: u64, ) -> bool
Whether fewer than value of the thread’s later replies raised the counter.
The counter holds the thread’s latest notifying events, so the redacted
reply is among them exactly while fewer than value later replies raised
it for the user. At most thread_latest_reply_search_limit relation rows
are read; a walk that uses them all, or fails to read one, returns false,
as does an unknown or backfilled root, which holds no relations. Only
direct thread replies are seen, while the thread bucket takes any event
within three relation hops of the root, so a notifying event that joins it
by such a hop can leave the count one low.
Source§impl Service
impl Service
Sourceasync fn raised_by_reply(
&self,
counter: Counter<'_>,
user: &UserId,
shortroomid: ShortRoomId,
count: Count,
) -> bool
async fn raised_by_reply( &self, counter: Counter<'_>, user: &UserId, shortroomid: ShortRoomId, count: Count, ) -> bool
Whether a reply raised the counter for the user as a direct thread reply.
The user’s notification record decides first, so a reply that never notified them costs no event load.
Source§impl Service
impl Service
pub async fn send_push_notice<E>(
&self,
user_id: &UserId,
pusher: &Pusher,
ruleset: &Ruleset,
event: &E,
) -> Resultwhere
E: Event,
Source§impl Service
impl Service
Sourcepub async fn send_badge_notice(
&self,
user_id: &UserId,
pusher: &Pusher,
) -> Result
pub async fn send_badge_notice( &self, user_id: &UserId, pusher: &Pusher, ) -> Result
Send an account-wide counts-only notification to a push gateway.
Enabled HTTP pushers emit the request, including an explicit zero. The delivery is skipped only when the gateway is known to hold the current total already; an unknown gateway is always sent to.
Source§impl Service
impl Service
fn prepare_http_pusher( &self, pusher: &Pusher, http: &HttpPusherData, ) -> Result<Device>
Source§impl Service
impl Service
Sourceasync fn send_http_notice(
&self,
user_id: &UserId,
pusher: &Pusher,
http: &HttpPusherData,
notify: Notification,
unread: Option<UInt>,
) -> Result
async fn send_http_notice( &self, user_id: &UserId, pusher: &Pusher, http: &HttpPusherData, notify: Notification, unread: Option<UInt>, ) -> Result
Deliver one notification to the pusher’s gateway and honor its verdict.
A pushkey the gateway names in rejected has its pusher removed. unread
names the counts value on the wire; it is recorded as delivered only after
the gateway accepts, so a failed or rejected send leaves the next refresh
unconditional.
Source§impl Service
impl Service
Sourcepub fn queue_suppressed_push(
&self,
user_id: &UserId,
pushkey: &str,
room_id: &RoomId,
pdu_id: RawPduId,
) -> bool
pub fn queue_suppressed_push( &self, user_id: &UserId, pushkey: &str, room_id: &RoomId, pdu_id: RawPduId, ) -> bool
Enqueue a PDU for later push delivery when suppression is active.
Source§impl Service
impl Service
Sourcepub fn take_suppressed_for_pushkey(
&self,
user_id: &UserId,
pushkey: &str,
) -> SuppressedRooms
pub fn take_suppressed_for_pushkey( &self, user_id: &UserId, pushkey: &str, ) -> SuppressedRooms
Take and remove all suppressed PDUs for a given user + pushkey.
Source§impl Service
impl Service
Sourcepub fn take_suppressed_for_user(&self, user_id: &UserId) -> SuppressedPushes
pub fn take_suppressed_for_user(&self, user_id: &UserId) -> SuppressedPushes
Take and remove all suppressed PDUs for a given user across all pushkeys.
Source§impl Service
impl Service
Sourcepub fn clear_suppressed_room(&self, user_id: &UserId, room_id: &RoomId) -> usize
pub fn clear_suppressed_room(&self, user_id: &UserId, room_id: &RoomId) -> usize
Clear suppressed PDUs for a specific room (across all pushkeys).
Source§impl Service
impl Service
Sourcepub fn clear_suppressed_pushkey(&self, user_id: &UserId, pushkey: &str) -> usize
pub fn clear_suppressed_pushkey(&self, user_id: &UserId, pushkey: &str) -> usize
Clear suppressed PDUs for a specific pushkey.
Source§impl Service
impl Service
Sourcepub fn suppressed_for_pushkey(
&self,
user_id: &UserId,
pushkey: &str,
) -> impl Iterator<Item = (OwnedRoomId, RawPduId)> + use<>
pub fn suppressed_for_pushkey( &self, user_id: &UserId, pushkey: &str, ) -> impl Iterator<Item = (OwnedRoomId, RawPduId)> + use<>
Snapshot the suppressed events for one pusher without draining them.
Ownership lets callers inspect the snapshot without holding the queue lock.
Source§impl Service
impl Service
Sourcepub async fn set_pusher(
&self,
sender: &UserId,
sender_device: &DeviceId,
pusher: &PusherAction,
) -> Result
pub async fn set_pusher( &self, sender: &UserId, sender_device: &DeviceId, pusher: &PusherAction, ) -> Result
Stores or deletes one of the user’s pushers, as /pushers/set asks.
Storing refuses an HTTP pusher whose URL is invalid or forbidden. It refuses an email pusher when the server has no SMTP, or when the address is malformed or not verified on the user’s account.
Source§impl Service
impl Service
async fn set_pusher_post( &self, sender: &UserId, sender_device: &DeviceId, action: &PusherAction, pusher: &Pusher, ) -> Result
Source§impl Service
impl Service
Sourceasync fn check_email_pusher(&self, sender: &UserId, address: &str) -> Result
async fn check_email_pusher(&self, sender: &UserId, address: &str) -> Result
Refuses an email pusher this server cannot or may not deliver.
Mail needs SMTP configured and the address verified on the sender’s own account. Without the binding check any user could direct notification mail at any address.
Source§impl Service
impl Service
Sourcepub async fn delete_pusher(&self, sender: &UserId, pushkey: &str)
pub async fn delete_pusher(&self, sender: &UserId, pushkey: &str)
Deletes one of the user’s pushers, with its email cursor and throttles.
The email lock keeps the worker from writing them back.
Source§impl Service
impl Service
Sourceasync fn remove_pusher(&self, sender: &UserId, pushkey: &str)
async fn remove_pusher(&self, sender: &UserId, pushkey: &str)
Deletes a pusher and everything kept for it.
Callers hold the pusher’s email lock.
Source§impl Service
impl Service
pub async fn get_device_pushkeys( &self, sender: &UserId, device_id: &DeviceId, ) -> Vec<String>
Source§impl Service
impl Service
pub async fn get_pusher_device(&self, pushkey: &str) -> Result<OwnedDeviceId>
Source§impl Service
impl Service
pub async fn get_pusher(&self, sender: &UserId, pushkey: &str) -> Result<Pusher>
Source§impl Service
impl Service
pub fn get_pushkeys<'a>( &'a self, sender: &'a UserId, ) -> impl Stream<Item = &str> + Send + 'a
Source§impl Service
impl Service
pub async fn get_actions<'a>(&self, __arg1: Evaluate<'a, '_>) -> &'a [Action]
Source§impl Service
impl Service
Resolve the events an event relates to, for the MSC3664 push condition.
None while push.msc3664_related_event_match is disabled, which leaves every
MSC3664 condition unable to match. The relations do not vary by recipient,
so the append path resolves them once for the whole room; the push-notice
path resolves them per notice, since it holds one event at a time.
Trait Implementations§
Source§impl Service for Service
impl Service for Service
Source§fn build(args: &Args<'_>) -> Result<Arc<Self>>
fn build(args: &Args<'_>) -> Result<Arc<Self>>
Source§fn worker<'async_trait>(
self: Arc<Self>,
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>where
Self: 'async_trait,
fn worker<'async_trait>(
self: Arc<Self>,
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>where
Self: 'async_trait,
Source§fn interrupt<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn interrupt<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn name(&self) -> &str
fn name(&self) -> &str
crate::service::make_name(std::module_path!())Source§fn clear_cache<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear_cache<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn memory_usage<'life0, 'life1, 'async_trait>(
&'life0 self,
_out: &'life1 mut (dyn Write + Send),
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn memory_usage<'life0, 'life1, 'async_trait>(
&'life0 self,
_out: &'life1 mut (dyn Write + Send),
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn unconstrained(&self) -> bool
fn unconstrained(&self) -> bool
Auto Trait Implementations§
impl !Freeze for Service
impl !RefUnwindSafe for Service
impl !UnwindSafe for Service
impl Send for Service
impl Sync for Service
impl Unpin for Service
impl UnsafeUnpin for Service
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ExpectInto for T
impl<T> ExpectInto for T
Source§impl<T> Expected for T
impl<T> Expected for T
Source§fn expected_add(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedAdd,
fn expected_add(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedAdd,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_sub(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedSub,
fn expected_sub(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedSub,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_mul(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedMul,
fn expected_mul(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedMul,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_div(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedDiv,
fn expected_div(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedDiv,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_rem(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedRem,
fn expected_rem(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedRem,
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> JsonCastable<CanonicalJsonValue> for T
impl<T> JsonCastable<Value> for T
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ServiceExt for T
impl<T> ServiceExt for T
§fn add_extension<T>(self, value: T) -> AddExtension<Self, T>where
Self: Sized,
fn add_extension<T>(self, value: T) -> AddExtension<Self, T>where
Self: Sized,
§fn compression(self) -> Compression<Self>where
Self: Sized,
fn compression(self) -> Compression<Self>where
Self: Sized,
§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
§fn sensitive_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>where
Self: Sized,
fn sensitive_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>where
Self: Sized,
§fn sensitive_request_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<Self>where
Self: Sized,
fn sensitive_request_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<Self>where
Self: Sized,
§fn sensitive_response_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveResponseHeaders<Self>where
Self: Sized,
fn sensitive_response_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveResponseHeaders<Self>where
Self: Sized,
§fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
500 Internal Server responses. Read moreSource§impl<T> Tried for T
impl<T> Tried for T
Source§fn try_add(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedAdd,
fn try_add(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedAdd,
rhs with checked arithmetic. Read moreSource§fn try_sub(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedSub,
fn try_sub(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedSub,
rhs with checked arithmetic. Read moreSource§fn try_mul(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedMul,
fn try_mul(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedMul,
rhs with checked arithmetic. Read more