Skip to main content

MembersV1

Struct MembersV1 

Source
pub struct MembersV1 {
    pub members: Vec<AuthorizedMember>,
}

Fields§

§members: Vec<AuthorizedMember>

Implementations§

Source§

impl MembersV1

Source

pub fn is_inviter_of( &self, member_id: MemberId, target_id: MemberId, params: &ChatRoomParametersV1, ) -> bool

Returns true if the given member_id invited the target_id, properly handling both regular members and the room owner. Use this instead of checking the members list directly.

Source

pub fn members_by_member_id(&self) -> HashMap<MemberId, &AuthorizedMember>

Note: doesn’t include owner

Source

pub fn has_banned_members( &self, bans_v1: &BansV1, parameters: &ChatRoomParametersV1, ) -> bool

Checks if there are any banned members or members downstream of banned members in the invite chain

Source

pub fn banned_member_ids( &self, bans_v1: &BansV1, member_info: &MemberInfoV1, parameters: &ChatRoomParametersV1, ) -> HashSet<MemberId>

The set of member ids that must be removed because they are the target of (or downstream of the target of) a currently-authorized ban.

This is the deputy-aware member cascade (#410). It is a pure function of the converged (members + member_info deputies + bans) state, so every peer computes the same removal set regardless of the order deltas arrived in — which is why enforcement lives here / in ChatRoomStateV1::post_apply_cleanup, NOT in verify (flipping ban validity inside verify would make it non-stable across deputy-state changes and break convergence). Bans themselves are never pruned by this (they remain an add-only CRDT tombstone set); revoking a deputy simply makes their bans stop being authorized, so the previously-removed members are no longer in this set and can rejoin.

Source

pub fn is_ban_authorized( banner: MemberId, target: MemberId, members_by_id: &HashMap<MemberId, &AuthorizedMember>, member_info: &MemberInfoV1, owner_id: MemberId, ) -> bool

Whether banner is currently authorized to ban target (#410).

Grants are checked in priority order. The ABSOLUTE grants come FIRST so they cannot be stripped by the target “self-immunizing” (a spammer listing the moderator in their OWN deputies to make the mod’s ban go inert):

  1. banner is the room owner — absolute.
  2. banner is a STRICT ancestor of target in the invite tree (“you can ban your own subtree”) — absolute.
  3. banner is an owner-appointed global moderator (owner’s deputies list banner) — absolute (the owner’s subtree is everyone).

Only then the deputy-derived branch (authority via a NON-owner ancestor), which the guardrail applies to: 4. Guardrail (“cannot ban the member who deputized you”): if target currently lists banner in target.deputies, DENY — a deputy cannot ban a fellow deputizer. Checked AFTER the absolute grants, so a genuine ancestor / owner-appointed mod keeps authority even if the target deputizes them. 5. Some strict NON-owner ancestor A of target lists banner in A.deputies — deputy authority scoped to A’s subtree.

There is no transitive re-deputization: a deputy’s own deputies only grant authority over the deputy’s OWN subtree (where the deputy is a genuine ancestor), never over a subtree they merely hold as a deputy.

Source

pub fn get_invite_chain( &self, member: &AuthorizedMember, parameters: &ChatRoomParametersV1, ) -> Result<Vec<AuthorizedMember>, String>

Get the full invite chain with Ed25519 signature verification at each link. This is the authoritative verification used by verify().

Trait Implementations§

Source§

impl Clone for MembersV1

Source§

fn clone(&self) -> MembersV1

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ComposableState for MembersV1

Source§

type ParentState = ChatRoomStateV1

Source§

type Summary = BTreeSet<MemberId>

Source§

type Delta = MembersDelta

Source§

type Parameters = ChatRoomParametersV1

Source§

fn verify( &self, parent_state: &Self::ParentState, parameters: &Self::Parameters, ) -> Result<(), String>

Source§

fn summarize( &self, _parent_state: &Self::ParentState, _parameters: &Self::Parameters, ) -> Self::Summary

Source§

fn delta( &self, _parent_state: &Self::ParentState, _parameters: &Self::Parameters, old_state_summary: &Self::Summary, ) -> Option<Self::Delta>

Source§

fn apply_delta( &mut self, parent_state: &Self::ParentState, parameters: &Self::Parameters, delta: &Option<Self::Delta>, ) -> Result<(), String>

Applies the specified delta to the current state. Read more
Source§

fn merge( &mut self, parent_state: &Self::ParentState, parameters: &Self::Parameters, other_state: &Self, ) -> Result<(), String>

Merges the current state with another state.
Source§

impl Debug for MembersV1

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MembersV1

Source§

fn default() -> MembersV1

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for MembersV1

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for MembersV1

Source§

impl PartialEq for MembersV1

Source§

fn eq(&self, other: &MembersV1) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for MembersV1

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for MembersV1

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.