[core] Add chat unread

fix #498
This commit is contained in:
devlikepro committed 2024-10-25 15:18:52 +07:00
1 parent 1a59300cd7
commit 64bf42dc1c
5 files changed
+31 -2

No files matched your search

+11
View File
@@ -124,6 +124,17 @@ class ChatsController {
) {
return session.chatsUnarchiveChat(chatId);
}
@Post(':chatId/unread')
@SessionApiParam
@ChatIdApiParam
@ApiOperation({ summary: 'Unread the chat' })
unreadChat(
@WorkingSessionParam session: WhatsappSession,
@Param('chatId') chatId: string,
) {
return session.chatsUnreadChat(chatId);
}
}
export { ChatsController };
+4
View File
@@ -359,6 +359,10 @@ export abstract class WhatsappSession {
throw new NotImplementedByEngineError();
}
public chatsUnreadChat(chatId: string): Promise<any> {
throw new NotImplementedByEngineError();
}
/**
* Labels methods
*/
@@ -833,6 +833,15 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
return this.chatsPutArchive(chatId, false);
}
public async chatsUnreadChat(chatId: string): Promise<any> {
const jid = toJID(chatId);
const messages = await this.store.getMessagesByJid(jid, 1);
return await this.sock.chatModify(
{ markRead: false, lastMessages: messages },
jid,
);
}
/**
* Labels methods
*/
@@ -566,6 +566,11 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
return this.whatsapp.unarchiveChat(id);
}
public chatsUnreadChat(chatId: string): Promise<any> {
const id = this.ensureSuffix(chatId);
return this.whatsapp.markChatUnread(id);
}
/**
*
* Label methods
+2 -2
View File
@@ -7,7 +7,7 @@ __metadata:
"@adiwajshing/baileys@github:devlikeapro/Baileys#fork-master-channels-678":
version: 6.7.8
resolution: "@adiwajshing/baileys@https://github.com/devlikeapro/Baileys.git#commit=d0323b92eb8365e6f32a61e41dd00010602d07f1"
resolution: "@adiwajshing/baileys@https://github.com/devlikeapro/Baileys.git#commit=fce71396d7a9229a23299b49d6e5bdca66e1c78b"
dependencies:
"@adiwajshing/keyed-db": ^0.2.4
"@hapi/boom": ^9.1.3
@@ -39,7 +39,7 @@ __metadata:
optional: true
sharp:
optional: true
checksum: a3b461006443713074401a17c3481aef571301e83f1fba193d06e7f9ea4c47359b5c973d0b3804e34d4e48c35bdc1a64d8c3e59a0a744e5bc9bcca591d180901
checksum: c8823494b7d7d237c32eeac2fdd09a1345bb4e16cd11de28dc326909778dc8c7f9ea4231af86659a8fa04231720709798b7ed7b070b555c67ec4dce77d4e064a
languageName: node
linkType: hard