Skip to main content

Module badges

Module badges 

Source
Expand description

Profile badges — fetch, validate, and cache.

Badges are not loaded during the critical boot path. The cache is filled once after initial sync (see refresh_own_badges) so badge-gated perks (e.g. raised emoji-pack limits) resolve without an on-demand network round-trip. has_vector_badge is the cheap synchronous reader used by those gates.

Constants§

NEW_REACTIONS_PER_POST_BY_TIER
Per-effective-tier cap on NEW reaction groups one user may open on a single message. Joining an existing reaction (+1) is never gated — only introducing an emoji the message doesn’t yet carry spends this allowance.

Functions§

bug_hunter_tier
Cached Bug Hunter tier (0-3) for the current account. Cheap + synchronous; 0 until the award fetch fills it.
check_new_reaction_allowance
Sender-side gate for reacting to reference_id with emoji: joining an existing group always passes; opening a new group checks the message-wide group ceiling, then the per-tier allowance. “Groups I opened” is judged by insertion order in our own view — the earliest held reaction per emoji. Ok(()) when the send may proceed.
effective_max_new_reactions_per_post
The current account’s fresh-reaction allowance per message.
effective_tier
The account’s effective premium tier (0-3): the higher of the Bug Hunter tier and the V for Vector badge (full premium = tier 3). Per-account perks (emoji limits) read this.
fetch_bug_hunter_tier
Highest non-revoked tier + whether a seen award was revoked, for displaying another user’s badge. Our own status goes through refresh_own_bug_hunter, which also catches revocation of a since-purged award.
has_fawkes_badge
Fetch + validate whether pubkey holds the V for Vector (Guy Fawkes 2025) badge: a kind-30078 d=fawkes_2025 claim published within the event window.
has_vector_badge
Cached flag for whether we hold the Vector badge. Cheap + synchronous, so safe to call from limit checks. Defaults to false when unset — badge perks stay off until the cache is filled post-sync.
max_account_tier
The highest effective tier across ALL accounts on this install. The multi-account cap is device-level (adding a profile spans accounts), so it must not drop when you switch to an un-badged account — unlike the per-account perks. Reads each account’s badge state straight from its vector.db.
note_own_badge_confirmed
Record the result of an on-demand badge check. When the checked key is our own and the badge is present, persist it (sticky) and emit badges_updated so badge-gated perks (raised emoji-pack limits) turn on immediately — this is the safety net for a post-sync refresh_own_badges that missed the claim (the holding relay is often flaky during the saturated sync window) and is now sitting in its multi-hour re-check cooldown. An on-demand check runs at a quiet moment, so it lands where the sync-time sweep didn’t.
refresh_own_badges
Fetch our own badges and persist to the per-account cache. Called once after initial sync. The std::sync::Arccrate::db::Session straddles the network fetch so a mid-fetch account swap can’t write account A’s badge into account B’s DB.
refresh_own_bug_hunter
Resolve + persist our own Bug Hunter tier (called post-sync). Sticky cache: upgrades apply immediately; a downgrade is honored ONLY on a seen revocation, never a mere absent award (flaky relay). The ids of the awards backing the current tier are cached so a revocation still resolves after the relays purge the award itself (NIP-09 deletion).