From 2c349c50c72ad2eb503d08bd59e4fc98b3c7e9a0 Mon Sep 17 00:00:00 2001 From: Joseph Mansy <36427684+yousefmansy1@users.noreply.github.com> Date: Fri, 10 Mar 2023 13:28:32 -0800 Subject: Support handling delete message from whatsapp. (#1986) --- bridge/whatsappmulti/handlers.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'bridge') diff --git a/bridge/whatsappmulti/handlers.go b/bridge/whatsappmulti/handlers.go index b8e78572..d99c6727 100644 --- a/bridge/whatsappmulti/handlers.go +++ b/bridge/whatsappmulti/handlers.go @@ -44,6 +44,8 @@ func (b *Bwhatsapp) handleMessage(message *events.Message) { b.handleDocumentMessage(message) case msg.ImageMessage != nil: b.handleImageMessage(message) + case msg.ProtocolMessage != nil && *msg.ProtocolMessage.Type == proto.ProtocolMessage_REVOKE: + b.handleDelete(msg.ProtocolMessage) } } @@ -359,3 +361,20 @@ func (b *Bwhatsapp) handleDocumentMessage(msg *events.Message) { b.Remote <- rmsg } + +func (b *Bwhatsapp) handleDelete(messageInfo *proto.ProtocolMessage) { + sender, _ := types.ParseJID(*messageInfo.Key.Participant) + + rmsg := config.Message{ + Account: b.Account, + Protocol: b.Protocol, + ID: getMessageIdFormat(sender, *messageInfo.Key.Id), + Event: config.EventMsgDelete, + Text: config.EventMsgDelete, + Channel: *messageInfo.Key.RemoteJid, + } + + b.Log.Debugf("<= Sending message from %s to gateway", b.Account) + b.Log.Debugf("<= Message is %#v", rmsg) + b.Remote <- rmsg +} -- cgit v1.2.3