-
-
Notifications
You must be signed in to change notification settings - Fork 123
feat(wacore): bind five more enums to the catalog and retire a dead event #1310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
db1e262
561cea0
4e42562
b8e202a
c4cf44a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,6 +59,11 @@ pub struct Wanted { | |
| /// `(wire value, Rust identifier)`. `medianotify` is one word on the wire | ||
| /// and two in English, and nothing in the bundle says so. | ||
| pub renames: &'static [(&'static str, &'static str)], | ||
| /// The wire value that carries `#[wire_default]`, when the type has a | ||
| /// default that is not simply its first variant. Declared rather than | ||
| /// inferred because the catalog's variant order is not ours: reading the | ||
| /// default off position would silently change it the day upstream reorders. | ||
| pub default: Option<&'static str>, | ||
| pub doc: &'static str, | ||
| } | ||
|
|
||
|
|
@@ -69,6 +74,7 @@ pub const WANTED: &[Wanted] = &[ | |
| rust: "StanzaMessageType", | ||
| shape: Shape::Open, | ||
| renames: &[("medianotify", "MediaNotify")], | ||
| default: None, | ||
| doc: "The `type` attribute of an incoming `<message>` envelope.\n\ | ||
| ///\n\ | ||
| /// The official parser rejects a stanza whose `type` is absent or\n\ | ||
|
|
@@ -82,6 +88,7 @@ pub const WANTED: &[Wanted] = &[ | |
| rust: "PollType", | ||
| shape: Shape::Closed, | ||
| renames: &[], | ||
| default: None, | ||
| doc: "The `polltype` attribute of an incoming `<message><meta>` node.\n\ | ||
| ///\n\ | ||
| /// Closed on purpose: the attribute is `attrEnumOrNullIfUnknown`\n\ | ||
|
|
@@ -94,6 +101,7 @@ pub const WANTED: &[Wanted] = &[ | |
| rust: "EncMediaType", | ||
| shape: Shape::Open, | ||
| renames: &[("livelocation", "LiveLocation")], | ||
| default: None, | ||
| doc: "The `mediatype` attribute of an `<enc>` node.\n\ | ||
| ///\n\ | ||
| /// A hint about the payload the ciphertext carries, available\n\ | ||
|
|
@@ -106,8 +114,66 @@ pub const WANTED: &[Wanted] = &[ | |
| rust: "RECEIPT_MODE", | ||
| shape: Shape::Masks, | ||
| renames: &[], | ||
| default: None, | ||
| doc: "Bits of a receipt's `<meta mode>` bitmask.", | ||
| }, | ||
| Wanted { | ||
| module: "WAWebBackendJobs.flow", | ||
| name: "DecryptFailType", | ||
| rust: "DecryptFailMode", | ||
| shape: Shape::Closed, | ||
| renames: &[], | ||
| default: Some("show"), | ||
| doc: "The `decrypt-fail` attribute of an `<enc>` node.\n\ | ||
| ///\n\ | ||
| /// `Hide` is the server asking that a failure to decrypt this\n\ | ||
| /// stanza not be surfaced to the user.", | ||
| }, | ||
| Wanted { | ||
| module: "WAWebSchemaGroupMetadata", | ||
| name: "MemberAddMode", | ||
| rust: "MemberAddMode", | ||
| shape: Shape::Closed, | ||
| renames: &[], | ||
| default: None, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
With AGENTS.md reference: AGENTS.md:L36-L36 Useful? React with 👍 / 👎. |
||
| doc: "Who may add participants to a group.", | ||
| }, | ||
| Wanted { | ||
| module: "WAWebGroupHistoryShareMode", | ||
| name: "MemberShareGroupHistoryMode", | ||
| rust: "MemberShareHistoryMode", | ||
| shape: Shape::Closed, | ||
| renames: &[], | ||
| default: Some("admin_share"), | ||
| doc: "Who may share a group's history with a new participant.", | ||
| }, | ||
| Wanted { | ||
| module: "WAWebSetPrivacyJob", | ||
| name: "PrivacyUserAction", | ||
| rust: "DisallowedListAction", | ||
| shape: Shape::Closed, | ||
| renames: &[], | ||
| default: Some("add"), | ||
| doc: "Whether a privacy disallowed-list entry is being added or removed.", | ||
| }, | ||
| Wanted { | ||
| module: "WAWebGroupApiConst", | ||
| name: "GROUP_PARTICIPANT_TYPES", | ||
| rust: "GroupParticipantType", | ||
| shape: Shape::Closed, | ||
| renames: &[("superadmin", "SuperAdmin")], | ||
| default: Some("participant"), | ||
| doc: "A participant's role in a group.", | ||
| }, | ||
| Wanted { | ||
| module: "WAWebStatusSetupController", | ||
| name: "MediaType", | ||
| rust: "CallLinkMedia", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the status composer's AGENTS.md reference: AGENTS.md:L5-L5 Useful? React with 👍 / 👎.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, and this is the one binding in the sweep that was actually wrong. Reverted in b8e202a — I checked the catalog before reverting: The underlying mistake is worth naming, because my own PR body advertised it as a feature: matching on variant sets is how a candidate gets found, not how it gets decided. The module has to own the wire format we parse. The other five hold up under that test — That rule is now in the emitter's module doc rather than only here, since a comment on a rejected candidate is not where the next sweep will look. Generated by Claude Code |
||
| shape: Shape::Closed, | ||
| renames: &[], | ||
| default: None, | ||
| doc: "The media a call link carries.", | ||
| }, | ||
| ]; | ||
|
|
||
| pub fn generate(ir: &EnumsIr) -> Result<String> { | ||
|
|
@@ -201,9 +267,23 @@ fn wire_enum(wanted: &Wanted, def: &EnumDef) -> Result<String> { | |
| wanted.module, | ||
| wanted.name | ||
| ); | ||
| if wanted.default == Some(wire.as_str()) { | ||
| out.push_str(" #[wire_default]\n"); | ||
| } | ||
| out.push_str(&format!(" #[wire = {}]\n {ident},\n", rust_str(wire))); | ||
| } | ||
|
|
||
| if let Some(default) = wanted.default { | ||
| ensure!( | ||
| def.variants | ||
| .iter() | ||
| .any(|v| matches!(&v.value, Scalar::Str(s) if s == default)), | ||
| "{}::{} declares {default:?} as its default, which the catalog does not carry", | ||
| wanted.module, | ||
| wanted.name | ||
| ); | ||
| } | ||
|
|
||
| if wanted.shape == Shape::Open { | ||
| out.push_str( | ||
| " /// A value this build does not model, kept verbatim.\n #[wire_fallback]\n Unknown(String),\n", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -241,7 +241,11 @@ pub enum EventKind { | |
| IncomingCall, | ||
| MissedCall, | ||
| CallEndedElsewhere, | ||
| PushNameUpdate, | ||
| /// Retired: the payload promised an old-name/new-name comparison this | ||
| /// client has no contact store to make, and nothing ever dispatched it. | ||
| /// The slot stays because the discriminant is an `EventInterest` bit index | ||
| /// a consumer persists, so removing it would re-point every mask past it. | ||
| RetiredPushNameUpdate, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Renaming this kind and removing AGENTS.md reference: AGENTS.md:L35-L35 Useful? React with 👍 / 👎.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The compile break was real and mine: I checked On retaining the names, I'm keeping the removal, deliberately. The crate is pre-1.0 and the repo owner has confirmed breaking changes are acceptable there when the PR carries a migration line, which the body now does. The reason a deprecated shim is worse than removal here: The frozen-payload contract in What is genuinely frozen is the Generated by Claude Code |
||
| SelfPushNameUpdated, | ||
| PinUpdate, | ||
| MuteUpdate, | ||
|
|
@@ -921,7 +925,6 @@ pub enum Event { | |
| /// Rejected call-log outcomes (`<terminate reason="accepted_elsewhere"|"rejected_elsewhere">`). | ||
|
greptile-apps[bot] marked this conversation as resolved.
greptile-apps[bot] marked this conversation as resolved.
|
||
| CallEndedElsewhere(CallEndedElsewhere), | ||
|
|
||
| PushNameUpdate(PushNameUpdate), | ||
| SelfPushNameUpdated(SelfPushNameUpdated), | ||
|
jlucaso1 marked this conversation as resolved.
|
||
| PinUpdate(PinUpdate), | ||
| MuteUpdate(MuteUpdate), | ||
|
|
@@ -1119,7 +1122,6 @@ impl Event { | |
| Event::IncomingCall(_) => EventKind::IncomingCall, | ||
| Event::MissedCall(_) => EventKind::MissedCall, | ||
| Event::CallEndedElsewhere(_) => EventKind::CallEndedElsewhere, | ||
| Event::PushNameUpdate(_) => EventKind::PushNameUpdate, | ||
| Event::SelfPushNameUpdated(_) => EventKind::SelfPushNameUpdated, | ||
| Event::AppStateSyncFailed(_) => EventKind::AppStateSyncFailed, | ||
| Event::PinUpdate(_) => EventKind::PinUpdate, | ||
|
|
@@ -1668,13 +1670,7 @@ pub struct DirtyState { | |
| pub timestamp: Option<u64>, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Copy, PartialEq, Eq, crate::WireEnum)] | ||
| pub enum DecryptFailMode { | ||
| #[wire = "show"] | ||
| Show, | ||
| #[wire = "hide"] | ||
| Hide, | ||
| } | ||
| pub use crate::types::wire_enums::DecryptFailMode; | ||
|
|
||
| #[derive(Debug, Clone, Copy, PartialEq, Eq, crate::WireEnum)] | ||
| pub enum UnavailableType { | ||
|
|
@@ -2207,16 +2203,6 @@ pub struct ContactUpdate { | |
| pub from_full_sync: bool, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Serialize, bon::Builder)] | ||
| #[non_exhaustive] | ||
| pub struct PushNameUpdate { | ||
| /// The contact who changed their push name. | ||
| pub jid: Jid, | ||
| pub message: Box<MessageInfo>, | ||
| pub old_push_name: String, | ||
| pub new_push_name: String, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Serialize, bon::Builder)] | ||
| #[non_exhaustive] | ||
| pub struct PinUpdate { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,7 @@ | ||
| use chrono::{DateTime, Utc}; | ||
| use waproto::whatsapp as wa; | ||
|
|
||
| #[derive(Debug, Clone)] | ||
| pub struct VerifiedName { | ||
| pub certificate: Box<wa::VerifiedNameCertificate>, | ||
| pub details: Box<wa::verified_name_certificate::Details>, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Default)] | ||
| pub struct LocalChatSettings { | ||
| pub found: bool, | ||
| pub muted_until: Option<DateTime<Utc>>, | ||
| pub pinned: bool, | ||
| pub archived: bool, | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.