fix: Handle exception where no employee is returned

This commit is contained in:
Suraj Shetty 2022-04-04 07:38:15 +05:30
parent 39abfae5fe
commit cfee53eb55

View File

@ -35,10 +35,10 @@ class CallLog(Document):
# Add Employee Name
if self.is_incoming_call():
# Taking the last 10 digits of the number
employee = get_employees_with_number(self.get("to"))
self.call_received_by = employee[0].get("name")
self.employee_user_id = employee[0].get("user_id")
employees = get_employees_with_number(self.get("to"))
if employees:
self.call_received_by = employees[0].get("name")
self.employee_user_id = employees[0].get("user_id")
def after_insert(self):
self.trigger_call_popup()