diff --git a/crm/fcrm/doctype/twilio_settings/twilio_settings.py b/crm/fcrm/doctype/twilio_settings/twilio_settings.py index 06038f1a..1d3a20b6 100644 --- a/crm/fcrm/doctype/twilio_settings/twilio_settings.py +++ b/crm/fcrm/doctype/twilio_settings/twilio_settings.py @@ -62,7 +62,7 @@ class TwilioSettings(Document): frappe.throw(_("Twilio API credential creation error.")) def get_twilio_voice_url(self): - url_path = "/api/method/crm.twilio.api.voice" + url_path = "/api/method/crm.integrations.twilio.api.voice" return get_public_url(url_path) def get_application(self, twilio, friendly_name=None): diff --git a/crm/twilio/api.py b/crm/integrations/twilio/api.py similarity index 100% rename from crm/twilio/api.py rename to crm/integrations/twilio/api.py diff --git a/crm/twilio/twilio_handler.py b/crm/integrations/twilio/twilio_handler.py similarity index 92% rename from crm/twilio/twilio_handler.py rename to crm/integrations/twilio/twilio_handler.py index aadbdaa6..30eba885 100644 --- a/crm/twilio/twilio_handler.py +++ b/crm/integrations/twilio/twilio_handler.py @@ -69,11 +69,11 @@ class Twilio: return identity.replace('(at)', '@') def get_recording_status_callback_url(self): - url_path = "/api/method/crm.twilio.api.update_recording_info" + url_path = "/api/method/crm.integrations.twilio.api.update_recording_info" return get_public_url(url_path) def get_update_call_status_callback_url(self): - url_path = "/api/method/crm.twilio.api.update_call_status_info" + url_path = "/api/method/crm.integrations.twilio.api.update_call_status_info" return get_public_url(url_path) def generate_twilio_dial_response(self, from_number: str, to_number: str): @@ -141,7 +141,7 @@ class IncomingCall: """ twilio = Twilio.connect() owners = get_twilio_number_owners(self.to_number) - attender = get_the_call_attender(owners) + attender = get_the_call_attender(owners, self.from_number) if not attender: resp = VoiceResponse() @@ -190,11 +190,20 @@ def get_active_loggedin_users(users): """, {'users': users}) return [row[0] for row in set(rows)] -def get_the_call_attender(owners): +def get_the_call_attender(owners, caller=None): """Get attender details from list of owners """ if not owners: return current_loggedin_users = get_active_loggedin_users(list(owners.keys())) + + if len(current_loggedin_users) > 1 and caller: + deal_owner = frappe.db.get_value('CRM Deal', {'mobile_no': caller}, 'deal_owner') + if not deal_owner: + deal_owner = frappe.db.get_value('CRM Lead', {'mobile_no': caller}, 'lead_owner') + for user in current_loggedin_users: + if user == deal_owner: + current_loggedin_users = [user] + for name, details in owners.items(): if ((details['call_receiving_device'] == 'Phone' and details['mobile_no']) or (details['call_receiving_device'] == 'Computer' and name in current_loggedin_users)): @@ -244,7 +253,7 @@ class TwilioCallDetails: caller = Twilio.emailid_from_identity(identity) if identity else '' else: owners = get_twilio_number_owners(to_number) - attender = get_the_call_attender(owners) + attender = get_the_call_attender(owners, from_number) receiver = attender['name'] if attender else '' return { diff --git a/crm/twilio/utils.py b/crm/integrations/twilio/utils.py similarity index 100% rename from crm/twilio/utils.py rename to crm/integrations/twilio/utils.py diff --git a/frontend/package.json b/frontend/package.json index 37330add..297a4ca6 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -9,7 +9,7 @@ "serve": "vite preview" }, "dependencies": { - "@twilio/voice-sdk": "^2.7.1", + "@twilio/voice-sdk": "^2.10.2", "@vueuse/core": "^10.3.0", "@vueuse/integrations": "^10.3.0", "feather-icons": "^4.28.0", diff --git a/frontend/src/components/CallUI.vue b/frontend/src/components/CallUI.vue index 3a9e4fcd..47b5af55 100644 --- a/frontend/src/components/CallUI.vue +++ b/frontend/src/components/CallUI.vue @@ -2,7 +2,7 @@