logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

push.ex (862B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.Push do
  5. alias Pleroma.Workers.WebPusherWorker
  6. require Logger
  7. def init do
  8. unless enabled() do
  9. Logger.warning("""
  10. VAPID key pair is not found. If you wish to enabled web push, please run
  11. mix web_push.gen.keypair
  12. and add the resulting output to your configuration file.
  13. """)
  14. end
  15. end
  16. def vapid_config do
  17. Application.get_env(:web_push_encryption, :vapid_details, [])
  18. end
  19. def enabled do
  20. case vapid_config() do
  21. [] -> false
  22. list when is_list(list) -> true
  23. _ -> false
  24. end
  25. end
  26. def send(notification) do
  27. WebPusherWorker.enqueue("web_push", %{"notification_id" => notification.id})
  28. end
  29. end