Chatwoot/app/controllers/api/v1/accounts/labels_controller.rb

35 lines
690 B
Ruby
Raw Normal View History

class Api::V1::Accounts::LabelsController < Api::V1::Accounts::BaseController
2020-06-07 05:47:13 +00:00
before_action :current_account
before_action :fetch_label, except: [:index, :create]
before_action :check_authorization
def index
@labels = policy_scope(Current.account.labels)
2020-06-07 05:47:13 +00:00
end
def show; end
def create
@label = Current.account.labels.create!(permitted_params)
2020-06-07 05:47:13 +00:00
end
def update
@label.update!(permitted_params)
2020-06-07 05:47:13 +00:00
end
def destroy
@label.destroy!
2020-06-07 05:47:13 +00:00
head :ok
end
private
def fetch_label
@label = Current.account.labels.find(params[:id])
2020-06-07 05:47:13 +00:00
end
def permitted_params
params.require(:label).permit(:title, :description, :color, :show_on_sidebar)
end
end