Add Undo of Follow Activity insertion

This commit is contained in:
dtluna 2017-04-21 19:54:21 +03:00
commit 28b203d08f
6 changed files with 51 additions and 6 deletions

View file

@ -174,6 +174,16 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
Repo.all(query)
end
def fetch_latest_follow(%User{ap_id: follower_id},
%User{ap_id: followed_id}) do
query = from activity in Activity,
where: fragment("? @> ?", activity.data, ^%{type: "Follow", actor: follower_id,
object: followed_id}),
order_by: [desc: :inserted_at],
limit: 1
Repo.one(query)
end
def upload(file) do
data = Upload.store(file)
Repo.insert(%Object{data: data})