summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Strizhakov <alex.strizhakov@gmail.com>2020-06-18 10:40:25 +0300
committerAlexander Strizhakov <alex.strizhakov@gmail.com>2021-03-10 16:46:56 +0300
commitf6ae86a081946ed55630655901529bb221cef519 (patch)
tree08cb2fc949f0d5230b452cbc8223721e1f857c78
parent9f33c5fe6337eebe9947ad88fa09a28460708b9e (diff)
some clean up
-rw-r--r--lib/pleroma/notification.ex4
-rw-r--r--lib/pleroma/web/masto_fe_controller.ex3
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/notification_controller.ex14
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api.ex12
4 files changed, 12 insertions, 21 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex
index 246993f4d..78dd97513 100644
--- a/lib/pleroma/notification.ex
+++ b/lib/pleroma/notification.ex
@@ -74,8 +74,12 @@ defmodule Pleroma.Notification do
reblog
}
+ @notification_types_excluding_chat List.delete(@notification_types, "pleroma:chat_mention")
+
def types, do: @notification_types
+ def types_excluding_chat, do: @notification_types_excluding_chat
+
def changeset(%Notification{} = notification, attrs) do
notification
|> cast(attrs, [:seen, :type])
diff --git a/lib/pleroma/web/masto_fe_controller.ex b/lib/pleroma/web/masto_fe_controller.ex
index 5a02f2f4d..0f4c413d8 100644
--- a/lib/pleroma/web/masto_fe_controller.ex
+++ b/lib/pleroma/web/masto_fe_controller.ex
@@ -56,7 +56,8 @@ defmodule Pleroma.Web.MastoFEController do
with {:ok, user} <- User.mastodon_settings_update(user, settings) do
if settings = get_in(user.settings, ["notifications", "shows"]) do
notify_settings =
- Enum.map(settings, fn {k, v} -> if v == false, do: k end)
+ settings
+ |> Enum.map(fn {k, v} -> if v == false, do: k end)
|> Enum.reject(&is_nil/1)
notification_settings =
diff --git a/lib/pleroma/web/mastodon_api/controllers/notification_controller.ex b/lib/pleroma/web/mastodon_api/controllers/notification_controller.ex
index 647ba661e..e6e893680 100644
--- a/lib/pleroma/web/mastodon_api/controllers/notification_controller.ex
+++ b/lib/pleroma/web/mastodon_api/controllers/notification_controller.ex
@@ -42,19 +42,11 @@ defmodule Pleroma.Web.MastodonAPI.NotificationController do
end
end
- @default_notification_types ~w{
- mention
- follow
- follow_request
- reblog
- favourite
- move
- pleroma:emoji_reaction
- }
def index(%{assigns: %{user: user}} = conn, params) do
params =
- Map.new(params, fn {k, v} -> {to_string(k), v} end)
- |> Map.put_new("include_types", @default_notification_types)
+ params
+ |> Map.new(fn {k, v} -> {to_string(k), v} end)
+ |> Map.put_new("include_types", Pleroma.Notification.types_excluding_chat())
notifications = MastodonAPI.get_notifications(user, params)
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api.ex b/lib/pleroma/web/mastodon_api/mastodon_api.ex
index 17cfc5443..851811ee1 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api.ex
@@ -50,16 +50,10 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPI do
end
def get_notifications(user, params \\ %{}) do
- options = cast_params(params)
-
- user_exclude_types = user.notification_settings.exclude_types
-
options =
- if (!options[:exclude_types] or options[:exclude_types] == []) and user_exclude_types != [] do
- Map.put(options, :exclude_types, user_exclude_types)
- else
- options
- end
+ params
+ |> Map.put_new("exclude_types", user.notification_settings.exclude_types)
+ |> cast_params()
user
|> Notification.for_user_query(options)