From dfc8425659620d023540538ec943490cf523f434 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Thu, 25 Apr 2019 09:14:35 +0300 Subject: [PATCH] Move settings to Source subentity --- CHANGELOG.md | 2 +- docs/api/differences_in_mastoapi_responses.md | 8 +++++++- lib/pleroma/web/mastodon_api/views/account_view.ex | 7 ++++--- test/web/mastodon_api/account_view_test.exs | 9 ++++++--- test/web/mastodon_api/mastodon_api_controller_test.exs | 4 ++-- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51ba239b6..0caeda978 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: 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.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 `pleroma.is_seen` to the Notification entity - Mastodon API: Add `pleroma.local` to the Status entity diff --git a/docs/api/differences_in_mastoapi_responses.md b/docs/api/differences_in_mastoapi_responses.md index 7f05527fb..c69734e72 100644 --- a/docs/api/differences_in_mastoapi_responses.md +++ b/docs/api/differences_in_mastoapi_responses.md @@ -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 - `hide_followers`: boolean, true when the user has follower 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 diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex index 6e6f0ba93..779b9a382 100644 --- a/lib/pleroma/web/mastodon_api/views/account_view.ex +++ b/lib/pleroma/web/mastodon_api/views/account_view.ex @@ -113,7 +113,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do bot: bot, source: %{ note: "", - sensitive: false + sensitive: false, + pleroma: %{} }, # Pleroma extension @@ -145,8 +146,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do ) do data |> Kernel.put_in([:source, :privacy], user_info.default_scope) - |> Kernel.put_in([:pleroma, :show_role], user.info.show_role) - |> Kernel.put_in([:pleroma, :no_rich_text], user.info.no_rich_text) + |> Kernel.put_in([:source, :pleroma, :show_role], user.info.show_role) + |> Kernel.put_in([:source, :pleroma, :no_rich_text], user.info.no_rich_text) end defp maybe_put_settings(data, _, _, _), do: data diff --git a/test/web/mastodon_api/account_view_test.exs b/test/web/mastodon_api/account_view_test.exs index db870f1d1..a24f2a050 100644 --- a/test/web/mastodon_api/account_view_test.exs +++ b/test/web/mastodon_api/account_view_test.exs @@ -56,7 +56,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do bot: false, source: %{ note: "", - sensitive: false + sensitive: false, + pleroma: %{} }, pleroma: %{ confirmation_pending: false, @@ -120,7 +121,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do bot: true, source: %{ note: "", - sensitive: false + sensitive: false, + pleroma: %{} }, pleroma: %{ confirmation_pending: false, @@ -208,7 +210,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do bot: true, source: %{ note: "", - sensitive: false + sensitive: false, + pleroma: %{} }, pleroma: %{ confirmation_pending: false, diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 0c52dd3e3..efcadcbf5 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -2259,7 +2259,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do |> patch("/api/v1/accounts/update_credentials", %{show_role: "false"}) assert user = json_response(conn, 200) - assert user["pleroma"]["show_role"] == false + assert user["source"]["pleroma"]["show_role"] == false end test "updates the user's no_rich_text status", %{conn: conn} do @@ -2271,7 +2271,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do |> patch("/api/v1/accounts/update_credentials", %{no_rich_text: "true"}) assert user = json_response(conn, 200) - assert user["pleroma"]["show_role"] == true + assert user["source"]["pleroma"]["no_rich_text"] == true end test "updates the user's name", %{conn: conn} do -- 2.45.2