Changeset View
Changeset View
Standalone View
Standalone View
lib/lsg_telegram/room.ex
Context not available. | |||||
@impl Telegram.ChatBot | @impl Telegram.ChatBot | ||||
def init(id) when is_integer(id) and id < 0 do | def init(id) when is_integer(id) and id < 0 do | ||||
token = Keyword.get(Application.get_env(:lsg, :telegram, []), :key) | token = Keyword.get(Application.get_env(:nola, :telegram, []), :key) | ||||
{:ok, chat} = Api.request(token, "getChat", chat_id: id) | {:ok, chat} = Api.request(token, "getChat", chat_id: id) | ||||
Logger.metadata(transport: :telegram, id: id, telegram_room_id: id) | Logger.metadata(transport: :telegram, id: id, telegram_room_id: id) | ||||
tg_room = case room(id) do | tg_room = case room(id) do | ||||
Context not available. | |||||
{:ok, %HTTPoison.Response{status_code: 200, body: body}} <- HTTPoison.get(path), | {:ok, %HTTPoison.Response{status_code: 200, body: body}} <- HTTPoison.get(path), | ||||
<<smol_body::binary-size(20), _::binary>> = body, | <<smol_body::binary-size(20), _::binary>> = body, | ||||
{:ok, magic} <- GenMagic.Pool.perform(Nola.GenMagic, {:bytes, smol_body}), | {:ok, magic} <- GenMagic.Pool.perform(Nola.GenMagic, {:bytes, smol_body}), | ||||
bucket = Application.get_env(:lsg, :s3, []) |> Keyword.get(:bucket), | bucket = Application.get_env(:nola, :s3, []) |> Keyword.get(:bucket), | ||||
ext = Path.extname(file["file_path"]), | ext = Path.extname(file["file_path"]), | ||||
s3path = "#{account.id}/#{file_unique_id}#{ext}", | s3path = "#{account.id}/#{file_unique_id}#{ext}", | ||||
s3req = ExAws.S3.put_object(bucket, s3path, body, acl: :public_read, content_type: magic.mime_type), | s3req = ExAws.S3.put_object(bucket, s3path, body, acl: :public_read, content_type: magic.mime_type), | ||||
Context not available. |