Move settings to Source subentity

This commit is contained in:
rinpatch 2019-04-25 09:14:35 +03:00
parent 4baea6e6d9
commit dfc8425659
5 changed files with 20 additions and 10 deletions

View file

@ -45,7 +45,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Mastodon API: Provide plaintext versions of cw/content in the Status entity - Mastodon API: Provide plaintext versions of cw/content in the Status entity
- Mastodon API: Add `pleroma.conversation_id`, `pleroma.in_reply_to_account_acct` fields to the Status entity - Mastodon API: Add `pleroma.conversation_id`, `pleroma.in_reply_to_account_acct` fields to the Status entity
- Mastodon API: Add `pleroma.tags`, `pleroma.relationship{}`, `pleroma.is_moderator`, `pleroma.is_admin`, `pleroma.confirmation_pending`, `pleroma.hide_followers`, `pleroma.hide_follows`, `pleroma.hide_favorites` fields to the User entity - Mastodon API: Add `pleroma.tags`, `pleroma.relationship{}`, `pleroma.is_moderator`, `pleroma.is_admin`, `pleroma.confirmation_pending`, `pleroma.hide_followers`, `pleroma.hide_follows`, `pleroma.hide_favorites` fields to the User entity
- Mastodon API: Add `pleroma.show_role`, `pleroma.no_rich_text` fields to the User entity (when the user is requesting themselves) - Mastodon API: Add `pleroma.show_role`, `pleroma.no_rich_text` fields to the Source subentity
- Mastodon API: Add support for updating `no_rich_text`, `hide_followers`, `hide_follows`, `hide_favorites`, `show_role` in `PATCH /api/v1/update_credentials` - Mastodon API: Add support for updating `no_rich_text`, `hide_followers`, `hide_follows`, `hide_favorites`, `show_role` in `PATCH /api/v1/update_credentials`
- Mastodon API: Add `pleroma.is_seen` to the Notification entity - Mastodon API: Add `pleroma.is_seen` to the Notification entity
- Mastodon API: Add `pleroma.local` to the Status entity - Mastodon API: Add `pleroma.local` to the Status entity

View file

@ -43,7 +43,13 @@ Has these additional fields under the `pleroma` object:
- `confirmation_pending`: boolean, true if a new user account is waiting on email confirmation to be activated - `confirmation_pending`: boolean, true if a new user account is waiting on email confirmation to be activated
- `hide_followers`: boolean, true when the user has follower hiding enabled - `hide_followers`: boolean, true when the user has follower hiding enabled
- `hide_follows`: boolean, true when the user has follow hiding enabled - `hide_follows`: boolean, true when the user has follow hiding enabled
- `show_role`: boolean, nullable (only shown when the user is requesting themselves), true when the user wants his role (e.g admin, moderator) to be shown
### Source
Has these additional fields under the `pleroma` object:
- `show_role`: boolean, nullable, true when the user wants his role (e.g admin, moderator) to be shown
- `no_rich_text` - boolean, nullable, true when html tags are stripped from all statuses requested from the API
## Account Search ## Account Search

View file

@ -113,7 +113,8 @@ defp do_render("account.json", %{user: user} = opts) do
bot: bot, bot: bot,
source: %{ source: %{
note: "", note: "",
sensitive: false sensitive: false,
pleroma: %{}
}, },
# Pleroma extension # Pleroma extension
@ -145,8 +146,8 @@ defp maybe_put_settings(
) do ) do
data data
|> Kernel.put_in([:source, :privacy], user_info.default_scope) |> Kernel.put_in([:source, :privacy], user_info.default_scope)
|> Kernel.put_in([:pleroma, :show_role], user.info.show_role) |> Kernel.put_in([:source, :pleroma, :show_role], user.info.show_role)
|> Kernel.put_in([:pleroma, :no_rich_text], user.info.no_rich_text) |> Kernel.put_in([:source, :pleroma, :no_rich_text], user.info.no_rich_text)
end end
defp maybe_put_settings(data, _, _, _), do: data defp maybe_put_settings(data, _, _, _), do: data

View file

@ -56,7 +56,8 @@ test "Represent a user account" do
bot: false, bot: false,
source: %{ source: %{
note: "", note: "",
sensitive: false sensitive: false,
pleroma: %{}
}, },
pleroma: %{ pleroma: %{
confirmation_pending: false, confirmation_pending: false,
@ -120,7 +121,8 @@ test "Represent a Service(bot) account" do
bot: true, bot: true,
source: %{ source: %{
note: "", note: "",
sensitive: false sensitive: false,
pleroma: %{}
}, },
pleroma: %{ pleroma: %{
confirmation_pending: false, confirmation_pending: false,
@ -208,7 +210,8 @@ test "represent an embedded relationship" do
bot: true, bot: true,
source: %{ source: %{
note: "", note: "",
sensitive: false sensitive: false,
pleroma: %{}
}, },
pleroma: %{ pleroma: %{
confirmation_pending: false, confirmation_pending: false,

View file

@ -2259,7 +2259,7 @@ test "updates the user's show_role status", %{conn: conn} do
|> patch("/api/v1/accounts/update_credentials", %{show_role: "false"}) |> patch("/api/v1/accounts/update_credentials", %{show_role: "false"})
assert user = json_response(conn, 200) assert user = json_response(conn, 200)
assert user["pleroma"]["show_role"] == false assert user["source"]["pleroma"]["show_role"] == false
end end
test "updates the user's no_rich_text status", %{conn: conn} do test "updates the user's no_rich_text status", %{conn: conn} do
@ -2271,7 +2271,7 @@ test "updates the user's no_rich_text status", %{conn: conn} do
|> patch("/api/v1/accounts/update_credentials", %{no_rich_text: "true"}) |> patch("/api/v1/accounts/update_credentials", %{no_rich_text: "true"})
assert user = json_response(conn, 200) assert user = json_response(conn, 200)
assert user["pleroma"]["show_role"] == true assert user["source"]["pleroma"]["no_rich_text"] == true
end end
test "updates the user's name", %{conn: conn} do test "updates the user's name", %{conn: conn} do