Merge branch 'features/private-reblogs' into 'develop'
Allow receiving private self-announces over ActivityPub See merge request pleroma/pleroma!1766
This commit is contained in:
commit
9b38bf4af4
9 changed files with 115 additions and 9 deletions
|
|
@ -125,8 +125,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
|
|||
end
|
||||
|
||||
@doc "POST /api/v1/statuses/:id/reblog"
|
||||
def reblog(%{assigns: %{user: user}} = conn, %{"id" => ap_id_or_id}) do
|
||||
with {:ok, announce, _activity} <- CommonAPI.repeat(ap_id_or_id, user),
|
||||
def reblog(%{assigns: %{user: user}} = conn, %{"id" => ap_id_or_id} = params) do
|
||||
with {:ok, announce, _activity} <- CommonAPI.repeat(ap_id_or_id, user, params),
|
||||
%Activity{} = announce <- Activity.normalize(announce.data) do
|
||||
try_render(conn, "show.json", %{activity: announce, for: user, as: :activity})
|
||||
end
|
||||
|
|
@ -242,7 +242,19 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
|
|||
def reblogged_by(%{assigns: %{user: user}} = conn, %{"id" => id}) do
|
||||
with %Activity{} = activity <- Activity.get_by_id_with_object(id),
|
||||
{:visible, true} <- {:visible, Visibility.visible_for_user?(activity, user)},
|
||||
%Object{data: %{"announcements" => announces}} <- Object.normalize(activity) do
|
||||
%Object{data: %{"announcements" => announces, "id" => ap_id}} <-
|
||||
Object.normalize(activity) do
|
||||
announces =
|
||||
"Announce"
|
||||
|> Activity.Queries.by_type()
|
||||
|> Ecto.Query.where([a], a.actor in ^announces)
|
||||
# this is to use the index
|
||||
|> Activity.Queries.by_object_id(ap_id)
|
||||
|> Repo.all()
|
||||
|> Enum.filter(&Visibility.visible_for_user?(&1, user))
|
||||
|> Enum.map(& &1.actor)
|
||||
|> Enum.uniq()
|
||||
|
||||
users =
|
||||
User
|
||||
|> Ecto.Query.where([u], u.ap_id in ^announces)
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
|||
pinned: pinned?(activity, user),
|
||||
sensitive: false,
|
||||
spoiler_text: "",
|
||||
visibility: "public",
|
||||
visibility: get_visibility(activity),
|
||||
media_attachments: reblogged[:media_attachments] || [],
|
||||
mentions: mentions,
|
||||
tags: reblogged[:tags] || [],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue