projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add follow_requests_outstanding_since?/3 to Pleroma.Activity
[akkoma]
/
lib
/
pleroma
/
web
/
activity_pub
/
relay.ex
diff --git
a/lib/pleroma/web/activity_pub/relay.ex
b/lib/pleroma/web/activity_pub/relay.ex
index b65710a941d1b92895a28dd58cf644fcf0d3de4f..6d60a074fa612383ef9c831347b171be5c1fdf05 100644
(file)
--- a/
lib/pleroma/web/activity_pub/relay.ex
+++ b/
lib/pleroma/web/activity_pub/relay.ex
@@
-1,5
+1,5
@@
# Pleroma: A lightweight social networking server
# Pleroma: A lightweight social networking server
-# Copyright © 2017-202
0
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-202
1
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.Relay do
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.Relay do
@@
-30,12
+30,16
@@
defmodule Pleroma.Web.ActivityPub.Relay do
end
end
end
end
- @spec unfollow(String.t()) :: {:ok, Activity.t()} | {:error, any()}
- def unfollow(target_instance) do
+ @spec unfollow(String.t()
, map()
) :: {:ok, Activity.t()} | {:error, any()}
+ def unfollow(target_instance
, opts \\ %{}
) do
with %User{} = local_user <- get_actor(),
with %User{} = local_user <- get_actor(),
- {:ok,
%User{} = target_user} <- User.get_or_fetch_by_ap_id(target_instance
),
+ {:ok,
target_user} <- fetch_target_user(target_instance, opts
),
{:ok, activity} <- ActivityPub.unfollow(local_user, target_user) do
{:ok, activity} <- ActivityPub.unfollow(local_user, target_user) do
- User.unfollow(local_user, target_user)
+ case target_user.id do
+ nil -> User.update_following_count(local_user)
+ _ -> User.unfollow(local_user, target_user)
+ end
+
Logger.info("relay: unfollowed instance: #{target_instance}: id=#{activity.data["id"]}")
{:ok, activity}
else
Logger.info("relay: unfollowed instance: #{target_instance}: id=#{activity.data["id"]}")
{:ok, activity}
else
@@
-43,6
+47,14
@@
defmodule Pleroma.Web.ActivityPub.Relay do
end
end
end
end
+ defp fetch_target_user(ap_id, opts) do
+ case {opts[:force], User.get_or_fetch_by_ap_id(ap_id)} do
+ {_, {:ok, %User{} = user}} -> {:ok, user}
+ {true, _} -> {:ok, %User{ap_id: ap_id}}
+ {_, error} -> error
+ end
+ end
+
@spec publish(any()) :: {:ok, Activity.t()} | {:error, any()}
def publish(%Activity{data: %{"type" => "Create"}} = activity) do
with %User{} = user <- get_actor(),
@spec publish(any()) :: {:ok, Activity.t()} | {:error, any()}
def publish(%Activity{data: %{"type" => "Create"}} = activity) do
with %User{} = user <- get_actor(),