Skip to content

Commit f972686

Browse files
committed
feat: Update chatwoot source ID and status after sent
1 parent e241cf4 commit f972686

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/api/integrations/chatbot/chatwoot/services/chatwoot.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,10 @@ export class ChatwootService {
14531453
chatwootIsRead: chatwootMessageIds.isRead,
14541454
},
14551455
});
1456+
1457+
if (this.isImportHistoryAvailable()) {
1458+
chatwootImport.updateMessageSourceID(chatwootMessageIds.messageId, key.id);
1459+
}
14561460
}
14571461

14581462
private async getMessageByKeyId(instance: InstanceDto, keyId: string): Promise<MessageModel> {

src/api/integrations/chatbot/chatwoot/utils/chatwoot-import-helper.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,14 @@ class ChatwootImport {
542542
public isIgnorePhoneNumber(remoteJid: string) {
543543
return this.isGroup(remoteJid) || remoteJid === 'status@broadcast' || remoteJid === '0@s.whatsapp.net';
544544
}
545+
546+
public updateMessageSourceID(messageId: string | number, sourceId: string) {
547+
const pgClient = postgresClient.getChatwootConnection();
548+
549+
const sql = `UPDATE messages SET source_id = $1, status = 0 WHERE id = $2;`;
550+
551+
return pgClient.query(sql, [`WAID:${sourceId}`, messageId]);
552+
}
545553
}
546554

547555
export const chatwootImport = new ChatwootImport();

0 commit comments

Comments
 (0)