fix(app-store): simplify inbox creation controller
This commit is contained in:
@@ -31,8 +31,6 @@ class Api::V1::Accounts::InboxesController < Api::V1::Accounts::BaseController
|
||||
end
|
||||
|
||||
def create
|
||||
return render_app_store_feature_disabled if app_store_channel_requested? && !Current.account.feature_enabled?(:channel_app_store)
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
channel = create_channel
|
||||
@inbox = Current.account.inboxes.build(
|
||||
@@ -102,14 +100,6 @@ class Api::V1::Accounts::InboxesController < Api::V1::Accounts::BaseController
|
||||
%w[web_widget api email line telegram whatsapp sms app_store]
|
||||
end
|
||||
|
||||
def app_store_channel_requested?
|
||||
permitted_params.dig(:channel, :type) == 'app_store'
|
||||
end
|
||||
|
||||
def render_app_store_feature_disabled
|
||||
render json: { message: 'App Store Reviews channel is not enabled for this account' }, status: :forbidden
|
||||
end
|
||||
|
||||
def update_inbox_working_hours
|
||||
@inbox.update_working_hours(params.permit(working_hours: Inbox::OFFISABLE_ATTRS)[:working_hours]) if params[:working_hours]
|
||||
end
|
||||
|
||||
@@ -434,18 +434,6 @@ RSpec.describe 'Inboxes API', type: :request do
|
||||
expect(response.body).to include('+123456789')
|
||||
end
|
||||
|
||||
it 'does not create an app store inbox when the feature is disabled' do
|
||||
post "/api/v1/accounts/#{account.id}/inboxes",
|
||||
headers: admin.create_new_auth_token,
|
||||
params: { name: 'App Store Reviews',
|
||||
channel: { type: 'app_store', app_id: '123456789', issuer_id: SecureRandom.uuid, key_id: 'KEY123',
|
||||
private_key: OpenSSL::PKey::EC.generate('prime256v1').to_pem } },
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:forbidden)
|
||||
expect(response.parsed_body['message']).to eq('App Store Reviews channel is not enabled for this account')
|
||||
end
|
||||
|
||||
it 'creates an app store inbox when the feature is enabled' do
|
||||
app_store_client = instance_double(AppStoreConnect::Client)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user