Merge branch 'feature/default-scope' into 'develop'
default scope setting See merge request pleroma/pleroma!239
This commit is contained in:
commit
fe4387077a
@ -873,7 +873,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||||||
},
|
},
|
||||||
compose: %{
|
compose: %{
|
||||||
me: "#{user.id}",
|
me: "#{user.id}",
|
||||||
default_privacy: "public",
|
default_privacy: user.info["default_scope"] || "public",
|
||||||
default_sensitive: false
|
default_sensitive: false
|
||||||
},
|
},
|
||||||
media_attachments: %{
|
media_attachments: %{
|
||||||
|
@ -431,6 +431,19 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
|
|||||||
user
|
user
|
||||||
end
|
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),
|
with changeset <- User.update_changeset(user, params),
|
||||||
{:ok, user} <- User.update_and_set_cache(changeset) do
|
{:ok, user} <- User.update_and_set_cache(changeset) do
|
||||||
CommonAPI.update(user)
|
CommonAPI.update(user)
|
||||||
|
@ -52,7 +52,8 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
|
|||||||
"cover_photo" => User.banner_url(user) |> MediaProxy.url(),
|
"cover_photo" => User.banner_url(user) |> MediaProxy.url(),
|
||||||
"background_image" => image_url(user.info["background"]) |> MediaProxy.url(),
|
"background_image" => image_url(user.info["background"]) |> MediaProxy.url(),
|
||||||
"is_local" => user.local,
|
"is_local" => user.local,
|
||||||
"locked" => !!user.info["locked"]
|
"locked" => !!user.info["locked"],
|
||||||
|
"default_scope" => user.info["default_scope"] || "public"
|
||||||
}
|
}
|
||||||
|
|
||||||
if assigns[:token] do
|
if assigns[:token] do
|
||||||
|
@ -60,7 +60,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
|
|||||||
"cover_photo" => banner,
|
"cover_photo" => banner,
|
||||||
"background_image" => nil,
|
"background_image" => nil,
|
||||||
"is_local" => true,
|
"is_local" => true,
|
||||||
"locked" => false
|
"locked" => false,
|
||||||
|
"default_scope" => "public"
|
||||||
}
|
}
|
||||||
|
|
||||||
assert represented == UserView.render("show.json", %{user: user})
|
assert represented == UserView.render("show.json", %{user: user})
|
||||||
@ -96,7 +97,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
|
|||||||
"cover_photo" => banner,
|
"cover_photo" => banner,
|
||||||
"background_image" => nil,
|
"background_image" => nil,
|
||||||
"is_local" => true,
|
"is_local" => true,
|
||||||
"locked" => false
|
"locked" => false,
|
||||||
|
"default_scope" => "public"
|
||||||
}
|
}
|
||||||
|
|
||||||
assert represented == UserView.render("show.json", %{user: user, for: follower})
|
assert represented == UserView.render("show.json", %{user: user, for: follower})
|
||||||
@ -133,7 +135,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
|
|||||||
"cover_photo" => banner,
|
"cover_photo" => banner,
|
||||||
"background_image" => nil,
|
"background_image" => nil,
|
||||||
"is_local" => true,
|
"is_local" => true,
|
||||||
"locked" => false
|
"locked" => false,
|
||||||
|
"default_scope" => "public"
|
||||||
}
|
}
|
||||||
|
|
||||||
assert represented == UserView.render("show.json", %{user: follower, for: user})
|
assert represented == UserView.render("show.json", %{user: follower, for: user})
|
||||||
@ -177,7 +180,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
|
|||||||
"cover_photo" => banner,
|
"cover_photo" => banner,
|
||||||
"background_image" => nil,
|
"background_image" => nil,
|
||||||
"is_local" => true,
|
"is_local" => true,
|
||||||
"locked" => false
|
"locked" => false,
|
||||||
|
"default_scope" => "public"
|
||||||
}
|
}
|
||||||
|
|
||||||
blocker = Repo.get(User, blocker.id)
|
blocker = Repo.get(User, blocker.id)
|
||||||
|
Loading…
Reference in New Issue
Block a user