forked from YokaiRick/akkoma
Merge branch 'feature/default-scope' into 'develop'
default scope setting See merge request pleroma/pleroma!239
This commit is contained in:
commit
fe4387077a
4 changed files with 24 additions and 6 deletions
|
@ -873,7 +873,7 @@ def index(%{assigns: %{user: user}} = conn, _params) do
|
|||
},
|
||||
compose: %{
|
||||
me: "#{user.id}",
|
||||
default_privacy: "public",
|
||||
default_privacy: user.info["default_scope"] || "public",
|
||||
default_sensitive: false
|
||||
},
|
||||
media_attachments: %{
|
||||
|
|
|
@ -431,6 +431,19 @@ def update_profile(%{assigns: %{user: user}} = conn, params) 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 @@ def render("user.json", %{user: user = %User{}} = assigns) 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 @@ test "A user" 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 @@ test "A user for a given other follower", %{user: user} 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 @@ test "A user that follows you", %{user: user} 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 @@ test "A blocked user for the blocker" do
|
|||
"cover_photo" => banner,
|
||||
"background_image" => nil,
|
||||
"is_local" => true,
|
||||
"locked" => false
|
||||
"locked" => false,
|
||||
"default_scope" => "public"
|
||||
}
|
||||
|
||||
blocker = Repo.get(User, blocker.id)
|
||||
|
|
Loading…
Reference in a new issue