summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Strizhakov <alex.strizhakov@gmail.com>2020-06-29 12:07:00 +0300
committerAlexander Strizhakov <alex.strizhakov@gmail.com>2021-03-10 16:46:57 +0300
commitaf6725121f909c7e2f03a6aafbcc4a54f93500c5 (patch)
treeb4a134519314a2ad2a9321899edebdb66e762159
parent5361e40162e5431a3d22fe71128facedaebd38ce (diff)
removing saving settings in mastofe
-rw-r--r--lib/pleroma/web/masto_fe_controller.ex16
-rw-r--r--test/pleroma/web/mastodon_api/masto_fe_controller_test.exs93
2 files changed, 10 insertions, 99 deletions
diff --git a/lib/pleroma/web/masto_fe_controller.ex b/lib/pleroma/web/masto_fe_controller.ex
index 0f4c413d8..e788ab37a 100644
--- a/lib/pleroma/web/masto_fe_controller.ex
+++ b/lib/pleroma/web/masto_fe_controller.ex
@@ -53,21 +53,7 @@ defmodule Pleroma.Web.MastoFEController do
@doc "PUT /api/web/settings: Backend-obscure settings blob for MastoFE, don't parse/reuse elsewhere"
def put_settings(%{assigns: %{user: user}} = conn, %{"data" => settings} = _params) do
- with {:ok, user} <- User.mastodon_settings_update(user, settings) do
- if settings = get_in(user.settings, ["notifications", "shows"]) do
- notify_settings =
- settings
- |> Enum.map(fn {k, v} -> if v == false, do: k end)
- |> Enum.reject(&is_nil/1)
-
- notification_settings =
- user.notification_settings
- |> Map.from_struct()
- |> Map.put(:exclude_types, notify_settings)
-
- User.update_notification_settings(user, notification_settings)
- end
-
+ with {:ok, _} <- User.mastodon_settings_update(user, settings) do
json(conn, %{})
else
e ->
diff --git a/test/pleroma/web/mastodon_api/masto_fe_controller_test.exs b/test/pleroma/web/mastodon_api/masto_fe_controller_test.exs
index 5d6a5c1bf..f8e91aa05 100644
--- a/test/pleroma/web/mastodon_api/masto_fe_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/masto_fe_controller_test.exs
@@ -11,94 +11,19 @@ defmodule Pleroma.Web.MastodonAPI.MastoFEControllerTest do
setup do: clear_config([:instance, :public])
- describe "put_settings/2" do
- setup do
- %{conn: conn, user: user} = oauth_access(["write:accounts"])
- [conn: conn, user: user]
- end
+ test "put settings", %{conn: conn} do
+ user = insert(:user)
- test "common", %{conn: conn, user: user} do
- assert conn
- |> put("/api/web/settings", %{"data" => %{"programming" => "socks"}})
- |> json_response(200)
+ conn =
+ conn
+ |> assign(:user, user)
+ |> assign(:token, insert(:oauth_token, user: user, scopes: ["write:accounts"]))
+ |> put("/api/web/settings", %{"data" => %{"programming" => "socks"}})
- user = User.get_cached_by_ap_id(user.ap_id)
- assert user.mastofe_settings == %{"programming" => "socks"}
- end
-
- test "saves notification settings", %{conn: conn, user: user} do
- assert conn
- |> put("/api/web/settings", %{
- "data" => %{
- "notifications" => %{
- "alerts" => %{
- "favourite" => true,
- "follow" => true,
- "follow_request" => true,
- "mention" => true,
- "poll" => true,
- "reblog" => true
- },
- "quickFilter" => %{"active" => "all", "advanced" => true, "show" => true},
- "shows" => %{
- "favourite" => false,
- "follow" => false,
- "follow_request" => false,
- "mention" => false,
- "poll" => false,
- "reblog" => true
- },
- "sounds" => %{
- "favourite" => true,
- "follow" => true,
- "follow_request" => true,
- "mention" => true,
- "poll" => true,
- "reblog" => true
- }
- }
- }
- })
+ assert _result = json_response(conn, 200)
user = User.get_cached_by_ap_id(user.ap_id)
-
- assert user.settings == %{
- "notifications" => %{
- "alerts" => %{
- "favourite" => true,
- "follow" => true,
- "follow_request" => true,
- "mention" => true,
- "poll" => true,
- "reblog" => true
- },
- "quickFilter" => %{"active" => "all", "advanced" => true, "show" => true},
- "shows" => %{
- "favourite" => false,
- "follow" => false,
- "follow_request" => false,
- "mention" => false,
- "poll" => false,
- "reblog" => true
- },
- "sounds" => %{
- "favourite" => true,
- "follow" => true,
- "follow_request" => true,
- "mention" => true,
- "poll" => true,
- "reblog" => true
- }
- }
- }
-
- assert user.notification_settings.exclude_types == [
- "favourite",
- "follow",
- "follow_request",
- "mention",
- "poll"
- ]
+ assert user.mastofe_settings == %{"programming" => "socks"}
end
end