fix: added api to react on whatsapp message

This commit is contained in:
Shariq Ansari 2024-04-20 23:35:44 +05:30
parent d9cb2ed683
commit 0b537cb47e

View File

@ -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