From 1bd3012c2d9037780e854b8738f99f16fafcad5a Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Sat, 12 Aug 2023 15:03:43 +0100 Subject: [PATCH] Fix compiler warnings --- CHANGELOG.md | 1 + .../controllers/account_controller.ex | 2 +- .../web/mastodon_api/views/account_view.ex | 22 +++++++++---------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3938f5ac..e0256a894 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Added - Full compatibility with Erlang OTP26 +- handling of GET /api/v1/preferences ## Changed - OTP builds are now built on erlang OTP26 diff --git a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex index bbae5a432..6fc88354f 100644 --- a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex @@ -546,7 +546,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do def identity_proofs(conn, params), do: MastodonAPIController.empty_array(conn, params) @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) end end diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex index 1ab6cba9b..2f543c08a 100644 --- a/lib/pleroma/web/mastodon_api/views/account_view.ex +++ b/lib/pleroma/web/mastodon_api/views/account_view.ex @@ -190,6 +190,17 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do 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 user = User.sanitize_html(user, User.html_filter_policy(opts[:for])) display_name = user.name || user.nickname @@ -315,17 +326,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do |> maybe_put_email_address(user, opts[:for]) 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 hd(String.split(string, "@")) end