Skip to content

feat: Implement Mex (Meta Experiment) and Newsletter functionality from Baileys v7.0.0-rc.9#60

Open
alltomatos wants to merge 2 commits intocanove:mainfrom
alltomatos:feature/mex-newsletter
Open

feat: Implement Mex (Meta Experiment) and Newsletter functionality from Baileys v7.0.0-rc.9#60
alltomatos wants to merge 2 commits intocanove:mainfrom
alltomatos:feature/mex-newsletter

Conversation

@alltomatos
Copy link
Copy Markdown

@alltomatos alltomatos commented Nov 29, 2025

Mex (Meta Experiment) and Newsletter Implementation

This PR adds complete support for the Mex protocol and Newsletter functionalities, ported from Baileys v7.0.0-rc.9.

📋 Changes

New Files

  • src/Types/Newsletter.ts: Complete Newsletter types, including QueryIds and XWAPaths for GraphQL queries
  • src/Socket/mex.ts: Mex protocol implementation with executeWMexQuery function for GraphQL queries
  • src/Socket/newsletter.ts: Extended socket with all Newsletter operations

Modified Files

  • src/Types/index.ts: Newsletter types export
  • src/Socket/index.ts: Changed to use makeNewsletterSocket as main socket

✨ Features

The Newsletter socket now provides:

Newsletter Management

  • newsletterCreate: Create newsletter
  • newsletterUpdate: Update metadata
  • newsletterDelete: Delete newsletter
  • newsletterMetadata: Get metadata by invite or JID

Interactions

  • newsletterFollow / newsletterUnfollow: Follow/unfollow newsletters
  • newsletterMute / newsletterUnmute: Mute/unmute notifications
  • newsletterReactMessage: React to messages
  • newsletterFetchMessages: Fetch messages
  • subscribeNewsletterUpdates: Subscribe to live updates

Administrative Operations

  • newsletterUpdateName / newsletterUpdateDescription / newsletterUpdatePicture: Update information
  • newsletterRemovePicture: Remove picture
  • newsletterAdminCount: Count administrators
  • newsletterChangeOwner: Change owner
  • newsletterDemote: Remove admin privileges
  • newsletterSubscribers: Get subscriber count

🔧 Technical Details

Socket Chain

Newsletter → Business → Groups → Chats → Messages → Base

Implemented Fixes

  • Proper type assertions in parseNewsletterMetadata for TypeScript strict mode compatibility
  • Error handling with Boom for GraphQL responses
  • Robust data path parsing in Mex responses

✅ Verification

  • TypeScript compilation without errors
  • Code ported directly from Baileys v7.0.0-rc.9
  • Maintains compatibility with existing sockets
  • All Newsletter operations implemented

📚 Usage Example

import { makeNewsletterSocket } from 'whaileys';

const sock = makeNewsletterSocket(config);

// Create newsletter
const newsletter = await sock.newsletterCreate('My Newsletter', 'Description');

// Follow newsletter
await sock.newsletterFollow(newsletter.id);

// Fetch messages
const messages = await sock.newsletterFetchMessages(newsletter.id, 10, 0, 0);

// React to message
await sock.newsletterReactMessage(newsletter.id, serverId, '👍');

🔗 References

📊 Statistics

  • Files changed: 5
  • Lines added: 368
  • Lines removed: 1

This implementation brings complete parity with Baileys for Newsletter functionalities, allowing Whaileys-based applications to use all WhatsApp channels/newsletters features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant