Notfication: Add validation of notification types
authorlain <lain@soykaf.club>
Sat, 6 Jun 2020 14:59:08 +0000 (16:59 +0200)
committerlain <lain@soykaf.club>
Sat, 6 Jun 2020 14:59:08 +0000 (16:59 +0200)
lib/pleroma/notification.ex

index 682a26912a5a7fe04d5af08ee256de2ec089d0d4..3ac8737e20ab522d214264cb8f9d594ccf973c79 100644 (file)
@@ -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()