end)
end
+ def subscribed_to?(user, %{ap_id: ap_id}) do
+ subs = user.info.subscriptions
+ Enum.member?(subs, ap_id)
+ end
+
def muted_users(user),
do: Repo.all(from(u in User, where: u.ap_id in ^user.info.mutes))
for_user = assigns[:for]
image = User.avatar_url(user) |> MediaProxy.url()
- {following, follows_you, statusnet_blocking} =
+ {following, follows_you, statusnet_blocking, subscribed} =
if for_user do
{
User.following?(for_user, user),
User.following?(user, for_user),
- User.blocks?(for_user, user)
+ User.blocks?(for_user, user),
+ User.subscribed_to?(for_user, user)
}
else
- {false, false, false}
+ {false, false, false, false}
end
user_info = User.get_cached_user_info(user)
"pleroma" =>
%{
"confirmation_pending" => user_info.confirmation_pending,
- "tags" => user.tags
+ "tags" => user.tags,
+ "subscribed" => subscribed
}
|> maybe_with_activation_status(user, for_user)
}
"fields" => [],
"pleroma" => %{
"confirmation_pending" => false,
- "tags" => []
+ "tags" => [],
+ "subscribed" => false
}
}
"fields" => [],
"pleroma" => %{
"confirmation_pending" => false,
- "tags" => []
+ "tags" => [],
+ "subscribed" => false,
}
}
"fields" => [],
"pleroma" => %{
"confirmation_pending" => false,
- "tags" => []
+ "tags" => [],
+ "subscribed" => false
}
}
assert represented == UserView.render("show.json", %{user: follower, for: user})
end
+ test "a user that you are subscribed to" do
+ user = insert(:user)
+ subscriber = insert(:user)
+ {:ok, subscriber} = User.subscribe(subscriber, user)
+ represented = UserView.render("show.json", %{user: user, for: subscriber})
+ assert represented["pleroma"]["subscribed"] == true
+ end
+
test "a user that is a moderator" do
user = insert(:user, %{info: %{is_moderator: true}})
represented = UserView.render("show.json", %{user: user, for: user})