+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Pleroma.Web.Push do
use GenServer
- alias Pleroma.{Repo, User}
+ alias Pleroma.Repo
+ alias Pleroma.User
alias Pleroma.Web.Push.Subscription
require Logger
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
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)
{: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"