forked from AkkomaGang/akkoma
Fix compiler warnings
This commit is contained in:
parent
2df7707060
commit
1bd3012c2d
3 changed files with 13 additions and 12 deletions
|
@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
|
|
||||||
## Added
|
## Added
|
||||||
- Full compatibility with Erlang OTP26
|
- Full compatibility with Erlang OTP26
|
||||||
|
- handling of GET /api/v1/preferences
|
||||||
|
|
||||||
## Changed
|
## Changed
|
||||||
- OTP builds are now built on erlang OTP26
|
- OTP builds are now built on erlang OTP26
|
||||||
|
|
|
@ -546,7 +546,7 @@ def endorsements(conn, params), do: MastodonAPIController.empty_array(conn, para
|
||||||
def identity_proofs(conn, params), do: MastodonAPIController.empty_array(conn, params)
|
def identity_proofs(conn, params), do: MastodonAPIController.empty_array(conn, params)
|
||||||
|
|
||||||
@doc "GET /api/v1/preferences"
|
@doc "GET /api/v1/preferences"
|
||||||
def preferences(%{assigns: %{user: user}} = conn, params) do
|
def preferences(%{assigns: %{user: user}} = conn, _params) do
|
||||||
render(conn, "preferences.json", user: user)
|
render(conn, "preferences.json", user: user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -190,6 +190,17 @@ def render("instance.json", %{instance: %Pleroma.Instances.Instance{} = instance
|
||||||
|
|
||||||
def render("instance.json", _), do: nil
|
def render("instance.json", _), do: nil
|
||||||
|
|
||||||
|
def render("preferences.json", %{user: user} = _opts) do
|
||||||
|
# TODO: Do we expose more settings that make sense to plug in here?
|
||||||
|
%{
|
||||||
|
"posting:default:visibility": user.default_scope,
|
||||||
|
"posting:default:sensitive": false,
|
||||||
|
"posting:default:language": nil,
|
||||||
|
"reading:expand:media": "default",
|
||||||
|
"reading:expand:spoilers": false
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
defp do_render("show.json", %{user: user} = opts) do
|
defp do_render("show.json", %{user: user} = opts) do
|
||||||
user = User.sanitize_html(user, User.html_filter_policy(opts[:for]))
|
user = User.sanitize_html(user, User.html_filter_policy(opts[:for]))
|
||||||
display_name = user.name || user.nickname
|
display_name = user.name || user.nickname
|
||||||
|
@ -315,17 +326,6 @@ defp do_render("show.json", %{user: user} = opts) do
|
||||||
|> maybe_put_email_address(user, opts[:for])
|
|> maybe_put_email_address(user, opts[:for])
|
||||||
end
|
end
|
||||||
|
|
||||||
def render("preferences.json", %{user: user} = opts) do
|
|
||||||
# TODO: Do we expose more settings that make sense to plug in here?
|
|
||||||
%{
|
|
||||||
"posting:default:visibility": user.default_scope,
|
|
||||||
"posting:default:sensitive": false,
|
|
||||||
"posting:default:language": nil,
|
|
||||||
"reading:expand:media": "default",
|
|
||||||
"reading:expand:spoilers": false
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
defp username_from_nickname(string) when is_binary(string) do
|
defp username_from_nickname(string) when is_binary(string) do
|
||||||
hd(String.split(string, "@"))
|
hd(String.split(string, "@"))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue