Commit fe438707 by lambda

Merge branch 'feature/default-scope' into 'develop'

default scope setting See merge request !239
parents 4a922305 32211c4a
Pipeline #2739 passed with stages
in 4 minutes 44 seconds
......@@ -873,7 +873,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
},
compose: %{
me: "#{user.id}",
default_privacy: "public",
default_privacy: user.info["default_scope"] || "public",
default_sensitive: false
},
media_attachments: %{
......
......@@ -431,6 +431,19 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
user
end
user =
if default_scope = params["default_scope"] do
with new_info <- Map.put(user.info, "default_scope", default_scope),
change <- User.info_changeset(user, %{info: new_info}),
{:ok, user} <- User.update_and_set_cache(change) do
user
else
_e -> user
end
else
user
end
with changeset <- User.update_changeset(user, params),
{:ok, user} <- User.update_and_set_cache(changeset) do
CommonAPI.update(user)
......
......@@ -52,7 +52,8 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
"cover_photo" => User.banner_url(user) |> MediaProxy.url(),
"background_image" => image_url(user.info["background"]) |> MediaProxy.url(),
"is_local" => user.local,
"locked" => !!user.info["locked"]
"locked" => !!user.info["locked"],
"default_scope" => user.info["default_scope"] || "public"
}
if assigns[:token] do
......
......@@ -60,7 +60,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
"cover_photo" => banner,
"background_image" => nil,
"is_local" => true,
"locked" => false
"locked" => false,
"default_scope" => "public"
}
assert represented == UserView.render("show.json", %{user: user})
......@@ -96,7 +97,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
"cover_photo" => banner,
"background_image" => nil,
"is_local" => true,
"locked" => false
"locked" => false,
"default_scope" => "public"
}
assert represented == UserView.render("show.json", %{user: user, for: follower})
......@@ -133,7 +135,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
"cover_photo" => banner,
"background_image" => nil,
"is_local" => true,
"locked" => false
"locked" => false,
"default_scope" => "public"
}
assert represented == UserView.render("show.json", %{user: follower, for: user})
......@@ -177,7 +180,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
"cover_photo" => banner,
"background_image" => nil,
"is_local" => true,
"locked" => false
"locked" => false,
"default_scope" => "public"
}
blocker = Repo.get(User, blocker.id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment