diff --git a/app/controllers/api/v1/accounts/portals_controller.rb b/app/controllers/api/v1/accounts/portals_controller.rb
index 18538e842..af96441f8 100644
--- a/app/controllers/api/v1/accounts/portals_controller.rb
+++ b/app/controllers/api/v1/accounts/portals_controller.rb
@@ -26,9 +26,8 @@ class Api::V1::Accounts::PortalsController < Api::V1::Accounts::BaseController
@portal.update!(portal_params.merge(live_chat_widget_params)) if params[:portal].present?
# @portal.custom_domain = parsed_custom_domain
process_attached_logo if params[:blob_id].present?
- rescue StandardError => e
- Rails.logger.error e
- render json: { error: @portal.errors.messages }.to_json, status: :unprocessable_entity
+ rescue ActiveRecord::RecordInvalid => e
+ render_record_invalid(e)
end
end
diff --git a/app/controllers/api/v1/accounts/whatsapp/authorizations_controller.rb b/app/controllers/api/v1/accounts/whatsapp/authorizations_controller.rb
index e7a1f3fa6..3e7d876c3 100644
--- a/app/controllers/api/v1/accounts/whatsapp/authorizations_controller.rb
+++ b/app/controllers/api/v1/accounts/whatsapp/authorizations_controller.rb
@@ -1,8 +1,10 @@
class Api::V1::Accounts::Whatsapp::AuthorizationsController < Api::V1::Accounts::BaseController
before_action :validate_feature_enabled!
+ before_action :fetch_and_validate_inbox, if: -> { params[:inbox_id].present? }
# POST /api/v1/accounts/:account_id/whatsapp/authorization
- # Handles the embedded signup callback data from the Facebook SDK
+ # Handles both initial authorization and reauthorization
+ # If inbox_id is present in params, it performs reauthorization
def create
validate_embedded_signup_params!
channel = process_embedded_signup
@@ -16,21 +18,42 @@ class Api::V1::Accounts::Whatsapp::AuthorizationsController < Api::V1::Accounts:
def process_embedded_signup
service = Whatsapp::EmbeddedSignupService.new(
account: Current.account,
- code: params[:code],
- business_id: params[:business_id],
- waba_id: params[:waba_id],
- phone_number_id: params[:phone_number_id]
+ params: params.permit(:code, :business_id, :waba_id, :phone_number_id).to_h.symbolize_keys,
+ inbox_id: params[:inbox_id]
)
service.perform
end
- def render_success_response(inbox)
+ def fetch_and_validate_inbox
+ @inbox = Current.account.inboxes.find(params[:inbox_id])
+ validate_reauthorization_required
+ end
+
+ def validate_reauthorization_required
+ return if @inbox.channel.reauthorization_required? || can_upgrade_to_embedded_signup?
+
render json: {
+ success: false,
+ message: I18n.t('inbox.reauthorization.not_required')
+ }, status: :unprocessable_entity
+ end
+
+ def can_upgrade_to_embedded_signup?
+ channel = @inbox.channel
+ return false unless channel.provider == 'whatsapp_cloud'
+
+ true
+ end
+
+ def render_success_response(inbox)
+ response = {
success: true,
id: inbox.id,
name: inbox.name,
channel_type: 'whatsapp'
}
+ response[:message] = I18n.t('inbox.reauthorization.success') if params[:inbox_id].present?
+ render json: response
end
def render_error_response(error)
diff --git a/app/controllers/platform/api/v1/accounts_controller.rb b/app/controllers/platform/api/v1/accounts_controller.rb
index e11cf9d4a..4521930a6 100644
--- a/app/controllers/platform/api/v1/accounts_controller.rb
+++ b/app/controllers/platform/api/v1/accounts_controller.rb
@@ -1,4 +1,11 @@
class Platform::Api::V1::AccountsController < PlatformController
+ def index
+ @resources = @platform_app.platform_app_permissibles
+ .where(permissible_type: 'Account')
+ .includes(:permissible)
+ .map(&:permissible)
+ end
+
def show; end
def create
diff --git a/app/controllers/slack_uploads_controller.rb b/app/controllers/slack_uploads_controller.rb
index 127e77649..6f157c7d5 100644
--- a/app/controllers/slack_uploads_controller.rb
+++ b/app/controllers/slack_uploads_controller.rb
@@ -17,7 +17,12 @@ class SlackUploadsController < ApplicationController
end
def blob_url
- url_for(@blob.representation(resize_to_fill: [250, nil]))
+ # Only generate representations for images
+ if @blob.content_type.start_with?('image/')
+ url_for(@blob.representation(resize_to_fill: [250, nil]))
+ else
+ url_for(@blob)
+ end
end
def avatar_url
diff --git a/app/controllers/twilio/callback_controller.rb b/app/controllers/twilio/callback_controller.rb
index 455828228..d607ba151 100644
--- a/app/controllers/twilio/callback_controller.rb
+++ b/app/controllers/twilio/callback_controller.rb
@@ -30,7 +30,8 @@ class Twilio::CallbackController < ApplicationController
:NumMedia,
:Latitude,
:Longitude,
- :MessageType
+ :MessageType,
+ :ProfileName
)
end
end
diff --git a/app/finders/notification_finder.rb b/app/finders/notification_finder.rb
index ccfe470a0..e1958827a 100644
--- a/app/finders/notification_finder.rb
+++ b/app/finders/notification_finder.rb
@@ -15,7 +15,13 @@ class NotificationFinder
end
def unread_count
- @notifications.where(read_at: nil).count
+ if type_included?('read')
+ # If we're including read notifications, filter to unread
+ @notifications.where(read_at: nil).count
+ else
+ # Already filtered to unread notifications, just count
+ @notifications.count
+ end
end
def count
@@ -27,7 +33,7 @@ class NotificationFinder
def set_up
find_all_notifications
filter_snoozed_notifications
- fitler_read_notifications
+ filter_read_notifications
end
def find_all_notifications
@@ -38,7 +44,7 @@ class NotificationFinder
@notifications = @notifications.where(snoozed_until: nil) unless type_included?('snoozed')
end
- def fitler_read_notifications
+ def filter_read_notifications
@notifications = @notifications.where(read_at: nil) unless type_included?('read')
end
diff --git a/app/javascript/dashboard/App.vue b/app/javascript/dashboard/App.vue
index 0fbb20ea9..8da7e7476 100644
--- a/app/javascript/dashboard/App.vue
+++ b/app/javascript/dashboard/App.vue
@@ -137,7 +137,6 @@ export default {
v-if="!authUIFlags.isFetching && !accountUIFlags.isFetchingItem"
id="app"
class="flex flex-col w-full h-screen min-h-0"
- :class="{ 'app-rtl--wrapper': isRTL }"
:dir="isRTL ? 'rtl' : 'ltr'"
>
- {{ t(`CAMPAIGN.WHATSAPP.CREATE.TITLE`) }}
-
-
+ {{ t(`CAMPAIGN.WHATSAPP.CREATE.TITLE`) }}
+
+