mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-20 04:12:23 -06:00
fix: fixed bugs in the frontend, on the event screens
This commit is contained in:
@@ -159,48 +159,10 @@ export class EvolutionStartupService extends ChannelStartupService {
|
||||
data: messageRaw,
|
||||
});
|
||||
|
||||
const contact = await this.prismaRepository.contact.findFirst({
|
||||
where: { instanceId: this.instanceId, remoteJid: key.remoteJid },
|
||||
});
|
||||
|
||||
const contactRaw: any = {
|
||||
await this.updateContact({
|
||||
remoteJid: messageRaw.key.remoteJid,
|
||||
pushName: received.pushName,
|
||||
instanceId: this.instanceId,
|
||||
};
|
||||
|
||||
if (contactRaw.remoteJid === 'status@broadcast') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (contact) {
|
||||
const contactRaw: any = {
|
||||
remoteJid: messageRaw.key.remoteJid,
|
||||
pushName: received.pushName,
|
||||
instanceId: this.instanceId,
|
||||
};
|
||||
|
||||
this.sendDataWebhook(Events.CONTACTS_UPDATE, contactRaw);
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled) {
|
||||
await this.chatwootService.eventWhatsapp(
|
||||
Events.CONTACTS_UPDATE,
|
||||
{ instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
contactRaw,
|
||||
);
|
||||
}
|
||||
|
||||
await this.prismaRepository.contact.updateMany({
|
||||
where: { remoteJid: contact.remoteJid },
|
||||
data: contactRaw,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.sendDataWebhook(Events.CONTACTS_UPSERT, contactRaw);
|
||||
|
||||
this.prismaRepository.contact.create({
|
||||
data: contactRaw,
|
||||
pushName: messageRaw.pushName,
|
||||
profilePicUrl: null,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -208,6 +170,79 @@ export class EvolutionStartupService extends ChannelStartupService {
|
||||
}
|
||||
}
|
||||
|
||||
private async updateContact(data: { remoteJid: string; pushName?: string; profilePicUrl?: string }) {
|
||||
const contact = await this.prismaRepository.contact.findFirst({
|
||||
where: { instanceId: this.instanceId, remoteJid: data.remoteJid },
|
||||
});
|
||||
|
||||
if (contact) {
|
||||
const contactRaw: any = {
|
||||
remoteJid: data.remoteJid,
|
||||
pushName: data?.pushName,
|
||||
instanceId: this.instanceId,
|
||||
profilePicUrl: data?.profilePicUrl,
|
||||
};
|
||||
|
||||
this.sendDataWebhook(Events.CONTACTS_UPDATE, contactRaw);
|
||||
|
||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled) {
|
||||
await this.chatwootService.eventWhatsapp(
|
||||
Events.CONTACTS_UPDATE,
|
||||
{ instanceName: this.instance.name, instanceId: this.instanceId },
|
||||
contactRaw,
|
||||
);
|
||||
}
|
||||
|
||||
await this.prismaRepository.contact.updateMany({
|
||||
where: { remoteJid: contact.remoteJid },
|
||||
data: contactRaw,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const contactRaw: any = {
|
||||
remoteJid: data.remoteJid,
|
||||
pushName: data?.pushName,
|
||||
instanceId: this.instanceId,
|
||||
profilePicUrl: data?.profilePicUrl,
|
||||
};
|
||||
|
||||
this.sendDataWebhook(Events.CONTACTS_UPSERT, contactRaw);
|
||||
|
||||
await this.prismaRepository.contact.create({
|
||||
data: contactRaw,
|
||||
});
|
||||
|
||||
const chat = await this.prismaRepository.chat.findFirst({
|
||||
where: { instanceId: this.instanceId, remoteJid: data.remoteJid },
|
||||
});
|
||||
|
||||
if (chat) {
|
||||
const chatRaw: any = {
|
||||
remoteJid: data.remoteJid,
|
||||
instanceId: this.instanceId,
|
||||
};
|
||||
|
||||
this.sendDataWebhook(Events.CHATS_UPDATE, chatRaw);
|
||||
|
||||
await this.prismaRepository.chat.updateMany({
|
||||
where: { remoteJid: chat.remoteJid },
|
||||
data: chatRaw,
|
||||
});
|
||||
}
|
||||
|
||||
const chatRaw: any = {
|
||||
remoteJid: data.remoteJid,
|
||||
instanceId: this.instanceId,
|
||||
};
|
||||
|
||||
this.sendDataWebhook(Events.CHATS_UPSERT, chatRaw);
|
||||
|
||||
await this.prismaRepository.chat.create({
|
||||
data: chatRaw,
|
||||
});
|
||||
}
|
||||
|
||||
protected async sendMessageWithTyping(number: string, message: any, options?: Options, isIntegration = false) {
|
||||
try {
|
||||
let quoted: any;
|
||||
@@ -225,12 +260,16 @@ export class EvolutionStartupService extends ChannelStartupService {
|
||||
quoted = msg;
|
||||
}
|
||||
|
||||
if (options.delay) {
|
||||
await new Promise((resolve) => setTimeout(resolve, options.delay));
|
||||
}
|
||||
|
||||
if (options?.webhookUrl) {
|
||||
webhookUrl = options.webhookUrl;
|
||||
}
|
||||
|
||||
const messageRaw: any = {
|
||||
key: { fromMe: true, id: 'ID', remoteJid: this.createJid(number) },
|
||||
key: { fromMe: true, id: 'ID', remoteJid: number },
|
||||
message: {
|
||||
...message,
|
||||
quoted,
|
||||
|
||||
@@ -1130,6 +1130,11 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
const mediaUrl = await s3Service.getObjectUrl(fullName);
|
||||
|
||||
messageRaw.message.mediaUrl = mediaUrl;
|
||||
|
||||
await this.prismaRepository.message.update({
|
||||
where: { id: msg.id },
|
||||
data: messageRaw,
|
||||
});
|
||||
} catch (error) {
|
||||
this.logger.error('line 1181');
|
||||
this.logger.error(['Error on upload file to minio', error?.message, error?.stack]);
|
||||
@@ -2034,6 +2039,11 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
const mediaUrl = await s3Service.getObjectUrl(fullName);
|
||||
|
||||
messageRaw.message.mediaUrl = mediaUrl;
|
||||
|
||||
await this.prismaRepository.message.update({
|
||||
where: { id: msg.id },
|
||||
data: messageRaw,
|
||||
});
|
||||
} catch (error) {
|
||||
this.logger.error('line 1181');
|
||||
this.logger.error(['Error on upload file to minio', error?.message, error?.stack]);
|
||||
|
||||
@@ -36,5 +36,6 @@ export function ChatwootInstanceMixin<TBase extends Constructor>(Base: TBase) {
|
||||
chatwootNameInbox?: string;
|
||||
chatwootOrganization?: string;
|
||||
chatwootLogo?: string;
|
||||
chatwootAutoCreate?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user