chore: Add a check for defined labels in SDK API (#1259)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
class Api::V1::Widget::LabelsController < Api::V1::Widget::BaseController
|
||||
def create
|
||||
if conversation.present?
|
||||
if conversation.present? && label_defined_in_account?
|
||||
conversation.label_list.add(permitted_params[:label])
|
||||
conversation.save!
|
||||
end
|
||||
@@ -19,6 +19,11 @@ class Api::V1::Widget::LabelsController < Api::V1::Widget::BaseController
|
||||
|
||||
private
|
||||
|
||||
def label_defined_in_account?
|
||||
label = @account.labels.find_by(title: permitted_params[:label])
|
||||
label.present?
|
||||
end
|
||||
|
||||
def permitted_params
|
||||
params.permit(:id, :label, :website_token)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user