From 46492a2aee53e7d0849faae6837423da3812b993 Mon Sep 17 00:00:00 2001 From: Alexander Strizhakov Date: Wed, 17 Jun 2020 18:39:20 +0300 Subject: [PATCH] set alert types in compile time --- lib/pleroma/web/push/subscription.ex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/push/subscription.ex b/lib/pleroma/web/push/subscription.ex index 7ea32b258..61e34fbba 100644 --- a/lib/pleroma/web/push/subscription.ex +++ b/lib/pleroma/web/push/subscription.ex @@ -14,6 +14,8 @@ defmodule Pleroma.Web.Push.Subscription do @type t :: %__MODULE__{} + @supported_alert_types Enum.map(Pleroma.Notification.types(), &String.to_atom/1) + schema "push_subscriptions" do belongs_to(:user, User, type: FlakeId.Ecto.CompatType) belongs_to(:token, Token) @@ -29,8 +31,7 @@ defmodule Pleroma.Web.Push.Subscription do @supported_alert_types ~w[follow favourite mention reblog pleroma:chat_mention pleroma:emoji_reaction]a defp alerts(%{data: %{alerts: alerts}}) do - types = Enum.map(Pleroma.Notification.types(), &String.to_atom/1) - alerts = Map.take(alerts, types) + alerts = Map.take(alerts, @supported_alert_types) %{"alerts" => alerts} end