Skip to content

Commit

Permalink
[EVOLUTION] Ignore view once messages for now and alert with outcome …
Browse files Browse the repository at this point in the history
…text
  • Loading branch information
dudanogueira committed May 3, 2024
1 parent ed5fdbe commit c1ac775
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions rocket_connect/plugins/evolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,12 @@ def incoming(self):
if self.message.get("event") == "messages.upsert":

# ignore buttons message
if self.message.get("data").get("messageType") in ["buttonsMessage", "buttonsResponseMessage"]:
return JsonResponse({"message": "Buttons not supported"})
if self.message.get("data").get("messageType") in [
"buttonsMessage", "buttonsResponseMessage", "listMessage", "listResponseMessage"
]:
return JsonResponse({"message": "Buttons or list not supported"})



department = None
message_obj, created = self.register_message()
Expand All @@ -586,6 +590,17 @@ def incoming(self):
if not room:
return JsonResponse({"message": "no room generated"})

# alert on viewonce
if self.message.get("data").get("messageType") in [
"viewOnceMessage"
]:
self.outcome_text(
room_id=self.room.room_id,
text=f"User sent ViewOnce message. This is not supported!!",
message_id=self.get_message_id(),
).json()
return JsonResponse({"message": "User sent ViewOnce message. This is not supported!!"})

#
# outcome if a quoted message
#
Expand Down Expand Up @@ -684,8 +699,8 @@ def incoming(self):
if message.get("contactsArrayMessage") or message.get("contactMessage"):
if message.get("contactsArrayMessage"):
contacts = message.get("contactsArrayMessage").get(
"contacts",
)
"contacts",
)
if message.get("contactMessage"):
contacts = [message.get("contactMessage")]
i = 0
Expand Down Expand Up @@ -812,12 +827,14 @@ def incoming(self):
#
if message.get("editedMessage"):
# get current message content
edited_id = message.get("editedMessage", {}).get("message", {}).get("protocolMessage", {}).get("key", {}).get("id", {})
edited_id = message.get("editedMessage", {}).get("message", {}).get(
"protocolMessage", {}).get("key", {}).get("id", {})
self.get_rocket_client()
edited_message = self.rocket.chat_get_message(msg_id=edited_id)
if edited_message.ok:
edited_content = edited_message.json()["message"]["msg"]
new_content = message.get("editedMessage", {}).get("message", {}).get("protocolMessage", {}).get("editedMessage", {}).get("conversation", {})
new_content = message.get("editedMessage", {}).get("message", {}).get(
"protocolMessage", {}).get("editedMessage", {}).get("conversation", {})
text = f"EDIT: ~{edited_content}~\n{new_content}"
self.outcome_text(room.room_id, text)
return JsonResponse({"message": "edited message"})
Expand Down

0 comments on commit c1ac775

Please sign in to comment.