mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
[READY FOR MERGE] Implement newsletter (#1532)
* feat: implement basic newsletter functionality with socket integration and event handling * feat: enhance media handling for newsletters with raw media upload support * feat: working updatePicture, removePicure, adminCount, mute, Unmute * fix: fetchMessages * chore: cleanup * fix: update newsletter metadata path and query ID for consistency. newsletterMetadata works now * chore: enhance newsletter metadata parsing and error handling * fix: correct DELETE QueryId value in Newsletter.ts * chore: split mex stuffs to own file * chore: remove as any
This commit is contained in:
committed by
GitHub
parent
5ffb19120d
commit
8391c02e0b
@@ -71,6 +71,16 @@ export type BaileysEventMap = {
|
||||
call: WACallEvent[]
|
||||
'labels.edit': Label
|
||||
'labels.association': { association: LabelAssociation; type: 'add' | 'remove' }
|
||||
|
||||
/** Newsletter-related events */
|
||||
'newsletter.reaction': {
|
||||
id: string
|
||||
server_id: string
|
||||
reaction: { code?: string; count?: number; removed?: boolean }
|
||||
}
|
||||
'newsletter.view': { id: string; server_id: string; count: number }
|
||||
'newsletter-participants.update': { id: string; author: string; user: string; new_role: string; action: string }
|
||||
'newsletter-settings.update': { id: string; update: any }
|
||||
}
|
||||
|
||||
export type BufferedEventData = {
|
||||
|
||||
@@ -15,6 +15,7 @@ export type WAContactMessage = proto.Message.IContactMessage
|
||||
export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage
|
||||
export type WAMessageKey = proto.IMessageKey & {
|
||||
senderLid?: string
|
||||
server_id?: string
|
||||
senderPn?: string
|
||||
participantLid?: string
|
||||
participantPn?: string
|
||||
@@ -292,6 +293,7 @@ export type MediaGenerationOptions = {
|
||||
export type MessageContentGenerationOptions = MediaGenerationOptions & {
|
||||
getUrlInfo?: (text: string) => Promise<WAUrlInfo | undefined>
|
||||
getProfilePicUrl?: (jid: string, type: 'image' | 'preview') => Promise<string | undefined>
|
||||
jid?: string
|
||||
}
|
||||
export type MessageGenerationOptions = MessageContentGenerationOptions & MessageGenerationOptionsFromContent
|
||||
|
||||
|
||||
98
src/Types/Newsletter.ts
Normal file
98
src/Types/Newsletter.ts
Normal file
@@ -0,0 +1,98 @@
|
||||
export enum XWAPaths {
|
||||
xwa2_newsletter_create = 'xwa2_newsletter_create',
|
||||
xwa2_newsletter_subscribers = 'xwa2_newsletter_subscribers',
|
||||
xwa2_newsletter_view = 'xwa2_newsletter_view',
|
||||
xwa2_newsletter_metadata = 'xwa2_newsletter',
|
||||
xwa2_newsletter_admin_count = 'xwa2_newsletter_admin',
|
||||
xwa2_newsletter_mute_v2 = 'xwa2_newsletter_mute_v2',
|
||||
xwa2_newsletter_unmute_v2 = 'xwa2_newsletter_unmute_v2',
|
||||
xwa2_newsletter_follow = 'xwa2_newsletter_follow',
|
||||
xwa2_newsletter_unfollow = 'xwa2_newsletter_unfollow',
|
||||
xwa2_newsletter_change_owner = 'xwa2_newsletter_change_owner',
|
||||
xwa2_newsletter_demote = 'xwa2_newsletter_demote',
|
||||
xwa2_newsletter_delete_v2 = 'xwa2_newsletter_delete_v2'
|
||||
}
|
||||
export enum QueryIds {
|
||||
CREATE = '8823471724422422',
|
||||
UPDATE_METADATA = '24250201037901610',
|
||||
METADATA = '6563316087068696',
|
||||
SUBSCRIBERS = '9783111038412085',
|
||||
FOLLOW = '7871414976211147',
|
||||
UNFOLLOW = '7238632346214362',
|
||||
MUTE = '29766401636284406',
|
||||
UNMUTE = '9864994326891137',
|
||||
ADMIN_COUNT = '7130823597031706',
|
||||
CHANGE_OWNER = '7341777602580933',
|
||||
DEMOTE = '6551828931592903',
|
||||
DELETE = '30062808666639665'
|
||||
}
|
||||
export type NewsletterUpdate = {
|
||||
name?: string
|
||||
description?: string
|
||||
picture?: string
|
||||
}
|
||||
export interface NewsletterCreateResponse {
|
||||
id: string
|
||||
state: { type: string }
|
||||
thread_metadata: {
|
||||
creation_time: string
|
||||
description: { id: string; text: string; update_time: string }
|
||||
handle: string | null
|
||||
invite: string
|
||||
name: { id: string; text: string; update_time: string }
|
||||
picture: { direct_path: string; id: string; type: string }
|
||||
preview: { direct_path: string; id: string; type: string }
|
||||
subscribers_count: string
|
||||
verification: 'VERIFIED' | 'UNVERIFIED'
|
||||
}
|
||||
viewer_metadata: {
|
||||
mute: 'ON' | 'OFF'
|
||||
role: NewsletterViewRole
|
||||
}
|
||||
}
|
||||
export interface NewsletterCreateResponse {
|
||||
id: string
|
||||
state: { type: string }
|
||||
thread_metadata: {
|
||||
creation_time: string
|
||||
description: { id: string; text: string; update_time: string }
|
||||
handle: string | null
|
||||
invite: string
|
||||
name: { id: string; text: string; update_time: string }
|
||||
picture: { direct_path: string; id: string; type: string }
|
||||
preview: { direct_path: string; id: string; type: string }
|
||||
subscribers_count: string
|
||||
verification: 'VERIFIED' | 'UNVERIFIED'
|
||||
}
|
||||
viewer_metadata: {
|
||||
mute: 'ON' | 'OFF'
|
||||
role: NewsletterViewRole
|
||||
}
|
||||
}
|
||||
export type NewsletterViewRole = 'ADMIN' | 'GUEST' | 'OWNER' | 'SUBSCRIBER'
|
||||
export interface NewsletterMetadata {
|
||||
id: string
|
||||
owner?: string
|
||||
name: string
|
||||
description?: string
|
||||
invite?: string
|
||||
creation_time?: number
|
||||
subscribers?: number
|
||||
picture?: {
|
||||
url?: string
|
||||
directPath?: string
|
||||
mediaKey?: string
|
||||
id?: string
|
||||
}
|
||||
verification?: 'VERIFIED' | 'UNVERIFIED'
|
||||
reaction_codes?: {
|
||||
code: string
|
||||
count: number
|
||||
}[]
|
||||
mute_state?: 'ON' | 'OFF'
|
||||
thread_metadata?: {
|
||||
creation_time?: number
|
||||
name?: string
|
||||
description?: string
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ export * from './Events'
|
||||
export * from './Product'
|
||||
export * from './Call'
|
||||
export * from './Signal'
|
||||
export * from './Newsletter'
|
||||
|
||||
import { AuthenticationState } from './Auth'
|
||||
import { SocketConfig } from './Socket'
|
||||
|
||||
Reference in New Issue
Block a user