Fix updating a group's avatar and banner picture

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-11-20 18:44:55 +01:00
parent e8da59f4a5
commit 07a11d792c
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773

View file

@ -120,9 +120,11 @@ defmodule Mobilizon.GraphQL.Resolvers.Group do
with {:ok, %{name: name, url: url, content_type: content_type, size: _size}} <- with {:ok, %{name: name, url: url, content_type: content_type, size: _size}} <-
Upload.store(pic.file, type: key, description: pic.alt) do Upload.store(pic.file, type: key, description: pic.alt) do
Map.put(args, key, %{"name" => name, "url" => url, "mediaType" => content_type}) Logger.debug("Uploaded #{name} to #{url}")
Map.put(args, key, %{name: name, url: url, content_type: content_type})
end end
else else
Logger.debug("No picture upload")
args args
end end
end) end)
@ -200,12 +202,17 @@ defmodule Mobilizon.GraphQL.Resolvers.Group do
{:error, :file_too_large} -> {:error, :file_too_large} ->
{:error, dgettext("errors", "The provided picture is too heavy")} {:error, dgettext("errors", "The provided picture is too heavy")}
map when is_map(map) -> args when is_map(args) ->
case API.Groups.update_group(args) do case API.Groups.update_group(args) do
{:ok, _activity, %Actor{type: :Group} = group} -> {:ok, _activity, %Actor{type: :Group} = group} ->
{:ok, group} {:ok, group}
{:error, _err} -> {:error, %Ecto.Changeset{} = changeset} ->
{:error, changeset}
{:error, err} ->
Logger.info("Failed to update group #{inspect(group_id)}")
Logger.debug(inspect(err))
{:error, dgettext("errors", "Failed to update the group")} {:error, dgettext("errors", "Failed to update the group")}
end end
end end