commit: a4e480a6368e20e26293fa88205b63d8e3bb837e parent b3887a6fa775bda1f51efab4774cba838ad0db91 Author: Phantasm <phantasm@centrum.cz> Date: Wed, 3 Dec 2025 00:06:32 +0100 lint and credoDiffstat:
3 files changed, 16 insertions(+), 8 deletions(-)diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex@@ -483,7 +483,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do end defp validate_visibility(%User{} = user, %{"type" => type, "object" => object} = activity) do - with {_, %Object{} = normalized_object} <- {:normalize, Object.normalize(object, fetch: false)}, + with {_, %Object{} = normalized_object} <- + {:normalize, Object.normalize(object, fetch: false)}, {_, true} <- {:visibility, Visibility.visible_for_user?(normalized_object, user)} do {:ok, activity} elsediff --git a/lib/pleroma/web/common_api/activity_draft.ex b/lib/pleroma/web/common_api/activity_draft.ex@@ -140,9 +140,10 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do # If a post was deleted all its activities (except the newly added Delete) are purged too, # thus lookup by Create db ID will yield nil just as if it never existed in the first place. # - # We allow replying to Announce here, due to a Pleroma-FE quirk where if presented with an Announce id - # it will render it as if it was just the normal referenced post, but use the Announce id for replies - # in the in_reply_to_id key of a POST request to /api/v1/statuses, or as an :id in /api/v1/statuses/:id/*. + # We allow replying to Announce here, due to a Pleroma-FE quirk where if presented with + # an Announce id it will render it as if it was just the normal referenced post, but + # use the Announce id for replies in the in_reply_to_id key of a POST request to + # /api/v1/statuses, or as an :id in /api/v1/statuses/:id/*. # TODO: Fix this quirk in FE and remove here and other affected places with %Activity{} = activity <- Activity.get_by_id(id), true <- Visibility.visible_for_user?(activity, draft.user), @@ -156,8 +157,12 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do add_error(draft, dgettext("errors", "Replying to a status that is not visibile to user")) {:type, type} -> - add_error(draft, dgettext("errors", "Can only reply to posts, not %{type} activities", - type: inspect(type))) + add_error( + draft, + dgettext("errors", "Can only reply to posts, not %{type} activities", + type: inspect(type) + ) + ) end enddiff --git a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs@@ -291,7 +291,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do end test "replying to own DM succeeds", %{user: user, conn: conn} do - # this is an "edge" case for visibility: replying user is not part of addressed users (but is the author) + # this is an "edge" case for visibility: replying user is not + # part of addressed users (but is the author) stranger = insert(:user) {:ok, %{id: dm_id} = dm_post_act} = @@ -1546,7 +1547,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do assert match?(%{"error" => _}, resp1) - # unreblog by reblog ID (reblog IDs are accepted by some APIs; ensure it fails here one way or another) + # unreblog by reblog ID (reblog IDs are accepted by some APIs; + # ensure it fails here one way or another) resp2 = build_conn() |> assign(:user, user)