Merge branch 'legal-boilerplate' into 'develop'
[akkoma] / lib / pleroma / web / push / push.ex
index 35e14c243d984283e1c6eadd57f4e2c3810b5137..6459d4543e99f7e9000b995ad339e9670e62ea06 100644 (file)
@@ -1,3 +1,7 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
 defmodule Pleroma.Web.Push do
   use GenServer
 
@@ -32,7 +36,7 @@ defmodule Pleroma.Web.Push do
   end
 
   def init(:ok) do
-    if enabled() do
+    if !enabled() do
       Logger.warn("""
       VAPID key pair is not found. If you wish to enabled web push, please run
 
@@ -54,7 +58,7 @@ defmodule Pleroma.Web.Push do
       when type in @types do
     actor = User.get_cached_by_ap_id(notification.activity.data["actor"])
 
-    type = format_type(notification)
+    type = Pleroma.Activity.mastodon_notification_type(notification.activity)
 
     Subscription
     |> where(user_id: ^user_id)
@@ -114,16 +118,6 @@ defmodule Pleroma.Web.Push do
     {:noreply, state}
   end
 
-  # https://github.com/tootsuite/mastodon/blob/master/app/models/notification.rb#L19
-  defp format_type(%{activity: %{data: %{"type" => type}}}) do
-    case type do
-      "Create" -> "mention"
-      "Follow" -> "follow"
-      "Announce" -> "reblog"
-      "Like" -> "favourite"
-    end
-  end
-
   defp format_title(%{activity: %{data: %{"type" => type}}}) do
     case type do
       "Create" -> "New Mention"