diff --git a/lib/pleroma/upload.ex b/lib/pleroma/upload.ex index 11b18cd4e..75aaac020 100644 --- a/lib/pleroma/upload.ex +++ b/lib/pleroma/upload.ex @@ -34,10 +34,10 @@ defmodule Pleroma.Upload do """ alias Ecto.UUID - alias Pleroma.Repo - alias Pleroma.Object alias Pleroma.Maps + alias Pleroma.Object alias Pleroma.Pagination + alias Pleroma.Repo alias Pleroma.Utils.URIEncoding alias Pleroma.Web.ActivityPub.Utils @@ -326,11 +326,13 @@ defmodule Pleroma.Upload do # Ugly as sin, but I could not figure out a better way to do this in ecto # This tries to find any objects with this attachment - # This DOES NOT handle chat messages and SKIPS them, because they have attachments as an object instead of an array + # This DOES NOT handle chat messages and SKIPS them, + # because they have attachments as an object instead of an array Repo.query!( """ SELECT * FROM - (SELECT objects.data->>'id' AS id, jsonb_array_elements(objects.data->'attachment') as json_attachments FROM objects WHERE jsonb_typeof(objects.data->'attachment') = 'array') + (SELECT objects.data->>'id' AS id, jsonb_array_elements(objects.data->'attachment') as json_attachments FROM objects + WHERE jsonb_typeof(objects.data->'attachment') = 'array') WHERE STARTS_WITH(json_attachments->'url'->0->>'href', $1) """, [clean_href] @@ -343,7 +345,10 @@ defmodule Pleroma.Upload do where: fragment("(?)->>'type' = ?", obj.data, "Document") and fragment("(?)->>'actor' = ?", obj.data, ^user.ap_id), - order_by: [desc: obj.id], limit: ^limit, offset: ^offset - ) |> Repo.all() + order_by: [desc: obj.id], + limit: ^limit, + offset: ^offset + ) + |> Repo.all() end end diff --git a/lib/pleroma/web/api_spec/operations/pleroma_util_operation.ex b/lib/pleroma/web/api_spec/operations/pleroma_util_operation.ex index e19268c4b..04a73861d 100644 --- a/lib/pleroma/web/api_spec/operations/pleroma_util_operation.ex +++ b/lib/pleroma/web/api_spec/operations/pleroma_util_operation.ex @@ -6,8 +6,8 @@ defmodule Pleroma.Web.ApiSpec.PleromaUtilOperation do alias OpenApiSpex.Operation alias OpenApiSpex.Schema alias Pleroma.Web.ApiSpec.Schemas.ApiError - alias Pleroma.Web.ApiSpec.Schemas.BooleanLike alias Pleroma.Web.ApiSpec.Schemas.Attachment + alias Pleroma.Web.ApiSpec.Schemas.BooleanLike import Pleroma.Web.ApiSpec.Helpers diff --git a/lib/pleroma/web/mastodon_api/controllers/media_controller.ex b/lib/pleroma/web/mastodon_api/controllers/media_controller.ex index 76c68e9bb..bd273fbc2 100644 --- a/lib/pleroma/web/mastodon_api/controllers/media_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/media_controller.ex @@ -6,8 +6,8 @@ defmodule Pleroma.Web.MastodonAPI.MediaController do use Pleroma.Web, :controller alias Pleroma.Object - alias Pleroma.User alias Pleroma.Repo + alias Pleroma.User alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.Plugs.OAuthScopesPlug diff --git a/lib/pleroma/web/pleroma_api/controllers/util_controller.ex b/lib/pleroma/web/pleroma_api/controllers/util_controller.ex index 4ec9e92e7..a81ab4536 100644 --- a/lib/pleroma/web/pleroma_api/controllers/util_controller.ex +++ b/lib/pleroma/web/pleroma_api/controllers/util_controller.ex @@ -10,8 +10,8 @@ defmodule Pleroma.Web.PleromaAPI.UtilController do alias Pleroma.Config alias Pleroma.Emoji alias Pleroma.Healthcheck - alias Pleroma.User alias Pleroma.Pagination + alias Pleroma.User alias Pleroma.Utils.URIEncoding alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.Auth.WrapperAuthenticator, as: Authenticator @@ -285,7 +285,7 @@ defmodule Pleroma.Web.PleromaAPI.UtilController do Pleroma.Upload.list_uploaded_by(user, offset, 50) |> Enum.map(fn %Pleroma.Object{ id: id, - data: %{"url" => [mediaUrl], "name" => name}, + data: %{"url" => [media_url], "name" => name}, inserted_at: uploaded } -> %{ @@ -293,8 +293,8 @@ defmodule Pleroma.Web.PleromaAPI.UtilController do attachment: %{ description: name, id: to_string(id), - url: mediaUrl["href"], - pleroma: %{mime_type: mediaUrl["mediaType"]}, + url: media_url["href"], + pleroma: %{mime_type: media_url["mediaType"]}, type: "unknown" } }