diff options
author | Roger Braun <roger@rogerbraun.net> | 2017-09-04 18:47:33 +0200 |
---|---|---|
committer | Roger Braun <roger@rogerbraun.net> | 2017-09-04 18:47:33 +0200 |
commit | 5db535c0b10c27a487b12d5dcc0c015b91753fed (patch) | |
tree | d1f53ae9708b24f423c5b5c582e755339bd69e60 /lib | |
parent | 540dfb4617aaab400d0aeafa47d41544c00a2b83 (diff) | |
download | pleroma-5db535c0b10c27a487b12d5dcc0c015b91753fed.tar.gz |
Add delete to ActivityPub.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub.ex | 17 |
1 files changed, 17 insertions, 0 deletions
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 }), |