mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-22 20:12:02 -06:00
Merge branch 'develop' of github.com:EvolutionAPI/evolution-api into develop
This commit is contained in:
commit
9945d8debb
@ -25,7 +25,14 @@ export async function useMultiFileAuthStateDb(
|
||||
const writeData = async (data: any, key: string): Promise<any> => {
|
||||
try {
|
||||
await client.connect();
|
||||
return await collection.replaceOne({ _id: key }, JSON.parse(JSON.stringify(data, BufferJSON.replacer)), {
|
||||
let msgParsed = JSON.parse(JSON.stringify(data, BufferJSON.replacer));
|
||||
if (Array.isArray(msgParsed)) {
|
||||
msgParsed = {
|
||||
_id: key,
|
||||
content_array: msgParsed,
|
||||
};
|
||||
}
|
||||
return await collection.replaceOne({ _id: key }, msgParsed, {
|
||||
upsert: true,
|
||||
});
|
||||
} catch (error) {
|
||||
@ -36,7 +43,10 @@ export async function useMultiFileAuthStateDb(
|
||||
const readData = async (key: string): Promise<any> => {
|
||||
try {
|
||||
await client.connect();
|
||||
const data = await collection.findOne({ _id: key });
|
||||
let data = (await collection.findOne({ _id: key })) as any;
|
||||
if (data?.content_array) {
|
||||
data = data.content_array;
|
||||
}
|
||||
const creds = JSON.stringify(data);
|
||||
return JSON.parse(creds, BufferJSON.reviver);
|
||||
} catch (error) {
|
||||
|
@ -338,14 +338,18 @@ export class ChatwootService {
|
||||
}
|
||||
|
||||
this.logger.verbose('update contact in chatwoot');
|
||||
const contact = await client.contacts.update({
|
||||
accountId: this.provider.account_id,
|
||||
id,
|
||||
data,
|
||||
});
|
||||
try {
|
||||
const contact = await client.contacts.update({
|
||||
accountId: this.provider.account_id,
|
||||
id,
|
||||
data,
|
||||
});
|
||||
|
||||
this.logger.verbose('contact updated');
|
||||
return contact;
|
||||
this.logger.verbose('contact updated');
|
||||
return contact;
|
||||
} catch (error) {
|
||||
this.logger.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
public async findContact(instance: InstanceDto, phoneNumber: string) {
|
||||
@ -488,6 +492,9 @@ export class ChatwootService {
|
||||
avatar_url: picture_url.profilePictureUrl || null,
|
||||
});
|
||||
}
|
||||
if (!contact) {
|
||||
contact = await this.findContact(instance, chatId);
|
||||
}
|
||||
} else {
|
||||
const jid = isGroup ? null : body.key.remoteJid;
|
||||
contact = await this.createContact(
|
||||
|
@ -369,7 +369,7 @@ export class TypebotService {
|
||||
}
|
||||
|
||||
if (element.underline) {
|
||||
text = `~${text}~`;
|
||||
text = `*${text}*`;
|
||||
}
|
||||
|
||||
if (element.url) {
|
||||
|
@ -2283,6 +2283,21 @@ export class WAStartupService {
|
||||
!message['conversation'] &&
|
||||
sender !== 'status@broadcast'
|
||||
) {
|
||||
|
||||
if (message['reactionMessage']) {
|
||||
this.logger.verbose('Sending reaction');
|
||||
return await this.client.sendMessage(
|
||||
sender,
|
||||
{
|
||||
react: {
|
||||
text: message['reactionMessage']['text'],
|
||||
key: message['reactionMessage']['key']
|
||||
}
|
||||
} as unknown as AnyMessageContent,
|
||||
option as unknown as MiscMessageGenerationOptions,
|
||||
);
|
||||
}
|
||||
|
||||
if (!message['audio']) {
|
||||
this.logger.verbose('Sending message');
|
||||
return await this.client.sendMessage(
|
||||
@ -2298,7 +2313,6 @@ export class WAStartupService {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (message['conversation']) {
|
||||
this.logger.verbose('Sending message');
|
||||
return await this.client.sendMessage(
|
||||
@ -2346,7 +2360,7 @@ export class WAStartupService {
|
||||
this.logger.log(messageRaw);
|
||||
|
||||
this.logger.verbose('Sending data to webhook in event SEND_MESSAGE');
|
||||
await this.sendDataWebhook(Events.SEND_MESSAGE, messageRaw);
|
||||
this.sendDataWebhook(Events.SEND_MESSAGE, messageRaw);
|
||||
|
||||
if (this.localChatwoot.enabled && !isChatwoot) {
|
||||
this.chatwootService.eventWhatsapp(Events.SEND_MESSAGE, { instanceName: this.instance.name }, messageRaw);
|
||||
|
Loading…
Reference in New Issue
Block a user