Skip to content

Commit

Permalink
[EVOLUTION] support message deletion in Rocket.Chat
Browse files Browse the repository at this point in the history
  • Loading branch information
dudanogueira committed Mar 8, 2024
1 parent e6eaadb commit 5a92791
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions rocket_connect/plugins/evolution.py
Expand Up @@ -365,6 +365,25 @@ def incoming(self):
)
return JsonResponse({})
#
# messages deletion
#
if self.message.get("event") == "messages.delete":
if self.connector.server.type == "rocketchat":
# TODO: move this code do base?
ref_id = self.message.get("data").get("id")
if ref_id:
self.get_rocket_client()
msg = self.rocket.chat_get_message(msg_id=ref_id)
if msg:
new_message = ":warning: DELETED: ~{}~".format(
msg.json()["message"]["msg"]
)
room = self.get_room()
self.rocket.chat_update(
room_id=room.room_id, msg_id=ref_id, text=new_message
)

#
# handle calls
#
if self.message.get("event") == "call":
Expand Down Expand Up @@ -538,6 +557,8 @@ def get_visitor_phone(self):
# the phone can come both as remoteJid or chatId, for when it
if self.message.get("event") == "call":
remoteJid = self.message.get("data", {}).get("from")
elif self.message.get("event") == "messages.delete":
remoteJid = self.message.get("data", {}).get("remoteJid")
else:
remoteJid = self.message.get("data", {}).get("key", {}).get("remoteJid")
if remoteJid:
Expand Down

0 comments on commit 5a92791

Please sign in to comment.