Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/features/chatstate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use wacore_binary::jid::Jid;

/// Chat state type for typing indicators.
#[derive(Debug, Clone, Copy, PartialEq, Eq, StringEnum)]
#[non_exhaustive]
pub enum ChatStateType {
#[str = "composing"]
Composing,
Expand Down
11 changes: 6 additions & 5 deletions src/features/community.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use wacore_binary::jid::Jid;

/// Classification of a group within the community hierarchy.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub enum GroupType {
/// Regular standalone group (not part of a community).
Default,
Expand All @@ -34,7 +35,7 @@ pub enum GroupType {
}

/// Options for creating a new community.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CreateCommunityOptions {
pub name: String,
pub description: Option<String>,
Expand All @@ -59,14 +60,14 @@ impl CreateCommunityOptions {
}

/// Result of creating a community.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CreateCommunityResult {
/// JID of the created community parent group.
pub gid: Jid,
}

/// A subgroup within a community.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CommunitySubgroup {
pub id: Jid,
pub subject: String,
Expand All @@ -76,14 +77,14 @@ pub struct CommunitySubgroup {
}

/// Result of linking subgroups to a community.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LinkSubgroupsResult {
pub linked_jids: Vec<Jid>,
pub failed_groups: Vec<(Jid, u32)>,
}

/// Result of unlinking subgroups from a community.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct UnlinkSubgroupsResult {
pub unlinked_jids: Vec<Jid>,
pub failed_groups: Vec<(Jid, u32)>,
Expand Down
6 changes: 3 additions & 3 deletions src/features/groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub use wacore::iq::groups::{
ParticipantChangeResponse,
};

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct GroupMetadata {
pub id: Jid,
pub subject: String,
Expand Down Expand Up @@ -62,7 +62,7 @@ pub struct GroupMetadata {
pub allow_non_admin_sub_group_creation: bool,
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct GroupParticipant {
pub jid: Jid,
pub phone_number: Option<Jid>,
Expand Down Expand Up @@ -108,7 +108,7 @@ impl From<GroupInfoResponse> for GroupMetadata {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CreateGroupResult {
pub gid: Jid,
}
Expand Down
12 changes: 8 additions & 4 deletions src/features/newsletter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use waproto::whatsapp as wa;
// Types

#[derive(Debug, Clone, PartialEq, Eq, StringEnum)]
#[non_exhaustive]
pub enum NewsletterMessageType {
#[str = "text"]
Text,
Expand All @@ -40,22 +41,25 @@ pub enum NewsletterMessageType {
}

/// Newsletter verification status.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum NewsletterVerification {
Verified,
Unverified,
}

/// Newsletter state.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum NewsletterState {
Active,
Suspended,
Geosuspended,
}

/// The viewer's role in a newsletter.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum NewsletterRole {
Owner,
Admin,
Expand All @@ -64,7 +68,7 @@ pub enum NewsletterRole {
}

/// Metadata for a newsletter (channel).
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct NewsletterMetadata {
pub jid: Jid,
pub name: String,
Expand Down
1 change: 1 addition & 0 deletions src/features/presence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub enum PresenceError {

/// Presence status for online/offline state.
#[derive(Debug, Clone, Copy, PartialEq, Eq, StringEnum)]
#[non_exhaustive]
pub enum PresenceStatus {
#[str = "available"]
Available,
Expand Down
15 changes: 8 additions & 7 deletions src/features/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::upload::UploadResponse;
/// Privacy setting sent in the `<meta>` node of the status stanza.
/// Matches WhatsApp Web's `status_setting` attribute.
#[derive(Debug, Clone, Copy, PartialEq, Eq, StringEnum)]
#[non_exhaustive]
pub enum StatusPrivacySetting {
/// Send to all contacts in address book.
#[string_default]
Expand Down Expand Up @@ -48,7 +49,7 @@ impl<'a> Status<'a> {
text: &str,
background_argb: u32,
font: i32,
recipients: Vec<Jid>,
recipients: &[Jid],
options: StatusSendOptions,
) -> Result<SendResult, anyhow::Error> {
let message = wa::Message {
Expand All @@ -75,7 +76,7 @@ impl<'a> Status<'a> {
upload: &UploadResponse,
thumbnail: Vec<u8>,
caption: Option<&str>,
recipients: Vec<Jid>,
recipients: &[Jid],
options: StatusSendOptions,
) -> Result<SendResult, anyhow::Error> {
let message = wa::Message {
Expand Down Expand Up @@ -109,7 +110,7 @@ impl<'a> Status<'a> {
thumbnail: Vec<u8>,
duration_seconds: u32,
caption: Option<&str>,
recipients: Vec<Jid>,
recipients: &[Jid],
options: StatusSendOptions,
) -> Result<SendResult, anyhow::Error> {
let message = wa::Message {
Expand Down Expand Up @@ -140,7 +141,7 @@ impl<'a> Status<'a> {
pub async fn send_raw(
&self,
message: wa::Message,
recipients: Vec<Jid>,
recipients: &[Jid],
options: StatusSendOptions,
) -> Result<SendResult, anyhow::Error> {
self.client
Expand All @@ -155,7 +156,7 @@ impl<'a> Status<'a> {
pub async fn revoke(
&self,
message_id: impl Into<String>,
recipients: Vec<Jid>,
recipients: &[Jid],
options: StatusSendOptions,
) -> Result<SendResult, anyhow::Error> {
let message_id = message_id.into();
Expand Down Expand Up @@ -187,10 +188,10 @@ impl Client {
/// # Example
/// ```no_run
/// # async fn example(client: &whatsapp_rust::Client) -> anyhow::Result<()> {
/// let recipients = vec![whatsapp_rust::Jid::pn("15551234567")];
/// let recipients = [whatsapp_rust::Jid::pn("15551234567")];
/// let id = client
/// .status()
/// .send_text("Hello!", 0xFF1E6E4F, 0, recipients, Default::default())
/// .send_text("Hello!", 0xFF1E6E4F, 0, &recipients, Default::default())
/// .await?;
/// # Ok(())
/// # }
Expand Down
8 changes: 5 additions & 3 deletions src/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct SendOptions {
}

/// Result of a successfully sent message.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SendResult {
pub message_id: String,
pub to: Jid,
Expand All @@ -49,6 +49,7 @@ impl SendResult {

/// Duration for pinned messages. Default is 7 days (matches WA Web).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[non_exhaustive]
pub enum PinDuration {
Hours24,
#[default]
Expand All @@ -68,6 +69,7 @@ impl PinDuration {

/// Specifies who is revoking (deleting) the message.
#[derive(Debug, Clone, PartialEq, Eq, Default)]
#[non_exhaustive]
pub enum RevokeType {
/// The message sender deleting their own message.
#[default]
Expand Down Expand Up @@ -275,7 +277,7 @@ impl Client {
pub(crate) async fn send_status_message(
&self,
message: wa::Message,
recipients: Vec<Jid>,
recipients: &[Jid],
options: crate::features::status::StatusSendOptions,
) -> Result<SendResult, anyhow::Error> {
use wacore::client::context::GroupInfo;
Expand Down Expand Up @@ -326,7 +328,7 @@ impl Client {
));
}
} else {
resolved_recipients.push(jid);
resolved_recipients.push(jid.clone());
}
}

Expand Down
Loading