chore: Adds API for agent bot avatar upload (#8533)
Adds API for agent bot avatar upload - accounts/agent_bot - platform/agent_bot
This commit is contained in:
@@ -9,13 +9,15 @@ class Platform::Api::V1::AgentBotsController < PlatformController
|
||||
def show; end
|
||||
|
||||
def create
|
||||
@resource = AgentBot.new(agent_bot_params)
|
||||
@resource = AgentBot.new(agent_bot_params.except(:avatar_url))
|
||||
@resource.save!
|
||||
process_avatar_from_url
|
||||
@platform_app.platform_app_permissibles.find_or_create_by(permissible: @resource)
|
||||
end
|
||||
|
||||
def update
|
||||
@resource.update!(agent_bot_params)
|
||||
@resource.update!(agent_bot_params.except(:avatar_url))
|
||||
process_avatar_from_url
|
||||
end
|
||||
|
||||
def destroy
|
||||
@@ -23,6 +25,11 @@ class Platform::Api::V1::AgentBotsController < PlatformController
|
||||
head :ok
|
||||
end
|
||||
|
||||
def avatar
|
||||
@resource.avatar.purge if @resource.avatar.attached?
|
||||
@resource
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_resource
|
||||
@@ -30,6 +37,10 @@ class Platform::Api::V1::AgentBotsController < PlatformController
|
||||
end
|
||||
|
||||
def agent_bot_params
|
||||
params.permit(:name, :description, :account_id, :outgoing_url)
|
||||
params.permit(:name, :description, :account_id, :outgoing_url, :avatar, :avatar_url)
|
||||
end
|
||||
|
||||
def process_avatar_from_url
|
||||
::Avatar::AvatarFromUrlJob.perform_later(@resource, params[:avatar_url]) if params[:avatar_url].present?
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user