chore: Add a check for defined labels in SDK API (#1259)

This commit is contained in:
Pranav Raj S
2020-09-20 19:29:39 +05:30
committed by GitHub
parent cdd428f503
commit 0deb1af852
2 changed files with 24 additions and 3 deletions

View File

@@ -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