lint and credo
This commit is contained in:
parent
b3887a6fa7
commit
a4e480a636
3 changed files with 16 additions and 8 deletions
|
|
@ -483,7 +483,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp validate_visibility(%User{} = user, %{"type" => type, "object" => object} = activity) do
|
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
|
{_, true} <- {:visibility, Visibility.visible_for_user?(normalized_object, user)} do
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -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,
|
# 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.
|
# 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
|
# We allow replying to Announce here, due to a Pleroma-FE quirk where if presented with
|
||||||
# it will render it as if it was just the normal referenced post, but use the Announce id for replies
|
# an Announce id it will render it as if it was just the normal referenced post, but
|
||||||
# in the in_reply_to_id key of a POST request to /api/v1/statuses, or as an :id in /api/v1/statuses/:id/*.
|
# 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
|
# TODO: Fix this quirk in FE and remove here and other affected places
|
||||||
with %Activity{} = activity <- Activity.get_by_id(id),
|
with %Activity{} = activity <- Activity.get_by_id(id),
|
||||||
true <- Visibility.visible_for_user?(activity, draft.user),
|
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"))
|
add_error(draft, dgettext("errors", "Replying to a status that is not visibile to user"))
|
||||||
|
|
||||||
{:type, type} ->
|
{:type, type} ->
|
||||||
add_error(draft, dgettext("errors", "Can only reply to posts, not %{type} activities",
|
add_error(
|
||||||
type: inspect(type)))
|
draft,
|
||||||
|
dgettext("errors", "Can only reply to posts, not %{type} activities",
|
||||||
|
type: inspect(type)
|
||||||
|
)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -291,7 +291,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "replying to own DM succeeds", %{user: user, conn: conn} do
|
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)
|
stranger = insert(:user)
|
||||||
|
|
||||||
{:ok, %{id: dm_id} = dm_post_act} =
|
{:ok, %{id: dm_id} = dm_post_act} =
|
||||||
|
|
@ -1546,7 +1547,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
||||||
|
|
||||||
assert match?(%{"error" => _}, resp1)
|
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 =
|
resp2 =
|
||||||
build_conn()
|
build_conn()
|
||||||
|> assign(:user, user)
|
|> assign(:user, user)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue