[core] ChatWoot - no from me tag for history (from whatsapp or API)
This commit is contained in:
1 parent
4e58713e7e
commit
d60dfba90a
2 files changed
+14
-10
No files matched your search
@@ -332,6 +332,7 @@ export class TaskActivity {
|
||||
private l: Locale,
|
||||
private conversation: Conversation,
|
||||
) {}
|
||||
|
||||
public async queue(paused: boolean) {
|
||||
let msg: string;
|
||||
if (paused) {
|
||||
@@ -391,6 +392,10 @@ class MessageAnyHistoryHandler extends MessageAnyHandler {
|
||||
public force: boolean = false;
|
||||
public shouldLogUnsupported = true;
|
||||
|
||||
protected get shouldAddFromTag() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected get delayFromMeAPI() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -219,6 +219,13 @@ export abstract class MessageBaseHandler<Payload extends WAMessageBase> {
|
||||
return 3_000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Weather to add a tag to messages sent from me like via API or WhatsApp
|
||||
*/
|
||||
protected get shouldAddFromTag() {
|
||||
return true;
|
||||
}
|
||||
|
||||
async ShouldProcessMessage(payload: Payload): Promise<boolean> {
|
||||
const key = parseMessageIdSerialized(payload.id);
|
||||
const chatwoot = await this.mappingService.getChatWootMessage({
|
||||
@@ -293,16 +300,8 @@ export abstract class MessageBaseHandler<Payload extends WAMessageBase> {
|
||||
let content = message.content;
|
||||
|
||||
// Format the content if the message from me
|
||||
if (payload.fromMe) {
|
||||
const key = parseMessageIdSerialized(payload.id);
|
||||
const chatwoot = await this.mappingService.getChatWootMessage({
|
||||
chat_id: toCusFormat(key.remoteJid),
|
||||
message_id: key.id,
|
||||
});
|
||||
const exists = !!chatwoot;
|
||||
if (exists) {
|
||||
// No additional content required
|
||||
} else if (payload.source === MessageSource.APP) {
|
||||
if (payload.fromMe && this.shouldAddFromTag) {
|
||||
if (payload.source === MessageSource.APP) {
|
||||
const key = TKey.MESSAGE_FROM_WHATSAPP;
|
||||
content = this.l.key(key).render({ text: content });
|
||||
} else if (payload.source === MessageSource.API) {
|
||||
|
||||
Reference in new issue
Block a user