Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel-dms
[akkoma] / lib / pleroma / notification.ex
index 682a26912a5a7fe04d5af08ee256de2ec089d0d4..3386a19336c6fa1a8fb44310053cab67aa5c2827 100644 (file)
@@ -31,7 +31,7 @@ defmodule Pleroma.Notification do
   schema "notifications" do
     field(:seen, :boolean, default: false)
     # This is an enum type in the database. If you add a new notification type,
-    # remembert to add a migration to add it to the `notifications_type` enum
+    # remember to add a migration to add it to the `notifications_type` enum
     # as well.
     field(:type, :string)
     belongs_to(:user, User, type: FlakeId.Ecto.CompatType)
@@ -61,9 +61,21 @@ defmodule Pleroma.Notification do
     |> Repo.aggregate(:count, :id)
   end
 
+  @notification_types ~w{
+    favourite
+    follow
+    follow_request
+    mention
+    move
+    pleroma:chat_mention
+    pleroma:emoji_reaction
+    reblog
+  }
+
   def changeset(%Notification{} = notification, attrs) do
     notification
     |> cast(attrs, [:seen, :type])
+    |> validate_inclusion(:type, @notification_types)
   end
 
   @spec last_read_query(User.t()) :: Ecto.Queryable.t()