pub struct MetaPostManager { /* private fields */ }Expand description
Owns all of a user’s config state — profile bio, follows, content thresholds, skip-warnings,
etc. — backed by a MetaPostV1 envelope that can be published to the network.
§Storage
Public and private config are stored as two separate keys in BUCKET_CONFIG:
{client_id}.meta_post_v1_public→MetaPostPublicV1{client_id}.meta_post_v1_private→MetaPostPrivateV1
MetaPostV1 is used strictly as the network envelope — it is assembled from the two
stored sections at publish time and disassembled on receive. Because every field carries
its own TimeMillis timestamp, concurrent edits from multiple devices merge cleanly
via last-writer-wins.
§Publishing policy
Local config changes (follows, thresholds, skip_warnings, bio) are written to
BUCKET_CONFIG immediately but are not published to the network on every change —
that would spam the network whenever a user toggles follows or adjusts sliders. A
MetaPostV1 is published to the network in exactly two situations:
- Explicit publish — the user saves their bio in the UI, which calls
build_meta_post_json()followed bysubmit_post()on the client. This bundles the latest config (including any pending follow/threshold changes) into the post. - Auto-publish on startup —
should_auto_publish()checks whether the current month’s User bucket already contains aMetaPostV1from this client. If not (and the bucket isn’t full), the client publishes one so other users and the user’s own devices can always find an up-to-date config within a reasonable time window.
Implementations§
Source§impl MetaPostManager
impl MetaPostManager
pub fn new( runtime_services: Arc<RuntimeServices>, client_storage: Arc<dyn ClientStorage>, key_locker: Arc<dyn KeyLocker>, client_id: ClientId, ) -> Self
pub async fn get_public(&self) -> Result<MetaPostPublicV1>
pub async fn get_private(&self) -> Result<MetaPostPrivateV1>
Sourcepub async fn set_bio(
&self,
nickname: String,
status: String,
selfie: String,
avatar: String,
) -> Result<()>
pub async fn set_bio( &self, nickname: String, status: String, selfie: String, avatar: String, ) -> Result<()>
Update the public bio fields in the local config. Does NOT automatically publish to the network.
pub async fn get_meta_post_public( &self, id: Id, ) -> Result<Option<MetaPostPublicV1>>
pub async fn get_all_meta_post_publics( &self, ) -> Result<Vec<(String, MetaPostPublicV1)>>
Sourcepub async fn build_meta_post_json(&self) -> Result<String>
pub async fn build_meta_post_json(&self) -> Result<String>
Build the MetaPostV1 JSON string ready for submit_post().
Also updates the local BUCKET_META_POST_PUBLIC cache.
Sourcepub async fn should_auto_publish(
&self,
post_bundle_manager: &dyn PostBundleManager,
) -> Result<bool>
pub async fn should_auto_publish( &self, post_bundle_manager: &dyn PostBundleManager, ) -> Result<bool>
Check whether the current month’s User bucket already contains a
MetaPostV1 from this client. Returns true if we should publish.
Sourcepub async fn process_incoming_meta_post(
&self,
meta_post_v1: &MetaPostV1,
post_client_id: &ClientId,
) -> Result<()>
pub async fn process_incoming_meta_post( &self, meta_post_v1: &MetaPostV1, post_client_id: &ClientId, ) -> Result<()>
Process an incoming MetaPostV1 from the network. Caches the public section for any user; decrypts and merges the private section if the post is from our own client_id.
pub async fn get_followed_client_ids(&self) -> Result<Vec<Id>>
pub async fn set_followed_client_ids(&self, client_ids: Vec<Id>) -> Result<()>
pub async fn set_followed_client_id( &self, client_id: Id, is_followed: bool, ) -> Result<()>
pub async fn set_followed_hashtag( &self, hashtag: String, is_followed: bool, ) -> Result<()>
pub async fn get_content_thresholds(&self) -> Result<HashMap<u8, u32>>
pub async fn set_content_threshold( &self, feedback_type: u8, threshold: u32, ) -> Result<()>
pub async fn set_content_thresholds( &self, thresholds: HashMap<u8, u32>, ) -> Result<()>
pub async fn get_skip_warnings_for_followed(&self) -> Result<bool>
pub async fn set_skip_warnings_for_followed(&self, value: bool) -> Result<()>
Auto Trait Implementations§
impl Freeze for MetaPostManager
impl !RefUnwindSafe for MetaPostManager
impl Send for MetaPostManager
impl Sync for MetaPostManager
impl Unpin for MetaPostManager
impl UnsafeUnpin for MetaPostManager
impl !UnwindSafe for MetaPostManager
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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 more