Include requested_by in relationship #260
2 changed files with 26 additions and 6 deletions
|
@ -94,12 +94,12 @@ def render(
|
||||||
|
|
||||||
followed_by =
|
followed_by =
|
||||||
if following_relationships do
|
if following_relationships do
|
||||||
case FollowingRelationship.find(following_relationships, target, reading_user) do
|
target_to_user_following_relation =
|
||||||
%{state: :follow_accept} -> true
|
FollowingRelationship.find(following_relationships, target, reading_user)
|
||||||
_ -> false
|
|
||||||
end
|
User.get_follow_state(target, reading_user, target_to_user_following_relation)
|
||||||
else
|
else
|
||||||
User.following?(target, reading_user)
|
User.get_follow_state(target, reading_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
subscribing =
|
subscribing =
|
||||||
|
@ -115,7 +115,7 @@ def render(
|
||||||
%{
|
%{
|
||||||
id: to_string(target.id),
|
id: to_string(target.id),
|
||||||
following: follow_state == :follow_accept,
|
following: follow_state == :follow_accept,
|
||||||
followed_by: followed_by,
|
followed_by: followed_by == :follow_accept,
|
||||||
blocking:
|
blocking:
|
||||||
UserRelationship.exists?(
|
UserRelationship.exists?(
|
||||||
user_relationships,
|
user_relationships,
|
||||||
|
@ -151,6 +151,7 @@ def render(
|
||||||
subscribing: subscribing,
|
subscribing: subscribing,
|
||||||
notifying: subscribing,
|
notifying: subscribing,
|
||||||
requested: follow_state == :follow_pending,
|
requested: follow_state == :follow_pending,
|
||||||
|
requested_by: followed_by == :follow_pending,
|
||||||
domain_blocking: User.blocks_domain?(reading_user, target),
|
domain_blocking: User.blocks_domain?(reading_user, target),
|
||||||
showing_reblogs:
|
showing_reblogs:
|
||||||
not UserRelationship.exists?(
|
not UserRelationship.exists?(
|
||||||
|
|
|
@ -347,6 +347,7 @@ defp test_relationship_rendering(user, other_user, expected_result) do
|
||||||
subscribing: false,
|
subscribing: false,
|
||||||
notifying: false,
|
notifying: false,
|
||||||
requested: false,
|
requested: false,
|
||||||
|
requested_by: false,
|
||||||
domain_blocking: false,
|
domain_blocking: false,
|
||||||
showing_reblogs: true,
|
showing_reblogs: true,
|
||||||
endorsed: false,
|
endorsed: false,
|
||||||
|
@ -432,6 +433,24 @@ test "represent a relationship for the user with a pending follow request" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "represent a relationship for a user with an inbound pending follow request" do
|
||||||
|
follower = insert(:user)
|
||||||
|
followed = insert(:user, is_locked: true)
|
||||||
|
|
||||||
|
{:ok, follower, followed, _} = CommonAPI.follow(follower, followed)
|
||||||
|
|
||||||
|
follower = User.get_cached_by_id(follower.id)
|
||||||
|
followed = User.get_cached_by_id(followed.id)
|
||||||
|
|
||||||
|
expected =
|
||||||
|
Map.merge(
|
||||||
|
@blank_response,
|
||||||
|
%{requested_by: true, followed_by: false, id: to_string(follower.id)}
|
||||||
|
)
|
||||||
|
|
||||||
|
test_relationship_rendering(followed, follower, expected)
|
||||||
|
end
|
||||||
|
|
||||||
test "returns the settings store if the requesting user is the represented user and it's requested specifically" do
|
test "returns the settings store if the requesting user is the represented user and it's requested specifically" do
|
||||||
user = insert(:user, pleroma_settings_store: %{fe: "test"})
|
user = insert(:user, pleroma_settings_store: %{fe: "test"})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue