pub struct Groups<'a> { /* private fields */ }Implementations§
Source§impl<'a> Groups<'a>
impl<'a> Groups<'a>
Sourcepub async fn query_info(&self, jid: &Jid) -> Result<Arc<GroupInfo>, GroupError>
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.
Sourcepub async fn query_info_with_freshness(
&self,
jid: &Jid,
freshness: Freshness,
) -> Result<Arc<GroupInfo>, GroupError>
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.
pub async fn get_participating( &self, ) -> Result<HashMap<Jid, GroupMetadata>, GroupError>
Sourcepub async fn get_metadata(&self, jid: &Jid) -> Result<GroupMetadata, GroupError>
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.
pub async fn create_group( &self, options: GroupCreateOptions, ) -> Result<CreateGroupResult, GroupError>
pub async fn set_subject( &self, jid: impl Into<Jid>, subject: GroupSubject, ) -> Result<(), GroupError>
Sourcepub async fn set_description(
&self,
jid: impl Into<Jid>,
description: Option<GroupDescription>,
prev: PreviousDescription<'_>,
) -> Result<(), GroupError>
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.
pub async fn leave(&self, jid: impl Into<Jid>) -> Result<(), GroupError>
pub async fn add_participants( &self, jid: impl Into<Jid>, participants: &[Jid], ) -> Result<Vec<ParticipantChangeResponse>, GroupError>
pub async fn remove_participants( &self, jid: impl Into<Jid>, participants: &[Jid], ) -> Result<Vec<ParticipantChangeResponse>, GroupError>
Sourcepub async fn remove_participants_including_linked_groups(
&self,
jid: impl Into<Jid>,
participants: &[Jid],
) -> Result<Vec<ParticipantChangeResponse>, GroupError>
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.
pub async fn promote_participants( &self, jid: impl Into<Jid>, participants: &[Jid], ) -> Result<Vec<ParticipantChangeResponse>, GroupError>
pub async fn demote_participants( &self, jid: impl Into<Jid>, participants: &[Jid], ) -> Result<Vec<ParticipantChangeResponse>, GroupError>
pub async fn get_invite_link( &self, jid: impl Into<Jid>, reset: bool, ) -> Result<String, GroupError>
Sourcepub async fn set_locked(
&self,
jid: impl Into<Jid>,
locked: bool,
) -> Result<(), GroupError>
pub async fn set_locked( &self, jid: impl Into<Jid>, locked: bool, ) -> Result<(), GroupError>
Lock the group so only admins can change group info.
Sourcepub async fn set_announce(
&self,
jid: impl Into<Jid>,
announce: bool,
) -> Result<(), GroupError>
pub async fn set_announce( &self, jid: impl Into<Jid>, announce: bool, ) -> Result<(), GroupError>
Set announcement mode. When enabled, only admins can send messages.
Sourcepub async fn set_ephemeral(
&self,
jid: impl Into<Jid>,
expiration: u32,
) -> Result<(), GroupError>
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.
Sourcepub async fn set_membership_approval(
&self,
jid: impl Into<Jid>,
mode: MembershipApprovalMode,
) -> Result<(), GroupError>
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.
Sourcepub async fn join_with_invite_code(
&self,
code: &str,
) -> Result<JoinGroupResult, GroupError>
pub async fn join_with_invite_code( &self, code: &str, ) -> Result<JoinGroupResult, GroupError>
Join a group using an invite code.
Sourcepub async fn join_with_invite_v4(
&self,
group_jid: impl Into<Jid>,
code: &str,
expiration: i64,
admin_jid: impl Into<Jid>,
) -> Result<JoinGroupResult, GroupError>
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).
Sourcepub async fn get_invite_info(
&self,
code: &str,
) -> Result<GroupMetadata, GroupError>
pub async fn get_invite_info( &self, code: &str, ) -> Result<GroupMetadata, GroupError>
Get group metadata from an invite code without joining.
Sourcepub async fn get_membership_requests(
&self,
jid: impl Into<Jid>,
) -> Result<Vec<MembershipRequest>, GroupError>
pub async fn get_membership_requests( &self, jid: impl Into<Jid>, ) -> Result<Vec<MembershipRequest>, GroupError>
Get pending membership approval requests.
Sourcepub async fn approve_membership_requests(
&self,
jid: impl Into<Jid>,
participants: &[Jid],
) -> Result<Vec<ParticipantChangeResponse>, GroupError>
pub async fn approve_membership_requests( &self, jid: impl Into<Jid>, participants: &[Jid], ) -> Result<Vec<ParticipantChangeResponse>, GroupError>
Approve pending membership requests.
Sourcepub async fn reject_membership_requests(
&self,
jid: impl Into<Jid>,
participants: &[Jid],
) -> Result<Vec<ParticipantChangeResponse>, GroupError>
pub async fn reject_membership_requests( &self, jid: impl Into<Jid>, participants: &[Jid], ) -> Result<Vec<ParticipantChangeResponse>, GroupError>
Reject pending membership requests.
Sourcepub async fn set_member_add_mode(
&self,
jid: impl Into<Jid>,
mode: MemberAddMode,
) -> Result<(), GroupError>
pub async fn set_member_add_mode( &self, jid: impl Into<Jid>, mode: MemberAddMode, ) -> Result<(), GroupError>
Set who can add members to the group.
Sourcepub async fn set_no_frequently_forwarded(
&self,
jid: impl Into<Jid>,
restrict: bool,
) -> Result<(), GroupError>
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.
Sourcepub async fn set_allow_admin_reports(
&self,
jid: impl Into<Jid>,
allow: bool,
) -> Result<(), GroupError>
pub async fn set_allow_admin_reports( &self, jid: impl Into<Jid>, allow: bool, ) -> Result<(), GroupError>
Enable or disable admin reports in the group.
Sourcepub async fn set_group_history(
&self,
jid: impl Into<Jid>,
enabled: bool,
) -> Result<(), GroupError>
pub async fn set_group_history( &self, jid: impl Into<Jid>, enabled: bool, ) -> Result<(), GroupError>
Enable or disable group history sharing.
Sourcepub async fn set_member_link_mode(
&self,
jid: &Jid,
mode: MemberLinkMode,
) -> Result<(), GroupError>
pub async fn set_member_link_mode( &self, jid: &Jid, mode: MemberLinkMode, ) -> Result<(), GroupError>
Set who can share invite links (via MEX).
Set who can share message history with new members (via MEX).
Sourcepub async fn set_limit_sharing(
&self,
jid: &Jid,
enabled: bool,
) -> Result<(), GroupError>
pub async fn set_limit_sharing( &self, jid: &Jid, enabled: bool, ) -> Result<(), GroupError>
Enable or disable limit sharing in the group (via MEX).
Sourcepub async fn cancel_membership_requests(
&self,
jid: impl Into<Jid>,
participants: &[Jid],
) -> Result<Vec<ParticipantChangeResponse>, GroupError>
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).
Sourcepub async fn revoke_request_code(
&self,
jid: impl Into<Jid>,
participants: &[Jid],
) -> Result<Vec<ParticipantChangeResponse>, GroupError>
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).
Sourcepub async fn acknowledge(&self, jid: impl Into<Jid>) -> Result<(), GroupError>
pub async fn acknowledge(&self, jid: impl Into<Jid>) -> Result<(), GroupError>
Acknowledge a group notification.
Sourcepub async fn batch_get_info(
&self,
jids: Vec<Jid>,
) -> Result<Vec<BatchGroupResult>, GroupError>
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).
Sourcepub async fn get_profile_pictures(
&self,
group_jids: Vec<Jid>,
picture_type: PictureType,
) -> Result<Vec<GroupProfilePicture>, GroupError>
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).
Sourcepub async fn set_profile_picture(
&self,
group_jid: impl Into<Jid>,
image_data: Vec<u8>,
) -> Result<SetProfilePictureResponse, GroupError>
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>Sourcepub async fn remove_profile_picture(
&self,
group_jid: impl Into<Jid>,
) -> Result<SetProfilePictureResponse, GroupError>
pub async fn remove_profile_picture( &self, group_jid: impl Into<Jid>, ) -> Result<SetProfilePictureResponse, GroupError>
Remove a group’s profile picture (admin operation).
Sourcepub async fn update_member_label(
&self,
group_jid: impl Into<Jid>,
label: impl Into<String>,
) -> Result<(), GroupError>
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.
Sourcepub async fn update_member_label_with_id(
&self,
group_jid: impl Into<Jid>,
label: impl Into<String>,
) -> Result<String, GroupError>
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
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read more