Chore: Code Cleanup in API controllers (#932)
* Chore: Code Cleanup in API controllers * Remove unnecessary scoping for accounts controller
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
class Api::V1::Accounts::InboxesController < Api::BaseController
|
||||
before_action :current_account
|
||||
class Api::V1::Accounts::InboxesController < Api::V1::Accounts::BaseController
|
||||
before_action :fetch_inbox, except: [:index, :create]
|
||||
before_action :fetch_agent_bot, only: [:set_agent_bot]
|
||||
before_action :check_authorization
|
||||
|
||||
def index
|
||||
@inboxes = policy_scope(current_account.inboxes)
|
||||
@inboxes = policy_scope(Current.account.inboxes)
|
||||
end
|
||||
|
||||
def create
|
||||
ActiveRecord::Base.transaction do
|
||||
channel = web_widgets.create!(permitted_params[:channel].except(:type)) if permitted_params[:channel][:type] == 'web_widget'
|
||||
@inbox = current_account.inboxes.build(name: permitted_params[:name], channel: channel)
|
||||
@inbox = Current.account.inboxes.build(name: permitted_params[:name], channel: channel)
|
||||
@inbox.avatar.attach(permitted_params[:avatar])
|
||||
@inbox.save!
|
||||
end
|
||||
@@ -41,7 +40,7 @@ class Api::V1::Accounts::InboxesController < Api::BaseController
|
||||
private
|
||||
|
||||
def fetch_inbox
|
||||
@inbox = current_account.inboxes.find(params[:id])
|
||||
@inbox = Current.account.inboxes.find(params[:id])
|
||||
end
|
||||
|
||||
def fetch_agent_bot
|
||||
@@ -49,7 +48,7 @@ class Api::V1::Accounts::InboxesController < Api::BaseController
|
||||
end
|
||||
|
||||
def web_widgets
|
||||
current_account.web_widgets
|
||||
Current.account.web_widgets
|
||||
end
|
||||
|
||||
def check_authorization
|
||||
|
||||
Reference in New Issue
Block a user