Merge branch 'fix/add-default-scope-mastoapi' into 'develop'
authorrinpatch <rinpatch@sdf.org>
Mon, 29 Apr 2019 06:45:18 +0000 (06:45 +0000)
committerrinpatch <rinpatch@sdf.org>
Mon, 29 Apr 2019 06:45:18 +0000 (06:45 +0000)
Add default_scope to /api/v1/update_credentials

See merge request pleroma/pleroma!1100

docs/api/differences_in_mastoapi_responses.md
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
test/web/mastodon_api/mastodon_api_controller_test.exs

index c69734e729d5b5eefbffcb2c027092fe5d1966ba..1350ace43eb0086d323e5eccdeb33944813e3dd4 100644 (file)
@@ -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
index 9179a26826840d1c5a33df5a49ebe8ed64b5dd8a..811a45c794623cf6f56aa76db9e1ddb2612330f8 100644 (file)
@@ -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
index aea0afa259e4d6052588693b19f4144269ce6eaf..c2a12d3c7a9fca1d4114ef148359024e7e9a1461 100644 (file)
@@ -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)