canove / whaticket-community

A very simple Ticket System based on WhatsApp messages, that allow multi-users in same WhatsApp account.
MIT License
1.64k stars 830 forks source link

Load all WhatsApp conversations #174

Closed tiagoandrepro closed 3 years ago

tiagoandrepro commented 3 years ago

In the chat implementation according to issue #129 it is interesting to load all the old WhatsApp conversations. Do you have any resources or tips to implement this feature?

wirys commented 3 years ago

Em backend/src/libs/wbot.ts Adicione esse codigo

import { handleMessage } from "../services/WbotServices/wbotMessageListener";

const syncUnreadMessages = async (wbot: Session) => {
  const chats = await wbot.getChats();

  chats.forEach(async chat => {
    if (chat.unreadCount > 0) {
      const unreadMessages = await chat.fetchMessages({
        limit: chat.unreadCount
      });
      unreadMessages.forEach(msg => {
        handleMessage(msg, wbot);
      });
    }
  });
};
  syncUnreadMessages(wbot);

testa ai e me fala

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

viniciusclt commented 1 year ago

Opa meu amigo, pelo que entendi, esse code vai importar as mensagens não lidas no whatsapp, certo? Precisava trazer o histórico da conversa (mensagens antigas), consegue me ajudar?