diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/notification.ex | 46 | ||||
-rw-r--r-- | lib/pleroma/web/mastodon_api/controllers/notification_controller.ex | 2 |
2 files changed, 25 insertions, 23 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index 78dd97513..c3d20aa9f 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -5,6 +5,9 @@ defmodule Pleroma.Notification do use Ecto.Schema + import Ecto.Query + import Ecto.Changeset + alias Ecto.Multi alias Pleroma.Activity alias Pleroma.FollowingRelationship @@ -20,15 +23,26 @@ defmodule Pleroma.Notification do alias Pleroma.Web.Push alias Pleroma.Web.Streamer - import Ecto.Query - import Ecto.Changeset - require Logger - @type t :: %__MODULE__{} - @include_muted_option :with_muted + @types ~w{ + favourite + follow + follow_request + mention + move + pleroma:chat_mention + pleroma:emoji_reaction + pleroma:report + reblog + } + + @types_excluding_chat_and_report @types -- ~w(pleroma:chat_mention pleroma:report) + + @type t :: %__MODULE__{} + schema "notifications" do field(:seen, :boolean, default: false) # This is an enum type in the database. If you add a new notification type, @@ -62,28 +76,16 @@ defmodule Pleroma.Notification do |> Repo.aggregate(:count, :id) end - @notification_types ~w{ - favourite - follow - follow_request - mention - move - pleroma:chat_mention - pleroma:emoji_reaction - pleroma:report - reblog - } - - @notification_types_excluding_chat List.delete(@notification_types, "pleroma:chat_mention") - - def types, do: @notification_types + @spec types() :: [String.t()] + def types, do: @types - def types_excluding_chat, do: @notification_types_excluding_chat + @spec types_excluding_chat_and_report() :: [String.t()] + def types_excluding_chat_and_report, do: @types_excluding_chat_and_report def changeset(%Notification{} = notification, attrs) do notification |> cast(attrs, [:seen, :type]) - |> validate_inclusion(:type, @notification_types) + |> validate_inclusion(:type, @types) end @spec last_read_query(User.t()) :: Ecto.Queryable.t() diff --git a/lib/pleroma/web/mastodon_api/controllers/notification_controller.ex b/lib/pleroma/web/mastodon_api/controllers/notification_controller.ex index e6e893680..771280a81 100644 --- a/lib/pleroma/web/mastodon_api/controllers/notification_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/notification_controller.ex @@ -46,7 +46,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationController do params = params |> Map.new(fn {k, v} -> {to_string(k), v} end) - |> Map.put_new("include_types", Pleroma.Notification.types_excluding_chat()) + |> Map.put_new("include_types", Pleroma.Notification.types_excluding_chat_and_report()) notifications = MastodonAPI.get_notifications(user, params) |