From 0c3e8b6dbdb5d44af7dacadc639a4ff95a56a302 Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Thu, 16 Sep 2021 16:51:06 +0530 Subject: [PATCH] chore: Return medium in inbox APIs (#3025) Return medium in inbox APIs --- app/builders/messages/facebook/message_builder.rb | 2 +- app/models/inbox.rb | 4 ++++ app/views/api/v1/models/_inbox.json.jbuilder | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/builders/messages/facebook/message_builder.rb b/app/builders/messages/facebook/message_builder.rb index 4ffb4b101..29579fd54 100644 --- a/app/builders/messages/facebook/message_builder.rb +++ b/app/builders/messages/facebook/message_builder.rb @@ -167,7 +167,7 @@ class Messages::Facebook::MessageBuilder result = {} # OAuthException, code: 100, error_subcode: 2018218, message: (#100) No profile available for this user # We don't need to capture this error as we don't care about contact params in case of echo messages - Sentry.capture_exception(e) unless outgoing_echo? + Sentry.capture_exception(e) unless @outgoing_echo rescue StandardError => e result = {} Sentry.capture_exception(e) diff --git a/app/models/inbox.rb b/app/models/inbox.rb index 437e7fd99..dbd64f820 100644 --- a/app/models/inbox.rb +++ b/app/models/inbox.rb @@ -83,6 +83,10 @@ class Inbox < ApplicationRecord channel_type == 'Channel::Email' end + def twilio? + channel_type == 'Channel::TwilioSms' + end + def inbox_type channel.name end diff --git a/app/views/api/v1/models/_inbox.json.jbuilder b/app/views/api/v1/models/_inbox.json.jbuilder index 20e1ca36c..5c25cedd0 100644 --- a/app/views/api/v1/models/_inbox.json.jbuilder +++ b/app/views/api/v1/models/_inbox.json.jbuilder @@ -38,6 +38,7 @@ json.reauthorization_required resource.channel.try(:reauthorization_required?) i ## Twilio Attributes json.phone_number resource.channel.try(:phone_number) +json.medium resource.channel.try(:medium) if resource.twilio? ## Email Channel Attributes json.forward_to_email resource.channel.try(:forward_to_email)