diff --git a/src/api/dto/sendMessage.dto.ts b/src/api/dto/sendMessage.dto.ts index ef922ae1..46839366 100644 --- a/src/api/dto/sendMessage.dto.ts +++ b/src/api/dto/sendMessage.dto.ts @@ -5,18 +5,14 @@ export class Quoted { message: proto.IMessage; } -export class Mentions { - everyOne?: boolean; - mentioned?: string[]; -} - export class Options { delay?: number; presence?: WAPresence; quoted?: Quoted; - mentions?: Mentions; linkPreview?: boolean; encoding?: boolean; + mentionsEveryOne?: boolean; + mentioned?: string[]; } export class MediaMessage { @@ -44,7 +40,7 @@ export class Metadata { delay?: number; quoted?: Quoted; linkPreview?: boolean; - everyOne?: boolean; + mentionsEveryOne?: boolean; mentioned?: string[]; encoding?: boolean; } diff --git a/src/api/services/channels/whatsapp.baileys.service.ts b/src/api/services/channels/whatsapp.baileys.service.ts index 49271d69..ac356b5c 100644 --- a/src/api/services/channels/whatsapp.baileys.service.ts +++ b/src/api/services/channels/whatsapp.baileys.service.ts @@ -1831,26 +1831,24 @@ export class BaileysStartupService extends ChannelStartupService { throw new NotFoundException('Group not found'); } - if (options?.mentions) { - if (options.mentions?.everyOne) { - mentions = group.participants.map((participant) => participant.id); - } else if (options.mentions?.mentioned?.length) { - mentions = options.mentions.mentioned.map((mention) => { - const jid = this.createJid(mention); - if (isJidGroup(jid)) { - return null; - } - return jid; - }); - } + console.log('options', options); + + if (options.mentionsEveryOne) { + mentions = group.participants.map((participant) => participant.id); + } else if (options.mentioned?.length) { + mentions = options.mentioned.map((mention) => { + const jid = this.createJid(mention); + if (isJidGroup(jid)) { + return null; + } + return jid; + }); } } catch (error) { throw new NotFoundException('Group not found'); } } - console.log('message', message); - const messageSent = await (async () => { const option = { quoted, @@ -2073,10 +2071,8 @@ export class BaileysStartupService extends ChannelStartupService { presence: 'composing', quoted: data?.quoted, linkPreview: data?.linkPreview, - mentions: { - everyOne: data?.everyOne, - mentioned: data?.mentioned, - }, + mentionsEveryOne: data?.mentionsEveryOne, + mentioned: data?.mentioned, }, isIntegration, ); @@ -2097,10 +2093,8 @@ export class BaileysStartupService extends ChannelStartupService { presence: 'composing', quoted: data?.quoted, linkPreview: data?.linkPreview, - mentions: { - everyOne: data?.everyOne, - mentioned: data?.mentioned, - }, + mentionsEveryOne: data?.mentionsEveryOne, + mentioned: data?.mentioned, }, ); } @@ -2352,10 +2346,8 @@ export class BaileysStartupService extends ChannelStartupService { delay: data?.delay, presence: 'composing', quoted: data?.quoted, - mentions: { - everyOne: data?.everyOne, - mentioned: data?.mentioned, - }, + mentionsEveryOne: data?.mentionsEveryOne, + mentioned: data?.mentioned, }, ); @@ -2374,10 +2366,8 @@ export class BaileysStartupService extends ChannelStartupService { delay: data?.delay, presence: 'composing', quoted: data?.quoted, - mentions: { - everyOne: data?.everyOne, - mentioned: data?.mentioned, - }, + mentionsEveryOne: data?.mentionsEveryOne, + mentioned: data?.mentioned, }, isIntegration, ); @@ -2541,10 +2531,8 @@ export class BaileysStartupService extends ChannelStartupService { delay: data?.delay, presence: 'composing', quoted: data?.quoted, - mentions: { - everyOne: data?.everyOne, - mentioned: data?.mentioned, - }, + mentionsEveryOne: data?.mentionsEveryOne, + mentioned: data?.mentioned, }, ); } @@ -2566,10 +2554,8 @@ export class BaileysStartupService extends ChannelStartupService { delay: data?.delay, presence: 'composing', quoted: data?.quoted, - mentions: { - everyOne: data?.everyOne, - mentioned: data?.mentioned, - }, + mentionsEveryOne: data?.mentionsEveryOne, + mentioned: data?.mentioned, }, ); } diff --git a/src/api/services/channels/whatsapp.business.service.ts b/src/api/services/channels/whatsapp.business.service.ts index cc0cd893..4f51c9b6 100644 --- a/src/api/services/channels/whatsapp.business.service.ts +++ b/src/api/services/channels/whatsapp.business.service.ts @@ -853,10 +853,8 @@ export class BusinessStartupService extends ChannelStartupService { presence: 'composing', quoted: data?.quoted, linkPreview: data?.linkPreview, - mentions: { - everyOne: data?.everyOne, - mentioned: data?.mentioned, - }, + mentionsEveryOne: data?.mentionsEveryOne, + mentioned: data?.mentioned, }, isIntegration, ); @@ -938,10 +936,8 @@ export class BusinessStartupService extends ChannelStartupService { presence: 'composing', quoted: data?.quoted, linkPreview: data?.linkPreview, - mentions: { - everyOne: data?.everyOne, - mentioned: data?.mentioned, - }, + mentionsEveryOne: data?.mentionsEveryOne, + mentioned: data?.mentioned, }, isIntegration, ); @@ -986,10 +982,8 @@ export class BusinessStartupService extends ChannelStartupService { presence: 'composing', quoted: data?.quoted, linkPreview: data?.linkPreview, - mentions: { - everyOne: data?.everyOne, - mentioned: data?.mentioned, - }, + mentionsEveryOne: data?.mentionsEveryOne, + mentioned: data?.mentioned, }, isIntegration, ); @@ -1027,10 +1021,8 @@ export class BusinessStartupService extends ChannelStartupService { presence: 'composing', quoted: data?.quoted, linkPreview: data?.linkPreview, - mentions: { - everyOne: data?.everyOne, - mentioned: data?.mentioned, - }, + mentionsEveryOne: data?.mentionsEveryOne, + mentioned: data?.mentioned, }, ); } @@ -1051,10 +1043,8 @@ export class BusinessStartupService extends ChannelStartupService { presence: 'composing', quoted: data?.quoted, linkPreview: data?.linkPreview, - mentions: { - everyOne: data?.everyOne, - mentioned: data?.mentioned, - }, + mentionsEveryOne: data?.mentionsEveryOne, + mentioned: data?.mentioned, }, ); } @@ -1093,10 +1083,8 @@ export class BusinessStartupService extends ChannelStartupService { presence: 'composing', quoted: data?.quoted, linkPreview: data?.linkPreview, - mentions: { - everyOne: data?.everyOne, - mentioned: data?.mentioned, - }, + mentionsEveryOne: data?.mentionsEveryOne, + mentioned: data?.mentioned, }, ); } @@ -1116,10 +1104,8 @@ export class BusinessStartupService extends ChannelStartupService { presence: 'composing', quoted: data?.quoted, linkPreview: data?.linkPreview, - mentions: { - everyOne: data?.everyOne, - mentioned: data?.mentioned, - }, + mentionsEveryOne: data?.mentionsEveryOne, + mentioned: data?.mentioned, }, isIntegration, ); @@ -1188,10 +1174,8 @@ export class BusinessStartupService extends ChannelStartupService { presence: 'composing', quoted: data?.quoted, linkPreview: data?.linkPreview, - mentions: { - everyOne: data?.everyOne, - mentioned: data?.mentioned, - }, + mentionsEveryOne: data?.mentionsEveryOne, + mentioned: data?.mentioned, }, ); }