Skip to main content

MetaPostManager

Struct MetaPostManager 

Source
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_publicMetaPostPublicV1
  • {client_id}.meta_post_v1_privateMetaPostPrivateV1

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:

  1. Explicit publish — the user saves their bio in the UI, which calls build_meta_post_json() followed by submit_post() on the client. This bundles the latest config (including any pending follow/threshold changes) into the post.
  2. Auto-publish on startupshould_auto_publish() checks whether the current month’s User bucket already contains a MetaPostV1 from 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

Source

pub fn new( runtime_services: Arc<RuntimeServices>, client_storage: Arc<dyn ClientStorage>, key_locker: Arc<dyn KeyLocker>, client_id: ClientId, ) -> Self

Source

pub async fn get_public(&self) -> Result<MetaPostPublicV1>

Source

pub async fn get_private(&self) -> Result<MetaPostPrivateV1>

Source

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.

Source

pub async fn get_meta_post_public( &self, id: Id, ) -> Result<Option<MetaPostPublicV1>>

Source

pub async fn get_all_meta_post_publics( &self, ) -> Result<Vec<(String, MetaPostPublicV1)>>

Source

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.

Source

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.

Source

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.

Source

pub async fn get_followed_client_ids(&self) -> Result<Vec<Id>>

Source

pub async fn set_followed_client_ids(&self, client_ids: Vec<Id>) -> Result<()>

Source

pub async fn set_followed_client_id( &self, client_id: Id, is_followed: bool, ) -> Result<()>

Source

pub async fn get_followed_hashtags(&self) -> Result<Vec<String>>

Source

pub async fn set_followed_hashtags(&self, hashtags: Vec<String>) -> Result<()>

Source

pub async fn set_followed_hashtag( &self, hashtag: String, is_followed: bool, ) -> Result<()>

Source

pub async fn get_content_thresholds(&self) -> Result<HashMap<u8, u32>>

Source

pub async fn set_content_threshold( &self, feedback_type: u8, threshold: u32, ) -> Result<()>

Source

pub async fn set_content_thresholds( &self, thresholds: HashMap<u8, u32>, ) -> Result<()>

Source

pub async fn get_skip_warnings_for_followed(&self) -> Result<bool>

Source

pub async fn set_skip_warnings_for_followed(&self, value: bool) -> Result<()>

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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> 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: 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: 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
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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