mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2026-03-21 20:18:40 -06:00
Merge pull request #2361 from JefersonRamos/feat/send-message-with-key-id
feat: add generateMessageID method and support for messageId in sendM…
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,
|
||||
|
||||
@@ -104,6 +104,7 @@ import makeWASocket, {
|
||||
DisconnectReason,
|
||||
downloadContentFromMessage,
|
||||
downloadMediaMessage,
|
||||
generateMessageIDV2,
|
||||
generateWAMessageFromContent,
|
||||
getAggregateVotesInPollMessage,
|
||||
GetCatalogOptions,
|
||||
@@ -2225,6 +2226,11 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
public generateMessageID() {
|
||||
return {
|
||||
id: generateMessageIDV2(this.client.user?.id),
|
||||
};
|
||||
}
|
||||
|
||||
private async generateLinkPreview(text: string) {
|
||||
try {
|
||||
@@ -2534,7 +2540,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
mentions,
|
||||
linkPreview,
|
||||
quoted,
|
||||
null,
|
||||
options?.messageId ?? null,
|
||||
group?.ephemeralDuration,
|
||||
previewContext,
|
||||
// group?.participants,
|
||||
@@ -2558,7 +2564,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
mentions,
|
||||
linkPreview,
|
||||
quoted,
|
||||
null,
|
||||
options?.messageId ?? null,
|
||||
undefined,
|
||||
contextInfo,
|
||||
);
|
||||
@@ -2790,6 +2796,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
linkPreview: data?.linkPreview,
|
||||
mentionsEveryOne: data?.mentionsEveryOne,
|
||||
mentioned: data?.mentioned,
|
||||
messageId: data?.messageId,
|
||||
},
|
||||
isIntegration,
|
||||
);
|
||||
@@ -2806,6 +2813,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
linkPreview: data?.linkPreview,
|
||||
mentionsEveryOne: data?.mentionsEveryOne,
|
||||
mentioned: data?.mentioned,
|
||||
messageId: data?.messageId,
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -3119,6 +3127,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
quoted: data?.quoted,
|
||||
mentionsEveryOne: data?.mentionsEveryOne,
|
||||
mentioned: data?.mentioned,
|
||||
messageId: data?.messageId,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -3141,6 +3150,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
quoted: data?.quoted,
|
||||
mentionsEveryOne: data?.mentionsEveryOne,
|
||||
mentioned: data?.mentioned,
|
||||
messageId: data?.messageId,
|
||||
},
|
||||
isIntegration,
|
||||
);
|
||||
@@ -3157,6 +3167,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');
|
||||
@@ -3172,6 +3183,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