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