mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-10 19:29:11 +00:00
Fix private post card handling.
This commit is contained in:
parent
5a4e2905fe
commit
62296f5a25
3 changed files with 15 additions and 3 deletions
|
@ -943,7 +943,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
|
||||
def visible_for_user?(activity, user) do
|
||||
x = [user.ap_id | user.following]
|
||||
y = activity.data["to"] ++ (activity.data["cc"] || [])
|
||||
y = [activity.actor] ++ activity.data["to"] ++ (activity.data["cc"] || [])
|
||||
visible_for_user?(activity, nil) || Enum.any?(x, &(&1 in y))
|
||||
end
|
||||
|
||||
|
|
|
@ -1518,9 +1518,9 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||
end
|
||||
end
|
||||
|
||||
def status_card(conn, %{"id" => status_id}) do
|
||||
def status_card(%{assigns: %{user: user}} = conn, %{"id" => status_id}) do
|
||||
with %Activity{} = activity <- Repo.get(Activity, status_id),
|
||||
true <- ActivityPub.is_public?(activity) do
|
||||
true <- ActivityPub.visible_for_user?(activity, user) do
|
||||
data =
|
||||
StatusView.render(
|
||||
"card.json",
|
||||
|
|
|
@ -1744,6 +1744,18 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
}
|
||||
}
|
||||
|
||||
# works with private posts
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{"status" => "http://example.com/ogp", "visibility" => "direct"})
|
||||
|
||||
response_two =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> get("/api/v1/statuses/#{activity.id}/card")
|
||||
|> json_response(200)
|
||||
|
||||
assert response_two == response
|
||||
|
||||
Pleroma.Config.put([:rich_media, :enabled], false)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue