Skip to main content

Service

Struct Service 

Source
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

Source

pub(crate) async fn append_pdu(&self, pdu_id: RawPduId, pdu: &Pdu) -> Result

Called by timeline append_pdu.

Source§

impl Service

Source

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

Source

async fn append_pdu_for_user(&self, user: &UserId, __arg2: Appended<'_>)

Source§

impl Service

Source

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

Source

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

Source

fn queue_push(&self, user: &UserId, pdu_id: &RawPduId, pushkey: String)

Source§

impl Service

Source

async fn increment_notificationcount(&self, room_id: &RoomId, user_id: &UserId)

Source§

impl Service

Source

async fn increment_highlightcount(&self, room_id: &RoomId, user_id: &UserId)

Source§

impl Service

Source

async fn increment_thread_notificationcount( &self, room_id: &RoomId, user_id: &UserId, thread_root: &EventId, )

Source§

impl Service

Source

async fn increment_thread_highlightcount( &self, room_id: &RoomId, user_id: &UserId, thread_root: &EventId, )

Source§

impl Service

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

async fn record_state<'a, Rooms>( &self, user_id: &UserId, pushkey: &str, stored: u64, cursor: u64, rooms: Rooms, )
where Rooms: Iterator<Item = (&'a RoomId, Throttle)> + Send,

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

Source

fn write_state<'a, Rooms>( &self, user_id: &UserId, pushkey: &str, cursor: u64, rooms: Rooms, )
where Rooms: Iterator<Item = (&'a RoomId, Throttle)>,

Writes the cursor and each room’s throttle in one transaction.

The cursor never moves past a mail without the throttles it set.

Source§

impl Service

Source

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

Source

async fn render_room<'a, Shown>( &self, user_id: &UserId, room_id: &RoomId, shown: Shown, ) -> Room
where Shown: Iterator<Item = &'a Pending> + Send,

Source§

impl Service

Source

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

Source

async fn room_name(&self, room_id: &RoomId) -> Option<String>

The room’s name, else its canonical alias, put on one line.

A name left with no text counts as none. A room with neither is None, and the mail labels it by its first sender.

Source§

impl Service

Source

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

Source

pub(super) async fn email_lock( &self, user_id: &UserId, pushkey: &str, ) -> MutexMapGuard<(OwnedUserId, SmallString<[u8; 48]>), ()>

Source§

impl Service

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

async fn boot_schedule( &self, ) -> BTreeMap<(OwnedUserId, SmallString<[u8; 48]>), Entry>

Schedules every email pusher with a cursor.

Mail pending across a restart then goes out without waiting for a fresh notification; a pusher with nothing left evaluates to idle.

Source§

impl Service

Source

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

Source

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

Source

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

Source

async fn email_cursor( &self, user_id: &UserId, pushkey: &str, ) -> Result<Option<u64>>

The pusher’s cursor, or None when it has none.

A cursor that cannot be read is logged and is an error, never taken for its absence.

Source§

impl Service

Source

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

Source

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

Source

async fn reset_notification_count<K>( &self, room_id: &RoomId, user_id: &UserId, key: K, )
where K: Serialize + Debug + Send + Sync,

Source§

impl Service

Source

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

Source

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

Source

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

Source

pub async fn notification_count( &self, user_id: &UserId, room_id: &RoomId, ) -> u64

Source§

impl Service

Source

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

Source

pub async fn highlight_count(&self, user_id: &UserId, room_id: &RoomId) -> u64

Source§

impl Service

Source

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

Source

pub async fn notification_read<E>( &self, user_id: &UserId, event: &E, count: u64, ) -> bool
where 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

Source

pub async fn last_notification_read( &self, user_id: &UserId, room_id: &RoomId, ) -> Result<u64>

Source§

impl Service

Source

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

Source

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

Source

pub async fn delete_room_notification_read(&self, room_id: &RoomId) -> Result

Source§

impl Service

Source

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

Source

async fn redact_pdu_for_user(&self, user: &UserId, redacted: Redacted<'_>)

Source§

impl Service

Source

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

Source

async fn uncount_at<K>( &self, counter: Counter<'_>, key: K, user: &UserId, redacted: Redacted<'_>, )
where K: Serialize + Debug + Send + Sync,

Source§

impl Service

Source

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

Source

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

Source

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

Source

pub(super) async fn send_request<T>( &self, dest: &str, request: T, ) -> Result<T::IncomingResponse>
where T: OutgoingRequest + Debug + Send, for<'a> T::Authentication: AuthScheme<Input<'a> = ()>, for<'a> T::PathBuilder: PathBuilder<Input<'a> = ()>,

Source§

impl Service

Source

async fn handle_ok<T>( &self, dest: &str, response: Response, ) -> Result<T::IncomingResponse>
where T: OutgoingRequest,

Source§

impl Service

Source

pub async fn send_push_notice<E>( &self, user_id: &UserId, pusher: &Pusher, ruleset: &Ruleset, event: &E, ) -> Result
where E: Event,

Source§

impl Service

Source

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

Source

async fn send_notice<Pdu: Event>( &self, user_id: &UserId, pusher: &Pusher, tweaks: Vec<Tweak>, event: &Pdu, ) -> Result

Source§

impl Service

Source

async fn send_http_event_notice<Pdu: Event>( &self, user_id: &UserId, pusher: &Pusher, http: &HttpPusherData, tweaks: Vec<Tweak>, event: &Pdu, ) -> Result

Source§

impl Service

Source

fn prepare_http_pusher( &self, pusher: &Pusher, http: &HttpPusherData, ) -> Result<Device>

Source§

impl Service

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub fn clear_suppressed_pushkey(&self, user_id: &UserId, pushkey: &str) -> usize

Clear suppressed PDUs for a specific pushkey.

Source§

impl Service

Source

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

Source

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

Source

async fn set_pusher_delete(&self, sender: &UserId, pushkey: &str)

Source§

impl Service

Source

async fn set_pusher_post( &self, sender: &UserId, sender_device: &DeviceId, action: &PusherAction, pusher: &Pusher, ) -> Result

Source§

impl Service

Source§

impl Service

Source

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

Source

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

Source

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

Source

pub async fn get_device_pushkeys( &self, sender: &UserId, device_id: &DeviceId, ) -> Vec<String>

Source§

impl Service

Source

pub async fn get_pusher_device(&self, pushkey: &str) -> Result<OwnedDeviceId>

Source§

impl Service

Source

pub async fn get_pusher(&self, sender: &UserId, pushkey: &str) -> Result<Pusher>

Source§

impl Service

Source

pub async fn get_pushers(&self, sender: &UserId) -> Vec<Pusher>

Source§

impl Service

Source

pub fn get_pushkeys<'a>( &'a self, sender: &'a UserId, ) -> impl Stream<Item = &str> + Send + 'a

Source§

impl Service

Source

pub async fn ruleset(&self, user_id: &UserId) -> Ruleset

The push ruleset a user’s notifications are evaluated against.

A user without stored rules gets the server default ruleset.

Source§

impl Service

Source

pub fn get_notifications<'a>( &'a self, sender: &'a UserId, from: Option<u64>, ) -> impl Stream<Item = (u64, Notified)> + Send + 'a

Source§

impl Service

Source

pub async fn get_actions<'a>(&self, __arg1: Evaluate<'a, '_>) -> &'a [Action]

Source§

impl Service

Source

pub async fn related_events<E: Event>( &self, event: &E, ) -> Option<Arc<BTreeMap<String, FlattenedJson>>>

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

Source§

fn build(args: &Args<'_>) -> Result<Arc<Self>>

Implement the construction of the service instance. Services are generally singletons so expect this to only be called once for a service type. Note that it may be called again after a server reload, but the prior instance will have been dropped first. Failure will shutdown the server with an error.
Source§

fn worker<'async_trait>( self: Arc<Self>, ) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>
where Self: 'async_trait,

Implement the service’s worker loop. The service manager spawns a task and calls this function after all services have been built.
Source§

fn interrupt<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Interrupt the service. This is sent to initiate a graceful shutdown. The service worker should return from its work loop.
Source§

fn name(&self) -> &str

Return the name of the service. i.e. 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,

Clear any caches or similar runtime state.
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,

Memory usage report in a markdown string.
Source§

fn unconstrained(&self) -> bool

Return true if the service worker opts out of the tokio cooperative budgeting. This can reduce tail latency at the risk of event loop starvation.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> DropFlavorWrapper<T> for T

§

type Flavor = MayDrop

The DropFlavor that [wrap]s T into Self
Source§

impl<T> ExpectInto for T

Source§

fn expect_into<Dst>(self) -> Dst
where Dst: TryFrom<Self>, Self: Sized,

Converts the value into Dst and returns the successful result. Read more
Source§

impl<T> Expected for T

Source§

fn expected_add(self, rhs: Self) -> Self
where Self: Sized + CheckedAdd,

Adds rhs with an expectation that the operation is valid. Read more
Source§

fn expected_sub(self, rhs: Self) -> Self
where Self: Sized + CheckedSub,

Subtracts rhs with an expectation that the operation is valid. Read more
Source§

fn expected_mul(self, rhs: Self) -> Self
where Self: Sized + CheckedMul,

Multiplies by rhs with an expectation that the operation is valid. Read more
Source§

fn expected_div(self, rhs: Self) -> Self
where Self: Sized + CheckedDiv,

Divides by rhs with an expectation that the operation is valid. Read more
Source§

fn expected_rem(self, rhs: Self) -> Self
where Self: Sized + CheckedRem,

Computes the remainder with an expectation that the operation is valid. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

§

const WITNESS: W = W::MAKE

A constant of the type witness
§

impl<T> Identity for T
where T: ?Sized,

§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
§

impl<T> JsonCastable<CanonicalJsonValue> for T

§

impl<T> JsonCastable<Value> for T

§

impl<T> Paint for T
where T: ?Sized,

§

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 primary(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Primary].

§Example
println!("{}", value.primary());
§

fn fixed(&self, color: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Fixed].

§Example
println!("{}", value.fixed(color));
§

fn rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Rgb].

§Example
println!("{}", value.rgb(r, g, b));
§

fn black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Black].

§Example
println!("{}", value.black());
§

fn red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Red].

§Example
println!("{}", value.red());
§

fn green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Green].

§Example
println!("{}", value.green());
§

fn yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Yellow].

§Example
println!("{}", value.yellow());
§

fn blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Blue].

§Example
println!("{}", value.blue());
§

fn magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Magenta].

§Example
println!("{}", value.magenta());
§

fn cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Cyan].

§Example
println!("{}", value.cyan());
§

fn white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: White].

§Example
println!("{}", value.white());
§

fn bright_black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlack].

§Example
println!("{}", value.bright_black());
§

fn bright_red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightRed].

§Example
println!("{}", value.bright_red());
§

fn bright_green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightGreen].

§Example
println!("{}", value.bright_green());
§

fn bright_yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightYellow].

§Example
println!("{}", value.bright_yellow());
§

fn bright_blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlue].

§Example
println!("{}", value.bright_blue());
§

fn bright_magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.bright_magenta());
§

fn bright_cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightCyan].

§Example
println!("{}", value.bright_cyan());
§

fn bright_white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightWhite].

§Example
println!("{}", value.bright_white());
§

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>

Returns self with the bg() set to [Color :: Primary].

§Example
println!("{}", value.on_primary());
§

fn on_fixed(&self, color: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Fixed].

§Example
println!("{}", value.on_fixed(color));
§

fn on_rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Rgb].

§Example
println!("{}", value.on_rgb(r, g, b));
§

fn on_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Black].

§Example
println!("{}", value.on_black());
§

fn on_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Red].

§Example
println!("{}", value.on_red());
§

fn on_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Green].

§Example
println!("{}", value.on_green());
§

fn on_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Yellow].

§Example
println!("{}", value.on_yellow());
§

fn on_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Blue].

§Example
println!("{}", value.on_blue());
§

fn on_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Magenta].

§Example
println!("{}", value.on_magenta());
§

fn on_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Cyan].

§Example
println!("{}", value.on_cyan());
§

fn on_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: White].

§Example
println!("{}", value.on_white());
§

fn on_bright_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlack].

§Example
println!("{}", value.on_bright_black());
§

fn on_bright_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightRed].

§Example
println!("{}", value.on_bright_red());
§

fn on_bright_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightGreen].

§Example
println!("{}", value.on_bright_green());
§

fn on_bright_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightYellow].

§Example
println!("{}", value.on_bright_yellow());
§

fn on_bright_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlue].

§Example
println!("{}", value.on_bright_blue());
§

fn on_bright_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.on_bright_magenta());
§

fn on_bright_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightCyan].

§Example
println!("{}", value.on_bright_cyan());
§

fn on_bright_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightWhite].

§Example
println!("{}", value.on_bright_white());
§

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 bold(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Bold].

§Example
println!("{}", value.bold());
§

fn dim(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Dim].

§Example
println!("{}", value.dim());
§

fn italic(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Italic].

§Example
println!("{}", value.italic());
§

fn underline(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Underline].

§Example
println!("{}", value.underline());

Returns self with the attr() set to [Attribute :: Blink].

§Example
println!("{}", value.blink());

Returns self with the attr() set to [Attribute :: RapidBlink].

§Example
println!("{}", value.rapid_blink());
§

fn invert(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Invert].

§Example
println!("{}", value.invert());
§

fn conceal(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Conceal].

§Example
println!("{}", value.conceal());
§

fn strike(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Strike].

§Example
println!("{}", value.strike());
§

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 mask(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Mask].

§Example
println!("{}", value.mask());
§

fn wrap(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Wrap].

§Example
println!("{}", value.wrap());
§

fn linger(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Linger].

§Example
println!("{}", value.linger());
§

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.

Returns self with the quirk() set to [Quirk :: Clear].

§Example
println!("{}", value.clear());
§

fn resetting(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Resetting].

§Example
println!("{}", value.resetting());
§

fn bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Bright].

§Example
println!("{}", value.bright());
§

fn on_bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: OnBright].

§Example
println!("{}", value.on_bright());
§

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);
§

fn new(self) -> Painted<Self>
where Self: Sized,

Create a new [Painted] with a default [Style]. Read more
§

fn paint<S>(&self, style: S) -> Painted<&Self>
where S: Into<Style>,

Apply a style wholesale to self. Any previous style is replaced. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ServiceExt for T

§

fn add_extension<T>(self, value: T) -> AddExtension<Self, T>
where Self: Sized,

Add some shareable value to request extensions. Read more
§

fn compression(self) -> Compression<Self>
where Self: Sized,

Compresses response bodies. Read more
§

fn decompression(self) -> Decompression<Self>
where Self: Sized,

Decompress response bodies. Read more
§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
§

fn follow_redirects(self) -> FollowRedirect<Self>
where Self: Sized,

Follow redirect resposes using the Standard policy. Read more
§

fn sensitive_headers( self, headers: impl IntoIterator<Item = HeaderName>, ) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>
where Self: Sized,

Mark headers as sensitive on both requests and responses. Read more
§

fn sensitive_request_headers( self, headers: impl IntoIterator<Item = HeaderName>, ) -> SetSensitiveRequestHeaders<Self>
where Self: Sized,

Mark headers as sensitive on requests. Read more
§

fn sensitive_response_headers( self, headers: impl IntoIterator<Item = HeaderName>, ) -> SetSensitiveResponseHeaders<Self>
where Self: Sized,

Mark headers as sensitive on responses. Read more
§

fn override_request_header<M>( self, header_name: HeaderName, make: M, ) -> SetRequestHeader<Self, M>
where Self: Sized,

Insert a header into the request. Read more
§

fn append_request_header<M>( self, header_name: HeaderName, make: M, ) -> SetRequestHeader<Self, M>
where Self: Sized,

Append a header into the request. Read more
§

fn insert_request_header_if_not_present<M>( self, header_name: HeaderName, make: M, ) -> SetRequestHeader<Self, M>
where Self: Sized,

Insert a header into the request, if the header is not already present. Read more
§

fn override_response_header<M>( self, header_name: HeaderName, make: M, ) -> SetResponseHeader<Self, M>
where Self: Sized,

Insert a header into the response. Read more
§

fn append_response_header<M>( self, header_name: HeaderName, make: M, ) -> SetResponseHeader<Self, M>
where Self: Sized,

Append a header into the response. Read more
§

fn insert_response_header_if_not_present<M>( self, header_name: HeaderName, make: M, ) -> SetResponseHeader<Self, M>
where Self: Sized,

Insert a header into the response, if the header is not already present. Read more
§

fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>
where Self: Sized,

Catch panics and convert them into 500 Internal Server responses. Read more
Source§

impl<T> Tried for T

Source§

fn try_add(self, rhs: Self) -> Result<Self, Error>
where Self: Sized + CheckedAdd,

Adds rhs with checked arithmetic. Read more
Source§

fn try_sub(self, rhs: Self) -> Result<Self, Error>
where Self: Sized + CheckedSub,

Subtracts rhs with checked arithmetic. Read more
Source§

fn try_mul(self, rhs: Self) -> Result<Self, Error>
where Self: Sized + CheckedMul,

Multiplies by rhs with checked arithmetic. Read more
Source§

fn try_div(self, rhs: Self) -> Result<Self, Error>
where Self: Sized + CheckedDiv,

Divides by rhs with checked arithmetic. Read more
Source§

fn try_rem(self, rhs: Self) -> Result<Self, Error>
where Self: Sized + CheckedRem,

Computes the remainder by rhs with checked arithmetic. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more