forked from AkkomaGang/akkoma
twitter api: user view: expose user notification settings under pleroma object
This commit is contained in:
parent
0f7eeb0943
commit
59a703fcbe
2 changed files with 9 additions and 0 deletions
|
@ -121,6 +121,7 @@ defp do_render("user.json", %{user: user = %User{}} = assigns) do
|
|||
"tags" => user.tags
|
||||
}
|
||||
|> maybe_with_activation_status(user, for_user)
|
||||
|> with_notification_settings(user, for_user)
|
||||
}
|
||||
|> maybe_with_user_settings(user, for_user)
|
||||
|> maybe_with_role(user, for_user)
|
||||
|
@ -132,6 +133,12 @@ defp do_render("user.json", %{user: user = %User{}} = assigns) do
|
|||
end
|
||||
end
|
||||
|
||||
defp with_notification_settings(data, %User{id: user_id} = user, %User{id: user_id}) do
|
||||
Map.put(data, "notification_settings", user.info.notification_settings)
|
||||
end
|
||||
|
||||
defp with_notification_settings(data, _, _), do: data
|
||||
|
||||
defp maybe_with_activation_status(data, user, %User{info: %{is_admin: true}}) do
|
||||
Map.put(data, "deactivated", user.info.deactivated)
|
||||
end
|
||||
|
|
|
@ -112,9 +112,11 @@ test "User exposes settings for themselves and only for themselves", %{user: use
|
|||
as_user = UserView.render("show.json", %{user: user, for: user})
|
||||
assert as_user["default_scope"] == user.info.default_scope
|
||||
assert as_user["no_rich_text"] == user.info.no_rich_text
|
||||
assert as_user["pleroma"]["notification_settings"] == user.info.notification_settings
|
||||
as_stranger = UserView.render("show.json", %{user: user})
|
||||
refute as_stranger["default_scope"]
|
||||
refute as_stranger["no_rich_text"]
|
||||
refute as_stranger["pleroma"]["notification_settings"]
|
||||
end
|
||||
|
||||
test "A user for a given other follower", %{user: user} do
|
||||
|
|
Loading…
Reference in a new issue