activitypub transmogrifier: use fetch_latest_follow to verify a follow object exists
This commit is contained in:
parent
7cf3cf77cf
commit
7e873756e7
@ -171,12 +171,16 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||||||
with %User{} = followed <- User.get_or_fetch_by_ap_id(actor),
|
with %User{} = followed <- User.get_or_fetch_by_ap_id(actor),
|
||||||
{:ok, follow_activity} <- get_follow_activity(follow_object),
|
{:ok, follow_activity} <- get_follow_activity(follow_object),
|
||||||
%User{local: true} = follower <- User.get_cached_by_ap_id(follow_activity["actor"]),
|
%User{local: true} = follower <- User.get_cached_by_ap_id(follow_activity["actor"]),
|
||||||
|
follow_activity <- Utils.fetch_latest_follow(follower, followed),
|
||||||
|
false <- is_nil(follow_activity),
|
||||||
{:ok, activity} <- ActivityPub.insert(data, true) do
|
{:ok, activity} <- ActivityPub.insert(data, true) do
|
||||||
if not User.following?(follower, followed) do
|
if not User.following?(follower, followed) do
|
||||||
{:ok, follower} = User.follow(follower, followed)
|
{:ok, follower} = User.follow(follower, followed)
|
||||||
end
|
end
|
||||||
|
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
|
else
|
||||||
|
_e -> :error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -186,10 +190,14 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||||||
with %User{} = followed <- User.get_or_fetch_by_ap_id(actor),
|
with %User{} = followed <- User.get_or_fetch_by_ap_id(actor),
|
||||||
{:ok, follow_activity} <- get_follow_activity(follow_object),
|
{:ok, follow_activity} <- get_follow_activity(follow_object),
|
||||||
%User{local: true} = follower <- User.get_cached_by_ap_id(follow_activity["actor"]),
|
%User{local: true} = follower <- User.get_cached_by_ap_id(follow_activity["actor"]),
|
||||||
|
follow_activity <- Utils.fetch_latest_follow(follower, followed),
|
||||||
|
false <- is_nil(follow_activity),
|
||||||
{:ok, activity} <- ActivityPub.insert(data, true) do
|
{:ok, activity} <- ActivityPub.insert(data, true) do
|
||||||
User.unfollow(follower, followed)
|
User.unfollow(follower, followed)
|
||||||
|
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
|
else
|
||||||
|
_e -> :error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user