some clean up
This commit is contained in:
parent
9f33c5fe63
commit
f6ae86a081
@ -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])
|
||||
|
@ -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 =
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user