removeing corresponding add activity
This commit is contained in:
parent
5ae9b05600
commit
8857242c95
4 changed files with 78 additions and 0 deletions
|
|
@ -391,4 +391,13 @@ defmodule Pleroma.Activity do
|
|||
end
|
||||
|
||||
def get_by_object_ap_id_with_object(_), do: nil
|
||||
|
||||
@spec add_by_params_query(String.t(), String.t(), String.t()) :: Ecto.Query.t()
|
||||
def add_by_params_query(object_id, actor, target) do
|
||||
object_id
|
||||
|> Queries.by_object_id()
|
||||
|> Queries.by_type("Add")
|
||||
|> Queries.by_actor(actor)
|
||||
|> where([a], fragment("?->>'target' = ?", a.data, ^target))
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -340,11 +340,16 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
|
|||
|
||||
# Tasks this handles:
|
||||
# - removes pin from user
|
||||
# - removes corresponding Add activity
|
||||
# - if activity had expiration, recreates activity expiration job
|
||||
@impl true
|
||||
def handle(%{data: %{"type" => "Remove"} = data} = object, meta) do
|
||||
with %User{} = user <- User.get_cached_by_ap_id(data["actor"]),
|
||||
{:ok, _user} <- User.remove_pinned_object_id(user, data["object"]) do
|
||||
data["object"]
|
||||
|> Activity.add_by_params_query(user.ap_id, user.featured_address)
|
||||
|> Repo.delete_all()
|
||||
|
||||
# if pinned activity was scheduled for deletion, we reschedule it for deletion
|
||||
if meta[:expires_at] do
|
||||
# MRF.ActivityExpirationPolicy used UTC timestamps for expires_at in original implementation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue