Skip to main content

Module sync

Module sync 

Source
Expand description

Profile sync — priority queue, background processor, and relay fetching.

The sync queue batches profile fetches by priority (Critical → High → Medium → Low), with cache windows to avoid hammering relays. The background processor drains the queue and calls load_profile for each entry.

Platform-specific work (DB persistence, image caching) is handled by the ProfileSyncHandler trait — src-tauri provides TauriProfileSyncHandler, CLI provides a no-op or logging implementation.

Structs§

NoOpProfileSyncHandler
No-op handler for CLI/tests.
ProfileSyncQueue
Profile sync queue manager with four priority lanes.

Enums§

SyncPriority
Priority levels for profile syncing, most urgent first (Critical < Low).

Constants§

STATUS_MAX_CHARS
Update the current user’s status (kind 30315) and broadcast to relays.

Traits§

ProfileSyncHandler
Callback trait for platform-specific profile sync work.

Functions§

accept_chat
Accept a DM request without answering it: what its sender sent, and their pictures, may load from now on.
block_user
Block a user by npub. DM events from blocked users are dropped after decryption. Group messages are stored but filtered in the UI.
get_blocked_users
Get all blocked profiles.
load_profile
Fetch a profile’s metadata and status from relays, update STATE, and notify via EventEmitter + handler callback.
persist_forgotten_imagery
Persist what ChatState::forget_blocked_imagery dropped and delete the files.
queue_chat_profiles
Queue all profiles for a chat. A community’s members refresh as they come on screen (queue_visible_profiles), so here a community only fetches the ones we know nothing of.
queue_profile_sync
Queue a single profile for syncing.
queue_visible_profiles
Queue the profiles the UI has on screen (or nearly) whose last check has gone stale. Called on every view, so it costs a lookup per npub and a fetch only for those that need one.
refresh_profile_now
Force immediate refresh of a profile (for user clicks).
set_nickname
Set a nickname for a profile.
set_stream_consent
Publish our kind-0 with stream consent set to on; returns the value now in effect.
stamp_vector_client
Once a login: a profile last written by another client takes our client tag, every key and tag of it kept, so servers that serve Vector’s users recognise the account. Returns whether it published.
stamp_vector_client_after_sync
stamp_vector_client once the login’s sync has settled: its relays are busiest before it.
start_profile_sync_processor
Background processor that continuously drains the profile sync queue.
sync_all_profiles
Queue every profile that has never been fetched. Known profiles refresh when their chat opens or they come on screen (queue_visible_profiles).
unblock_user
Unblock a user by npub.
update_bot_profile
Publish the current user’s profile and mark it as a bot (bot: true in the metadata). The SDK uses this so every bot it builds is tagged; human clients use update_profile.
update_profile
Update the current user’s profile metadata and broadcast to relays.
update_status
Status is ephemeral — updated in STATE + frontend but not persisted to DB. (Re-fetched from relays on next load_profile call.)