mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2026-03-21 20:18:40 -06:00
feat: add generateMessageID method and support for messageId in sendMessage DTO
This commit is contained in:
@@ -14,6 +14,7 @@ export class Options {
|
||||
mentionsEveryOne?: boolean;
|
||||
mentioned?: string[];
|
||||
webhookUrl?: string;
|
||||
messageId?: string;
|
||||
}
|
||||
|
||||
export class MediaMessage {
|
||||
@@ -45,6 +46,7 @@ export class Metadata {
|
||||
mentioned?: string[];
|
||||
encoding?: boolean;
|
||||
notConvertSticker?: boolean;
|
||||
messageId?: string;
|
||||
}
|
||||
|
||||
export class SendTextDto extends Metadata {
|
||||
|
||||
@@ -318,7 +318,7 @@ export class EvolutionStartupService extends ChannelStartupService {
|
||||
|
||||
let audioFile;
|
||||
|
||||
const messageId = v4();
|
||||
const messageId = options?.messageId || v4();
|
||||
|
||||
let messageRaw: any;
|
||||
|
||||
@@ -548,6 +548,7 @@ export class EvolutionStartupService extends ChannelStartupService {
|
||||
linkPreview: data?.linkPreview,
|
||||
mentionsEveryOne: data?.mentionsEveryOne,
|
||||
mentioned: data?.mentioned,
|
||||
messageId: data?.messageId,
|
||||
},
|
||||
null,
|
||||
isIntegration,
|
||||
@@ -613,6 +614,7 @@ export class EvolutionStartupService extends ChannelStartupService {
|
||||
linkPreview: data?.linkPreview,
|
||||
mentionsEveryOne: data?.mentionsEveryOne,
|
||||
mentioned: data?.mentioned,
|
||||
messageId: data?.messageId,
|
||||
},
|
||||
file,
|
||||
isIntegration,
|
||||
@@ -711,6 +713,7 @@ export class EvolutionStartupService extends ChannelStartupService {
|
||||
linkPreview: data?.linkPreview,
|
||||
mentionsEveryOne: data?.mentionsEveryOne,
|
||||
mentioned: data?.mentioned,
|
||||
messageId: data?.messageId,
|
||||
},
|
||||
file,
|
||||
isIntegration,
|
||||
@@ -736,6 +739,7 @@ export class EvolutionStartupService extends ChannelStartupService {
|
||||
quoted: data?.quoted,
|
||||
mentionsEveryOne: data?.mentionsEveryOne,
|
||||
mentioned: data?.mentioned,
|
||||
messageId: data?.messageId,
|
||||
},
|
||||
null,
|
||||
isIntegration,
|
||||
|
||||
@@ -10,6 +10,12 @@ export class BaileysController {
|
||||
return instance.baileysOnWhatsapp(body?.jid);
|
||||
}
|
||||
|
||||
public async generateMessageID({ instanceName }: InstanceDto) {
|
||||
const instance = this.waMonitor.waInstances[instanceName];
|
||||
|
||||
return instance.generateMessageID();
|
||||
}
|
||||
|
||||
public async profilePictureUrl({ instanceName }: InstanceDto, body: any) {
|
||||
const instance = this.waMonitor.waInstances[instanceName];
|
||||
|
||||
|
||||
@@ -19,6 +19,16 @@ export class BaileysRouter extends RouterBroker {
|
||||
|
||||
res.status(HttpStatus.OK).json(response);
|
||||
})
|
||||
.get(this.routerPath('generateMessageID'), ...guards, async (req, res) => {
|
||||
const response = await this.dataValidate<InstanceDto>({
|
||||
request: req,
|
||||
schema: instanceSchema,
|
||||
ClassRef: InstanceDto,
|
||||
execute: (instance) => baileysController.generateMessageID(instance),
|
||||
});
|
||||
|
||||
res.status(HttpStatus.OK).json(response);
|
||||
})
|
||||
.post(this.routerPath('profilePictureUrl'), ...guards, async (req, res) => {
|
||||
const response = await this.dataValidate<InstanceDto>({
|
||||
request: req,
|
||||
|
||||
@@ -128,6 +128,7 @@ import makeWASocket, {
|
||||
WAMessageKey,
|
||||
WAPresence,
|
||||
WASocket,
|
||||
generateMessageIDV2
|
||||
} from 'baileys';
|
||||
import { Label } from 'baileys/lib/Types/Label';
|
||||
import { LabelAssociation } from 'baileys/lib/Types/LabelAssociation';
|
||||
@@ -1979,6 +1980,13 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
}
|
||||
}
|
||||
|
||||
private async generateMessageID() {
|
||||
|
||||
return {
|
||||
id: generateMessageIDV2(this.client.user?.id)
|
||||
};
|
||||
}
|
||||
|
||||
private async sendMessage(
|
||||
sender: string,
|
||||
message: any,
|
||||
@@ -2242,7 +2250,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
mentions,
|
||||
linkPreview,
|
||||
quoted,
|
||||
null,
|
||||
options.messageId,
|
||||
group?.ephemeralDuration,
|
||||
// group?.participants,
|
||||
);
|
||||
@@ -2264,7 +2272,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
mentions,
|
||||
linkPreview,
|
||||
quoted,
|
||||
null,
|
||||
options.messageId,
|
||||
undefined,
|
||||
contextInfo,
|
||||
);
|
||||
@@ -2490,6 +2498,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
linkPreview: data?.linkPreview,
|
||||
mentionsEveryOne: data?.mentionsEveryOne,
|
||||
mentioned: data?.mentioned,
|
||||
messageId: data?.messageId,
|
||||
},
|
||||
isIntegration,
|
||||
);
|
||||
@@ -2506,6 +2515,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
linkPreview: data?.linkPreview,
|
||||
mentionsEveryOne: data?.mentionsEveryOne,
|
||||
mentioned: data?.mentioned,
|
||||
messageId: data?.messageId,
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -2819,6 +2829,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
quoted: data?.quoted,
|
||||
mentionsEveryOne: data?.mentionsEveryOne,
|
||||
mentioned: data?.mentioned,
|
||||
messageId: data?.messageId,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -2841,6 +2852,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
quoted: data?.quoted,
|
||||
mentionsEveryOne: data?.mentionsEveryOne,
|
||||
mentioned: data?.mentioned,
|
||||
messageId: data?.messageId,
|
||||
},
|
||||
isIntegration,
|
||||
);
|
||||
@@ -2857,6 +2869,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
quoted: data?.quoted,
|
||||
mentionsEveryOne: data?.mentionsEveryOne,
|
||||
mentioned: data?.mentioned,
|
||||
messageId: data?.messageId,
|
||||
};
|
||||
|
||||
if (file) mediaData.media = file.buffer.toString('base64');
|
||||
@@ -2872,6 +2885,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
quoted: data?.quoted,
|
||||
mentionsEveryOne: data?.mentionsEveryOne,
|
||||
mentioned: data?.mentioned,
|
||||
messageId: data?.messageId,
|
||||
},
|
||||
isIntegration,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user