Use the preloaded object in tag queries
[akkoma] / lib / pleroma / notification.ex
index caa6b755e40027a0737d10e146babc0d6a7738c2..b357d5399d024cc0968acc5b8719206a2306184c 100644 (file)
@@ -98,6 +98,14 @@ defmodule Pleroma.Notification do
     |> Repo.delete_all()
   end
 
+  def destroy_multiple(%{id: user_id} = _user, ids) do
+    from(n in Notification,
+      where: n.id in ^ids,
+      where: n.user_id == ^user_id
+    )
+    |> Repo.delete_all()
+  end
+
   def dismiss(%{id: user_id} = _user, id) do
     notification = Repo.get(Notification, id)
 
@@ -142,6 +150,7 @@ defmodule Pleroma.Notification do
       []
       |> Utils.maybe_notify_to_recipients(activity)
       |> Utils.maybe_notify_mentioned_recipients(activity)
+      |> Utils.maybe_notify_subscribers(activity)
       |> Enum.uniq()
 
     User.get_users_from_set(recipients, local_only)
@@ -163,19 +172,16 @@ defmodule Pleroma.Notification do
     User.blocks?(user, %{ap_id: actor})
   end
 
-  def skip?(:local, %{local: true}, user) do
-    user.info.notification_settings["local"] == false
-  end
+  def skip?(:local, %{local: true}, %{info: %{notification_settings: %{"local" => false}}}),
+    do: true
 
-  def skip?(:local, %{local: false}, user) do
-    user.info.notification_settings["remote"] == false
-  end
+  def skip?(:local, %{local: false}, %{info: %{notification_settings: %{"remote" => false}}}),
+    do: true
 
   def skip?(:muted, activity, user) do
     actor = activity.data["actor"]
 
-    User.mutes?(user, %{ap_id: actor}) or
-      CommonAPI.thread_muted?(user, activity)
+    User.mutes?(user, %{ap_id: actor}) or CommonAPI.thread_muted?(user, activity)
   end
 
   def skip?(
@@ -194,7 +200,7 @@ defmodule Pleroma.Notification do
     User.following?(user, followed)
   end
 
-  def skip?(:recently_followed, activity, user) do
+  def skip?(:recently_followed, %{data: %{"type" => "Follow"}} = activity, user) do
     actor = activity.data["actor"]
 
     Notification.for_user(user)