fix: Ghost emoji correction in message sending

Corrects an issue where a ghost emoji was being displayed in message sending. The 'Mentions' class was removed and its properties were moved to the 'Options' class. The 'everyOne' and 'mentioned' properties were replaced by 'mentionsEveryOne' and 'mentioned', respectively. This change improves the code readability and maintainability.

The affected files are:
- src/api/dto/sendMessage.dto.ts
- src/api/services/channels/whatsapp.baileys.service.ts
- src/api/services/channels/whatsapp.business.service.ts
This commit is contained in:
Davidson Gomes 2024-06-26 17:27:38 -03:00
parent 0ded76d366
commit 99f4fe2e43
3 changed files with 43 additions and 77 deletions

View File

@ -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;
}

View File

@ -1831,11 +1831,12 @@ export class BaileysStartupService extends ChannelStartupService {
throw new NotFoundException('Group not found');
}
if (options?.mentions) {
if (options.mentions?.everyOne) {
console.log('options', options);
if (options.mentionsEveryOne) {
mentions = group.participants.map((participant) => participant.id);
} else if (options.mentions?.mentioned?.length) {
mentions = options.mentions.mentioned.map((mention) => {
} else if (options.mentioned?.length) {
mentions = options.mentioned.map((mention) => {
const jid = this.createJid(mention);
if (isJidGroup(jid)) {
return null;
@ -1843,14 +1844,11 @@ export class BaileysStartupService extends ChannelStartupService {
return jid;
});
}
}
} catch (error) {
throw new NotFoundException('Group not found');
}
}
console.log('message', message);
const messageSent = await (async () => {
const option = {
quoted,
@ -2073,11 +2071,9 @@ export class BaileysStartupService extends ChannelStartupService {
presence: 'composing',
quoted: data?.quoted,
linkPreview: data?.linkPreview,
mentions: {
everyOne: data?.everyOne,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
},
},
isIntegration,
);
}
@ -2097,11 +2093,9 @@ export class BaileysStartupService extends ChannelStartupService {
presence: 'composing',
quoted: data?.quoted,
linkPreview: data?.linkPreview,
mentions: {
everyOne: data?.everyOne,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
},
},
);
}
@ -2352,11 +2346,9 @@ export class BaileysStartupService extends ChannelStartupService {
delay: data?.delay,
presence: 'composing',
quoted: data?.quoted,
mentions: {
everyOne: data?.everyOne,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
},
},
);
fs.unlinkSync(convert);
@ -2374,11 +2366,9 @@ export class BaileysStartupService extends ChannelStartupService {
delay: data?.delay,
presence: 'composing',
quoted: data?.quoted,
mentions: {
everyOne: data?.everyOne,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
},
},
isIntegration,
);
}
@ -2541,11 +2531,9 @@ export class BaileysStartupService extends ChannelStartupService {
delay: data?.delay,
presence: 'composing',
quoted: data?.quoted,
mentions: {
everyOne: data?.everyOne,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
},
},
);
}
@ -2566,11 +2554,9 @@ export class BaileysStartupService extends ChannelStartupService {
delay: data?.delay,
presence: 'composing',
quoted: data?.quoted,
mentions: {
everyOne: data?.everyOne,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
},
},
);
}

View File

@ -853,11 +853,9 @@ export class BusinessStartupService extends ChannelStartupService {
presence: 'composing',
quoted: data?.quoted,
linkPreview: data?.linkPreview,
mentions: {
everyOne: data?.everyOne,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
},
},
isIntegration,
);
return res;
@ -938,11 +936,9 @@ export class BusinessStartupService extends ChannelStartupService {
presence: 'composing',
quoted: data?.quoted,
linkPreview: data?.linkPreview,
mentions: {
everyOne: data?.everyOne,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
},
},
isIntegration,
);
}
@ -986,11 +982,9 @@ export class BusinessStartupService extends ChannelStartupService {
presence: 'composing',
quoted: data?.quoted,
linkPreview: data?.linkPreview,
mentions: {
everyOne: data?.everyOne,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
},
},
isIntegration,
);
}
@ -1027,11 +1021,9 @@ export class BusinessStartupService extends ChannelStartupService {
presence: 'composing',
quoted: data?.quoted,
linkPreview: data?.linkPreview,
mentions: {
everyOne: data?.everyOne,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
},
},
);
}
@ -1051,11 +1043,9 @@ export class BusinessStartupService extends ChannelStartupService {
presence: 'composing',
quoted: data?.quoted,
linkPreview: data?.linkPreview,
mentions: {
everyOne: data?.everyOne,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
},
},
);
}
@ -1093,11 +1083,9 @@ export class BusinessStartupService extends ChannelStartupService {
presence: 'composing',
quoted: data?.quoted,
linkPreview: data?.linkPreview,
mentions: {
everyOne: data?.everyOne,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
},
},
);
}
@ -1116,11 +1104,9 @@ export class BusinessStartupService extends ChannelStartupService {
presence: 'composing',
quoted: data?.quoted,
linkPreview: data?.linkPreview,
mentions: {
everyOne: data?.everyOne,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
},
},
isIntegration,
);
return res;
@ -1188,11 +1174,9 @@ export class BusinessStartupService extends ChannelStartupService {
presence: 'composing',
quoted: data?.quoted,
linkPreview: data?.linkPreview,
mentions: {
everyOne: data?.everyOne,
mentionsEveryOne: data?.mentionsEveryOne,
mentioned: data?.mentioned,
},
},
);
}