Upload pictures fixes
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
2749989a28
commit
d609ccfb51
|
@ -22,7 +22,8 @@ defmodule MobilizonWeb.API.Events do
|
||||||
category: category
|
category: category
|
||||||
} = args
|
} = args
|
||||||
) do
|
) do
|
||||||
with %Actor{url: url} = actor <- Actors.get_local_actor_with_everything(organizer_actor_id),
|
with %Actor{url: url} = actor <-
|
||||||
|
Actors.get_local_actor_with_everything(organizer_actor_id),
|
||||||
title <- String.trim(title),
|
title <- String.trim(title),
|
||||||
mentions <- Formatter.parse_mentions(description),
|
mentions <- Formatter.parse_mentions(description),
|
||||||
visibility <- Map.get(args, :visibility, "public"),
|
visibility <- Map.get(args, :visibility, "public"),
|
||||||
|
|
|
@ -217,8 +217,13 @@ defmodule MobilizonWeb.Resolvers.Event do
|
||||||
|
|
||||||
# If we have an attached picture, just transmit it. It will be handled by
|
# If we have an attached picture, just transmit it. It will be handled by
|
||||||
# Mobilizon.Service.ActivityPub.Utils.make_picture_data/1
|
# Mobilizon.Service.ActivityPub.Utils.make_picture_data/1
|
||||||
|
# However, we need to pass it's actor ID
|
||||||
@spec save_attached_picture(map()) :: {:ok, map()}
|
@spec save_attached_picture(map()) :: {:ok, map()}
|
||||||
defp save_attached_picture(%{picture: %{picture: %Plug.Upload{} = _picture}} = args), do: args
|
defp save_attached_picture(
|
||||||
|
%{picture: %{picture: %{file: %Plug.Upload{} = _picture} = all_pic}} = args
|
||||||
|
) do
|
||||||
|
{:ok, Map.put(args, :picture, Map.put(all_pic, :actor_id, args.organizer_actor_id))}
|
||||||
|
end
|
||||||
|
|
||||||
# Otherwise if we use a previously uploaded picture we need to fetch it from database
|
# Otherwise if we use a previously uploaded picture we need to fetch it from database
|
||||||
@spec save_attached_picture(map()) :: {:ok, map()}
|
@spec save_attached_picture(map()) :: {:ok, map()}
|
||||||
|
|
|
@ -208,7 +208,7 @@ defmodule Mobilizon.Service.ActivityPub.Utils do
|
||||||
@doc """
|
@doc """
|
||||||
Save picture data from raw data and return AS Link data.
|
Save picture data from raw data and return AS Link data.
|
||||||
"""
|
"""
|
||||||
def make_picture_data(%{picture: picture}) do
|
def make_picture_data(picture) when is_map(picture) do
|
||||||
with {:ok, %{"url" => [%{"href" => url, "mediaType" => content_type}], "size" => size}} <-
|
with {:ok, %{"url" => [%{"href" => url, "mediaType" => content_type}], "size" => size}} <-
|
||||||
MobilizonWeb.Upload.store(picture.file),
|
MobilizonWeb.Upload.store(picture.file),
|
||||||
{:ok, %Picture{file: _file} = pic} <-
|
{:ok, %Picture{file: _file} = pic} <-
|
||||||
|
|
Loading…
Reference in a new issue