X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Factivity_pub%2Factivity_pub.ex;h=146888c98eab2ea68ea866f32ad419cf5c5f7033;hb=5db535c0b10c27a487b12d5dcc0c015b91753fed;hp=fbe259f50c79bb4b713a921ad44f002543528a5f;hpb=8004ee8ccfa63181fb103ea50db3b10956d81ce9;p=akkoma diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index fbe259f50..146888c98 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -75,6 +75,23 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do end end + def delete(%Object{data: %{"id" => id, "actor" => actor}} = object, local \\ true) do + user = User.get_cached_by_ap_id(actor) + data = %{ + "type" => "Delete", + "actor" => actor, + "object" => id, + "to" => [user.follower_address, "https://www.w3.org/ns/activitystreams#Public"] + } + with {:ok, activity} <- insert(data, local), + :ok <- maybe_federate(activity) do + Repo.delete(object) + Repo.delete_all(Activity.all_non_create_by_object_ap_id_q(id)) + Repo.delete_all(Activity.all_by_object_ap_id_q(id)) + {:ok, activity} + end + end + def fetch_activities_for_context(context) do query = from activity in Activity, where: fragment("? @> ?", activity.data, ^%{ type: "Create", context: context }),