From ce782409c7e9cc72330b3821c4ac94519d1ccb04 Mon Sep 17 00:00:00 2001 From: Tanmay Deep Sharma Date: Mon, 4 May 2026 15:24:34 +0700 Subject: [PATCH] chore(voice): trim redundant comments on backend voice files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pass through pla-150 to drop comments that just describe what the next line already does: - whatsapp_calls_controller: removed the Twilio-comparison note (the ensure_calling_enabled body says it), the SDP-forwarding tagline, and tightened the 138006/transport-error/wamid blocks. - call.rb: dropped trivial annotations on STATUSES / TERMINAL_STATUSES; the names already say what they are. - send_on_channel_service: collapsed the two-line voice_call rationale into one — the surrounding context covers the rest. No behavior change. 33/33 enterprise call specs still pass; rubocop clean. --- app/services/base/send_on_channel_service.rb | 3 +-- .../api/v1/accounts/whatsapp_calls_controller.rb | 12 ++++-------- enterprise/app/models/call.rb | 2 -- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/app/services/base/send_on_channel_service.rb b/app/services/base/send_on_channel_service.rb index 1f48b607c..44380a179 100644 --- a/app/services/base/send_on_channel_service.rb +++ b/app/services/base/send_on_channel_service.rb @@ -46,8 +46,7 @@ class Base::SendOnChannelService def invalid_message? # private notes aren't send to the channels # we should also avoid the case of message loops, when outgoing messages are created from channel - # voice_call bubbles are call status indicators, not deliverable messages — skip the send pipeline - # otherwise it falls through to "Template not found" / 24-hour-window errors + # voice_call bubbles are call status indicators, not deliverable messages message.private? || outgoing_message_originated_from_channel? || message.content_type == 'voice_call' end diff --git a/enterprise/app/controllers/api/v1/accounts/whatsapp_calls_controller.rb b/enterprise/app/controllers/api/v1/accounts/whatsapp_calls_controller.rb index b83723f84..c1dbacecd 100644 --- a/enterprise/app/controllers/api/v1/accounts/whatsapp_calls_controller.rb +++ b/enterprise/app/controllers/api/v1/accounts/whatsapp_calls_controller.rb @@ -59,7 +59,6 @@ class Api::V1::Accounts::WhatsappCallsController < Api::V1::Accounts::BaseContro authorize @conversation, :show? end - # Twilio voice also exposes voice_enabled? but uses a different initiation path. def ensure_calling_enabled channel = @conversation.inbox.channel return if channel.is_a?(Channel::Whatsapp) && channel.voice_enabled? @@ -98,7 +97,6 @@ class Api::V1::Accounts::WhatsappCallsController < Api::V1::Accounts::BaseContro 'uploaded' end - # Browser-built SDP offer is forwarded to Meta; the connect webhook later delivers Meta's answer. def create_outbound_call contact_phone = @conversation.contact.phone_number.delete('+') result = provider_service.initiate_call(contact_phone, params[:sdp_offer]) @@ -112,9 +110,8 @@ class Api::V1::Accounts::WhatsappCallsController < Api::V1::Accounts::BaseContro ) end - # 138006 = no call permission yet; send opt-in template (throttled) and surface state to FE. - # Lock the conversation so concurrent initiate requests can't both pass the throttle gate - # and double-send the opt-in template. + # Meta error 138006 means the contact hasn't opted in yet; send the opt-in + # template (throttled, behind a conversation lock to prevent double-send). def render_permission_request status = nil @conversation.with_lock do @@ -142,8 +139,7 @@ class Api::V1::Accounts::WhatsappCallsController < Api::V1::Accounts::BaseContro last_requested.present? && Time.zone.parse(last_requested) > PERMISSION_REQUEST_THROTTLE.ago end - # Treat transport errors the same as a falsy provider return so the action renders 422 - # rather than letting Faraday/HTTParty exceptions bubble up as 500s. + # Treat transport errors as a falsy return so we render 422 rather than 500. def send_permission_request_safely provider_service.send_call_permission_request(@conversation.contact.phone_number.delete('+')) rescue StandardError => e @@ -151,7 +147,7 @@ class Api::V1::Accounts::WhatsappCallsController < Api::V1::Accounts::BaseContro nil end - # Record the wamid so the reply webhook can match context.id back to this conversation. + # Stash the outbound wamid so the reply webhook can match context.id back here. def record_permission_request_wamid(sent) attrs = (@conversation.additional_attributes || {}).merge( 'call_permission_requested_at' => Time.current.iso8601, diff --git a/enterprise/app/models/call.rb b/enterprise/app/models/call.rb index 51c7ef5e9..26b81fe3c 100644 --- a/enterprise/app/models/call.rb +++ b/enterprise/app/models/call.rb @@ -29,9 +29,7 @@ # index_calls_on_provider_and_provider_call_id (provider,provider_call_id) UNIQUE # class Call < ApplicationRecord - # All valid call statuses STATUSES = %w[ringing in_progress completed no_answer failed].freeze - # Statuses where the call is finished and won't change again TERMINAL_STATUSES = %w[completed no_answer failed].freeze store_accessor :meta, :conference_sid, :recording_sid, :parent_call_sid, :initiated_at, :ended_at