mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-05 14:38:26 +00:00
fix: Create error log if something goes wrong while call log creation (#19055)
* fix: Create error log if something goes wrong while call log creation - For better debbugging * fix: Rollback if any error occurs during call log creation
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import frappe
|
import frappe
|
||||||
import requests
|
import requests
|
||||||
|
from frappe import _
|
||||||
|
|
||||||
# api/method/erpnext.erpnext_integrations.exotel_integration.handle_incoming_call
|
# api/method/erpnext.erpnext_integrations.exotel_integration.handle_incoming_call
|
||||||
# api/method/erpnext.erpnext_integrations.exotel_integration.handle_end_call
|
# api/method/erpnext.erpnext_integrations.exotel_integration.handle_end_call
|
||||||
@@ -7,19 +8,24 @@ import requests
|
|||||||
|
|
||||||
@frappe.whitelist(allow_guest=True)
|
@frappe.whitelist(allow_guest=True)
|
||||||
def handle_incoming_call(**kwargs):
|
def handle_incoming_call(**kwargs):
|
||||||
exotel_settings = get_exotel_settings()
|
try:
|
||||||
if not exotel_settings.enabled: return
|
exotel_settings = get_exotel_settings()
|
||||||
|
if not exotel_settings.enabled: return
|
||||||
|
|
||||||
call_payload = kwargs
|
call_payload = kwargs
|
||||||
status = call_payload.get('Status')
|
status = call_payload.get('Status')
|
||||||
if status == 'free':
|
if status == 'free':
|
||||||
return
|
return
|
||||||
|
|
||||||
call_log = get_call_log(call_payload)
|
call_log = get_call_log(call_payload)
|
||||||
if not call_log:
|
if not call_log:
|
||||||
create_call_log(call_payload)
|
create_call_log(call_payload)
|
||||||
else:
|
else:
|
||||||
update_call_log(call_payload, call_log=call_log)
|
update_call_log(call_payload, call_log=call_log)
|
||||||
|
except Exception as e:
|
||||||
|
frappe.db.rollback()
|
||||||
|
frappe.log_error(title=_('Error in Exotel incoming call'))
|
||||||
|
frappe.db.commit()
|
||||||
|
|
||||||
@frappe.whitelist(allow_guest=True)
|
@frappe.whitelist(allow_guest=True)
|
||||||
def handle_end_call(**kwargs):
|
def handle_end_call(**kwargs):
|
||||||
|
|||||||
Reference in New Issue
Block a user