X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=inline;f=lib%2Fpleroma%2Fuser_relationship.ex;h=a467e9b65ad23c6366286387028341af4a59bd53;hb=1e6c27181e0bbfad3fbd964d770cd4d547c10236;hp=235ad427ce8887df7903f31c8d7cabef3810332d;hpb=a2a8c8e9e09b3aa5bc488a958a0afe5909a6e89c;p=akkoma
diff --git a/lib/pleroma/user_relationship.ex b/lib/pleroma/user_relationship.ex
index 235ad427c..a467e9b65 100644
--- a/lib/pleroma/user_relationship.ex
+++ b/lib/pleroma/user_relationship.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.UserRelationship do
@@ -87,6 +87,22 @@ defmodule Pleroma.UserRelationship do
source_to_target_rel_types \\ nil,
target_to_source_rel_types \\ nil
)
+
+ def dictionary(
+ _source_users,
+ _target_users,
+ [] = _source_to_target_rel_types,
+ [] = _target_to_source_rel_types
+ ) do
+ []
+ end
+
+ def dictionary(
+ source_users,
+ target_users,
+ source_to_target_rel_types,
+ target_to_source_rel_types
+ )
when is_list(source_users) and is_list(target_users) do
source_user_ids = User.binary_id(source_users)
target_user_ids = User.binary_id(target_users)
@@ -138,11 +154,16 @@ defmodule Pleroma.UserRelationship do
def view_relationships_option(%User{} = reading_user, actors, opts) do
{source_to_target_rel_types, target_to_source_rel_types} =
- if opts[:source_mutes_only] do
- # This option is used for rendering statuses (FE needs `muted` flag for each one anyways)
- {[:mute], []}
- else
- {[:block, :mute, :notification_mute, :reblog_mute], [:block, :inverse_subscription]}
+ case opts[:subset] do
+ :source_mutes ->
+ # Used for statuses rendering (FE needs `muted` flag for each status when statuses load)
+ {[:mute], []}
+
+ nil ->
+ {[:block, :mute, :notification_mute, :reblog_mute], [:block, :inverse_subscription]}
+
+ unknown ->
+ raise "Unsupported :subset option value: #{inspect(unknown)}"
end
user_relationships =
@@ -153,7 +174,17 @@ defmodule Pleroma.UserRelationship do
target_to_source_rel_types
)
- following_relationships = FollowingRelationship.all_between_user_sets([reading_user], actors)
+ following_relationships =
+ case opts[:subset] do
+ :source_mutes ->
+ []
+
+ nil ->
+ FollowingRelationship.all_between_user_sets([reading_user], actors)
+
+ unknown ->
+ raise "Unsupported :subset option value: #{inspect(unknown)}"
+ end
%{user_relationships: user_relationships, following_relationships: following_relationships}
end