Skip to main content

Groups

Struct Groups 

Source
pub struct Groups<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> Groups<'a>

Source

pub async fn query_info(&self, jid: &Jid) -> Result<Arc<GroupInfo>, GroupError>

Query the cached, send-oriented view of a group.

Returns the slim GroupInfo the encryption path needs: participant JIDs, the group’s addressing mode, the LID/PN mapping, and whether it is a community announcement group. A cached entry is returned as-is, so a repeated call is free. Only a cache miss goes to the network, and it sends the persisted participant phash, so an unchanged group costs a not-modified answer instead of a full metadata download.

This is the right call for routing and encrypting a message. For the user-facing fields (subject, description, admin roles, group settings) use Groups::get_metadata, and to control staleness explicitly use Groups::query_info_with_freshness.

Source

pub async fn query_info_with_freshness( &self, jid: &Jid, freshness: Freshness, ) -> Result<Arc<GroupInfo>, GroupError>

Query group metadata using the requested cache freshness policy.

A refresh leaves the current snapshot readable while the network request is in flight, then atomically replaces it after a successful response.

Source

pub async fn get_participating( &self, ) -> Result<HashMap<Jid, GroupMetadata>, GroupError>

Source

pub async fn get_metadata(&self, jid: &Jid) -> Result<GroupMetadata, GroupError>

Fetch the complete, user-facing metadata of a group.

Returns an owned GroupMetadata: subject, description, creator, per-participant admin roles, and ephemeral and membership settings. In a LID-addressed group, participant phone numbers the server left out are backfilled from known LID/PN mappings on a best-effort basis; a participant with no known mapping keeps phone_number: None. The query always hits the network (no phash is sent, so the server never answers not-modified) and the result does not populate the group cache.

This is the right call for displaying or auditing a group. When you only need the participant list to send a message, prefer the cached Groups::query_info.

Source

pub async fn create_group( &self, options: GroupCreateOptions, ) -> Result<CreateGroupResult, GroupError>

Source

pub async fn set_subject( &self, jid: impl Into<Jid>, subject: GroupSubject, ) -> Result<(), GroupError>

Source

pub async fn set_description( &self, jid: impl Into<Jid>, description: Option<GroupDescription>, prev: PreviousDescription<'_>, ) -> Result<(), GroupError>

Set or delete a group’s description.

Pass None as the description to delete it. prev names the description this update replaces; the server accepts the change only when that token matches the group’s current description, so a group that already has one cannot be updated without it. With PreviousDescription::Resolve the token is read from the server first, which costs one extra query but is always current; a caller holding fresh GroupMetadata::description_id can pass it directly instead.

Returns GroupError::DescriptionConflict when the group’s description changed between the read and this update.

Source

pub async fn leave(&self, jid: impl Into<Jid>) -> Result<(), GroupError>

Source

pub async fn add_participants( &self, jid: impl Into<Jid>, participants: &[Jid], ) -> Result<Vec<ParticipantChangeResponse>, GroupError>

Source

pub async fn remove_participants( &self, jid: impl Into<Jid>, participants: &[Jid], ) -> Result<Vec<ParticipantChangeResponse>, GroupError>

Source

pub async fn remove_participants_including_linked_groups( &self, jid: impl Into<Jid>, participants: &[Jid], ) -> Result<Vec<ParticipantChangeResponse>, GroupError>

Remove participants from a parent group and all of its linked groups.

Source

pub async fn promote_participants( &self, jid: impl Into<Jid>, participants: &[Jid], ) -> Result<Vec<ParticipantChangeResponse>, GroupError>

Source

pub async fn demote_participants( &self, jid: impl Into<Jid>, participants: &[Jid], ) -> Result<Vec<ParticipantChangeResponse>, GroupError>

Source

pub async fn set_locked( &self, jid: impl Into<Jid>, locked: bool, ) -> Result<(), GroupError>

Lock the group so only admins can change group info.

Source

pub async fn set_announce( &self, jid: impl Into<Jid>, announce: bool, ) -> Result<(), GroupError>

Set announcement mode. When enabled, only admins can send messages.

Source

pub async fn set_ephemeral( &self, jid: impl Into<Jid>, expiration: u32, ) -> Result<(), GroupError>

Set ephemeral (disappearing) messages timer on the group.

Common values: 86400 (24h), 604800 (7d), 7776000 (90d). Pass 0 to disable.

Source

pub async fn set_membership_approval( &self, jid: impl Into<Jid>, mode: MembershipApprovalMode, ) -> Result<(), GroupError>

Set membership approval mode. When on, new members must be approved by an admin.

Source

pub async fn join_with_invite_code( &self, code: &str, ) -> Result<JoinGroupResult, GroupError>

Join a group using an invite code.

Source

pub async fn join_with_invite_v4( &self, group_jid: impl Into<Jid>, code: &str, expiration: i64, admin_jid: impl Into<Jid>, ) -> Result<JoinGroupResult, GroupError>

Accept a V4 invite (received as a GroupInviteMessage, not a link).

Source

pub async fn get_invite_info( &self, code: &str, ) -> Result<GroupMetadata, GroupError>

Get group metadata from an invite code without joining.

Source

pub async fn get_membership_requests( &self, jid: impl Into<Jid>, ) -> Result<Vec<MembershipRequest>, GroupError>

Get pending membership approval requests.

Source

pub async fn approve_membership_requests( &self, jid: impl Into<Jid>, participants: &[Jid], ) -> Result<Vec<ParticipantChangeResponse>, GroupError>

Approve pending membership requests.

Source

pub async fn reject_membership_requests( &self, jid: impl Into<Jid>, participants: &[Jid], ) -> Result<Vec<ParticipantChangeResponse>, GroupError>

Reject pending membership requests.

Source

pub async fn set_member_add_mode( &self, jid: impl Into<Jid>, mode: MemberAddMode, ) -> Result<(), GroupError>

Set who can add members to the group.

Source

pub async fn set_no_frequently_forwarded( &self, jid: impl Into<Jid>, restrict: bool, ) -> Result<(), GroupError>

Restrict or allow frequently-forwarded messages in the group.

Source

pub async fn set_allow_admin_reports( &self, jid: impl Into<Jid>, allow: bool, ) -> Result<(), GroupError>

Enable or disable admin reports in the group.

Source

pub async fn set_group_history( &self, jid: impl Into<Jid>, enabled: bool, ) -> Result<(), GroupError>

Enable or disable group history sharing.

Set who can share invite links (via MEX).

Source

pub async fn set_member_share_history_mode( &self, jid: &Jid, mode: MemberShareHistoryMode, ) -> Result<(), GroupError>

Set who can share message history with new members (via MEX).

Source

pub async fn set_limit_sharing( &self, jid: &Jid, enabled: bool, ) -> Result<(), GroupError>

Enable or disable limit sharing in the group (via MEX).

Source

pub async fn cancel_membership_requests( &self, jid: impl Into<Jid>, participants: &[Jid], ) -> Result<Vec<ParticipantChangeResponse>, GroupError>

Cancel pending membership requests (from the requesting user’s side).

Source

pub async fn revoke_request_code( &self, jid: impl Into<Jid>, participants: &[Jid], ) -> Result<Vec<ParticipantChangeResponse>, GroupError>

Revoke invitation codes from specific participants (admin operation).

Source

pub async fn acknowledge(&self, jid: impl Into<Jid>) -> Result<(), GroupError>

Acknowledge a group notification.

Source

pub async fn batch_get_info( &self, jids: Vec<Jid>, ) -> Result<Vec<BatchGroupResult>, GroupError>

Batch query group info for multiple groups at once (max 10,000).

Source

pub async fn get_profile_pictures( &self, group_jids: Vec<Jid>, picture_type: PictureType, ) -> Result<Vec<GroupProfilePicture>, GroupError>

Batch fetch group profile pictures (max 1,000).

Source

pub async fn set_profile_picture( &self, group_jid: impl Into<Jid>, image_data: Vec<u8>, ) -> Result<SetProfilePictureResponse, GroupError>

Set a group’s profile picture (admin operation).

Sends a JPEG; the caller should size/crop it (WhatsApp uses 640x640). Passing empty image_data removes the picture, mirroring the own-picture API; prefer Groups::remove_profile_picture when removal is the intent.

§Wire Format
<iq type="set" xmlns="w:profile:picture" to="{group}@g.us">
  <picture type="image">{jpeg bytes}</picture>
</iq>
Source

pub async fn remove_profile_picture( &self, group_jid: impl Into<Jid>, ) -> Result<SetProfilePictureResponse, GroupError>

Remove a group’s profile picture (admin operation).

Source

pub async fn update_member_label( &self, group_jid: impl Into<Jid>, label: impl Into<String>, ) -> Result<(), GroupError>

Set or clear the bot’s per-group member label. Empty clears.

WA Web sends this as a ProtocolMessage over the normal message path, not as an IQ.

Source

pub async fn update_member_label_with_id( &self, group_jid: impl Into<Jid>, label: impl Into<String>, ) -> Result<String, GroupError>

Set or clear the member label and return the sent message ID.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Groups<'a>

§

impl<'a> !UnwindSafe for Groups<'a>

§

impl<'a> Freeze for Groups<'a>

§

impl<'a> Send for Groups<'a>

§

impl<'a> Sync for Groups<'a>

§

impl<'a> Unpin for Groups<'a>

§

impl<'a> UnsafeUnpin for Groups<'a>

Blanket Implementations§

Source§

impl<T> AggregateExpressionMethods for T

Source§

fn aggregate_distinct(self) -> Self::Output
where Self: DistinctDsl,

DISTINCT modifier for aggregate functions Read more
Source§

fn aggregate_all(self) -> Self::Output
where Self: AllDsl,

ALL modifier for aggregate functions Read more
Source§

fn aggregate_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add an aggregate function filter Read more
Source§

fn aggregate_order<O>(self, o: O) -> Self::Output
where Self: OrderAggregateDsl<O>,

Add an aggregate function order Read more
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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

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

Source§

fn into_sql<T>(self) -> Self::Expression

Convert self to an expression for Diesel’s query builder. Read more
Source§

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Spawnable for T
where T: Send + 'static,

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

impl<T> WindowExpressionMethods for T

Source§

fn over(self) -> Self::Output
where Self: OverDsl,

Turn a function call into a window function call Read more
Source§

fn window_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add a filter to the current window function Read more
Source§

fn partition_by<E>(self, expr: E) -> Self::Output
where Self: PartitionByDsl<E>,

Add a partition clause to the current window function Read more
Source§

fn window_order<E>(self, expr: E) -> Self::Output
where Self: OrderWindowDsl<E>,

Add a order clause to the current window function Read more
Source§

fn frame_by<E>(self, expr: E) -> Self::Output
where Self: FrameDsl<E>,

Add a frame clause to the current window function Read more