diff options
author | lain <lain@soykaf.club> | 2020-05-05 08:21:39 +0000 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-05-05 08:21:39 +0000 |
commit | c297667f16db40654bb16608c01dc4a2dc7c0e4b (patch) | |
tree | 198ffe0c5f8d8ac2c77e29646e90599481b4ea62 /lib | |
parent | b1c29e2de8a02ef3093387c1454d290a92fbdef8 (diff) | |
parent | ec24c70db80665aaaf4d7794ea62e9f9e6676bec (diff) | |
download | pleroma-c297667f16db40654bb16608c01dc4a2dc7c0e4b.tar.gz |
Merge branch 'fix/issue-1729' into 'develop'
Only update follower/following stats for actor types of users and bots.
Closes #1565 and #1729
See merge request pleroma/pleroma!2464
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub.ex | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 1f4a09370..1c21d78af 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -1530,21 +1530,34 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do defp normalize_counter(counter) when is_integer(counter), do: counter defp normalize_counter(_), do: 0 - defp maybe_update_follow_information(data) do + def maybe_update_follow_information(user_data) do with {:enabled, true} <- {:enabled, Config.get([:instance, :external_user_synchronization])}, - {:ok, info} <- fetch_follow_information_for_user(data) do - info = Map.merge(data[:info] || %{}, info) - Map.put(data, :info, info) + {_, true} <- {:user_type_check, user_data[:type] in ["Person", "Service"]}, + {_, true} <- + {:collections_available, + !!(user_data[:following_address] && user_data[:follower_address])}, + {:ok, info} <- + fetch_follow_information_for_user(user_data) do + info = Map.merge(user_data[:info] || %{}, info) + + user_data + |> Map.put(:info, info) else + {:user_type_check, false} -> + user_data + + {:collections_available, false} -> + user_data + {:enabled, false} -> - data + user_data e -> Logger.error( - "Follower/Following counter update for #{data.ap_id} failed.\n" <> inspect(e) + "Follower/Following counter update for #{user_data.ap_id} failed.\n" <> inspect(e) ) - data + user_data end end |