Skip to main content

Module notify

Module notify 

Source
Expand description

Notification levels and mutes, for communities, channels and DMs alike.

Two settings per scope, doing different jobs. Level decides what rings: every message, only your name, or nothing. Mute greys the row, drops its unread weight, and clamps the level to at most Mentions — a volume knob, not an off switch, which is why Nothing is not a synonym for it.

Level resolves down the chain Community → Channel, most specific opinion winning. Mute unions down it: muting a community mutes every channel in it. With no opinion stored anywhere, what the conversation IS picks the level: a DM or a group chat rings for everything, a community only for your name.

Structs§

Preview
What a notification shows. Every platform passes its notification through Preview::apply, so the setting means the same thing everywhere.
Resolved
A scope’s settings after the chain has been walked.
ScopePrefs
One scope’s stored settings. None means inherit; suppress_everyone is only ever set at community scope.
Sender
The name and avatar a notification shows for someone.
StreamGate
Who Streamer Mode hides. Read once per notification, outside any state lock.

Enums§

ContentPrivacy
How much of a message a system notification reveals: the account’s notif_content_privacy setting, read at notify time.
MessageClass
What a message is, loudest first. Resolved once at classification so a suppressed @everyone is Normal everywhere downstream: notification, ping badge and muted-row count alike.
NotifyLevel
What rings. Ordered loudest first, so the numeric rank orders “quieter”.

Constants§

MUTE_FOREVER
mute_until sentinel for a mute with no end.
MUTE_OFF
mute_until sentinel for “not muted”.
STREAM_MASK
Stands in for every name Streamer Mode hides. Fixed length, so it says nothing about the name.

Functions§

all_prefs
apply_wire
Adopt a sibling device’s list wholesale. Returns the scopes whose settings actually moved, so the caller only has to repaint those.
channel_is_listed
Whether channel_id is one its community still lists. A channel nobody lists has no row to open, so its unread can never be seen or cleared.
community_muted_for_chat
Whether a chat’s COMMUNITY is itself silenced, rather than this one room inside it. A surface that stands for the whole space must not grey because one channel is quiet.
default_level
The level a scope starts at when nothing on its chain says otherwise. group_id is the Concord group the scope belongs to (or is), if any.
everyone_allowed
Whether an authorized @everyone may ping, for a community. Two levers: the App Settings kill switch, which wins outright, and the community’s own choice under it. A channel has no say, deliberately.
everyone_pings_for_chat
Whether an @everyone in this chat still counts as someone calling your name.
in_legacy_mute_list
The predicate the older vector/mutes projection is both WRITTEN and READ with. Publishing one shape and applying another is how an inherited mute ratchets into a permanent per-channel one.
invalidate
Drop the cache so the next warm re-reads the table.
invalidate_communities
Forget what was read off the communities: a channel set or an invite-link registry was rewritten, which can change both what is listed and whether a group is a group chat or a community.
is_community
Whether community_id is a community rather than a group chat. A group chat is one channel behind no invite link; anything bigger or open to strangers is a community, and a busy one can’t ring for every message.
is_loaded
Whether the table has actually been read. An unloaded cache answers “default” for every scope, which is indistinguishable from “nothing is stored” — so anything that WRITES state derived from it must check this first, the same rule synced_prefs::is_hydrated applies to publishing.
is_muted_at
legacy_muted_for_chat
in_legacy_mute_list for a chat, stored flag folded in like resolve_chat.
muted_for_chat
next_expiry
The soonest mute expiry still ahead of now_ms, for arming one timer rather than one per mute.
now_ms
passes
Whether a message of this class rings at this level.
prefs
resolve
Walk the chain for one scope. community_id is the channel’s community, or None for a DM or for a community resolving itself.
resolve_chat
A chat’s settings, with its stored muted flag folded in. That flag is the mirror this module keeps for the paths that predate it, and the landing point for a mute arriving over the older vector/mutes projection, so it counts as a mute in its own right rather than being assumed to agree.
resolve_from
The chain arithmetic on its own: level takes the most specific opinion, then fallback; mute takes either, and the mute clamps the level it hands back.
resolve_mentions
content with each mention (@npub1…, nostr:npub1…, a bare npub, or the same forms of an nprofile) read as @name. An unknown npub stays as written, except while streaming, where it and anyone hidden read as @•••••.
ring_for_chat
What a chat’s row should badge with: full unread at All, pings at Mentions, nothing at Nothing.
scan_mentions
The scanner behind resolve_mentions. lookup names a bare npub, or None to leave its token as written. An nprofile is looked up by the npub it encodes.
sender
Nickname, then name, then display name, else fallback; masked with no avatar when the gate hides them. Every platform’s notification names a sender through this.
sender_in
sender inside a community: the nickname they go by there, unless you named them yourself.
set_level
set_mute
set_prefs
Write a scope through to the database and the cache.
set_suppress_everyone
strip_ansi
content without terminal escape sequences: an ```ansi block’s colour codes are styling, and a notification has no way to show them.
sweep_expired
Clear every mute whose timer has run out, returning the scopes that just lapsed. Expiry is a write rather than a read: the callers of muted read a cached boolean, and making them all consult the clock instead would be the wrong fix.
to_wire
This device’s table as the publishable projection.
warm
Read the table into memory. Called once when a database is opened, because every badge recount resolves every chat and a lazy load would put a SQLite round trip on that path.