From 0b537cb47ec9b6174769fa2ced946d41769662bf Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sat, 20 Apr 2024 23:35:44 +0530 Subject: [PATCH] fix: added api to react on whatsapp message --- crm/api/whatsapp.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crm/api/whatsapp.py b/crm/api/whatsapp.py index 2b8a5def..cbda59a0 100644 --- a/crm/api/whatsapp.py +++ b/crm/api/whatsapp.py @@ -52,4 +52,20 @@ def create_whatsapp_message(reference_doctype, reference_name, message, to, atta "content_type": content_type, }) doc.insert(ignore_permissions=True) + return doc.name + +@frappe.whitelist() +def react_on_whatsapp_message(emoji, reply_to_name): + reply_to_doc = frappe.get_doc("WhatsApp Message", reply_to_name) + to = reply_to_doc.type == "Incoming" and reply_to_doc.get("from") or reply_to_doc.to + doc = frappe.new_doc("WhatsApp Message") + doc.update({ + "reference_doctype": reply_to_doc.reference_doctype, + "reference_name": reply_to_doc.reference_name, + "message": emoji, + "to": to, + "reply_to_message_id": reply_to_doc.message_id, + "content_type": "reaction", + }) + doc.insert(ignore_permissions=True) return doc.name \ No newline at end of file