diff options
author | rinpatch <rinpatch@sdf.org> | 2019-04-29 06:45:18 +0000 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2019-04-29 06:45:18 +0000 |
commit | 0fd176b990887c170928bc0ce7d43d3a0aab8f7f (patch) | |
tree | d6e300a9e561fe67e04f37d7e679a5afa4d4c157 | |
parent | 8e266e02da15275c4e17533a50ee4c0eaf65227f (diff) | |
parent | ce3789e39ab0b63e634d583cbafbda7a9e4d7550 (diff) | |
download | pleroma-0fd176b990887c170928bc0ce7d43d3a0aab8f7f.tar.gz |
Merge branch 'fix/add-default-scope-mastoapi' into 'develop'
Add default_scope to /api/v1/update_credentials
See merge request pleroma/pleroma!1100
-rw-r--r-- | docs/api/differences_in_mastoapi_responses.md | 1 | ||||
-rw-r--r-- | lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 1 | ||||
-rw-r--r-- | test/web/mastodon_api/mastodon_api_controller_test.exs | 12 |
3 files changed, 14 insertions, 0 deletions
diff --git a/docs/api/differences_in_mastoapi_responses.md b/docs/api/differences_in_mastoapi_responses.md index c69734e72..1350ace43 100644 --- a/docs/api/differences_in_mastoapi_responses.md +++ b/docs/api/differences_in_mastoapi_responses.md @@ -79,3 +79,4 @@ Additional parameters can be added to the JSON body/Form data: - `hide_follows` - if true, user's follows will be hidden - `hide_favorites` - if true, user's favorites timeline will be hidden - `show_role` - if true, user's role (e.g admin, moderator) will be exposed to anyone in the API +- `default_scope` - the scope returned under `privacy` key in Source subentity diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 9179a2682..811a45c79 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -103,6 +103,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do {:ok, ControllerHelper.truthy_param?(value)} end) end) + |> add_if_present(params, "default_scope", :default_scope) |> add_if_present(params, "header", :banner, fn value -> with %Plug.Upload{} <- value, {:ok, object} <- ActivityPub.upload(value, type: :banner) do diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index aea0afa25..c2a12d3c7 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -2214,6 +2214,18 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do assert user["locked"] == true end + test "updates the user's default scope", %{conn: conn} do + user = insert(:user) + + conn = + conn + |> assign(:user, user) + |> patch("/api/v1/accounts/update_credentials", %{default_scope: "cofe"}) + + assert user = json_response(conn, 200) + assert user["source"]["privacy"] == "cofe" + end + test "updates the user's hide_followers status", %{conn: conn} do user = insert(:user) |