[#1149] Addressed code review comments (code style, jobs pruning etc.).
[akkoma] / lib / pleroma / web / push / push.ex
index 729dad02a22a0cec0698c6501cf2671e939ec49f..4973b529ceec978a4fcd489a20155c00e100ca71 100644 (file)
@@ -3,10 +3,13 @@
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.Push do
-  alias Pleroma.Web.Push.Impl
+  alias Pleroma.Repo
+  alias Pleroma.Workers.WebPusherWorker
 
   require Logger
 
+  import Pleroma.Workers.WorkerHelper, only: [worker_args: 1]
+
   def init do
     unless enabled() do
       Logger.warn("""
@@ -31,6 +34,9 @@ defmodule Pleroma.Web.Push do
     end
   end
 
-  def send(notification),
-    do: PleromaJobQueue.enqueue(:web_push, Impl, [notification])
+  def send(notification) do
+    %{"op" => "web_push", "notification_id" => notification.id}
+    |> WebPusherWorker.new(worker_args(:web_push))
+    |> Repo.insert()
+  end
 end