fix: Set avatar for users(agent/contact) in slack channels (#7960)

This commit is contained in:
Muhsin Keloth
2023-09-26 09:38:14 +05:30
committed by GitHub
parent 30cb141e5e
commit cbbe939662
4 changed files with 79 additions and 1 deletions

View File

@@ -0,0 +1,27 @@
class SlackUploadsController < ApplicationController
include Rails.application.routes.url_helpers
before_action :set_blob, only: [:show]
def show
if @blob
redirect_to blob_url
else
redirect_to avatar_url
end
end
private
def set_blob
@blob = ActiveStorage::Blob.find_by(key: params[:blob_key])
end
def blob_url
url_for(@blob.representation(resize_to_fill: [250, nil]))
end
def avatar_url
base_url = ENV.fetch('FRONTEND_URL', nil)
"#{base_url}/integrations/slack/#{params[:sender_type]}.png"
end
end