ostatus: we need to include the original author of a message as a mention
[akkoma] / lib / pleroma / user.ex
index b27397e13956fc5ae16e638ff3e2ef69c1e21d2b..856f27e1013a160701c0ef7a3991c4cd5e5b66fc 100644 (file)
@@ -449,13 +449,29 @@ defmodule Pleroma.User do
     update_and_set_cache(cs)
   end
 
+  def get_notified_from_activity_query(to) do
+    from(
+      u in User,
+      where: u.ap_id in ^to,
+      where: u.local == true
+    )
+  end
+
+  def get_notified_from_activity(%Activity{recipients: to, data: %{"type" => "Announce"} = data}) do
+    object = Object.get_by_ap_id(data["object"])
+
+    # ensure that the actor who published the announced object appears only once
+    to =
+      (to ++ [object.data["actor"]])
+      |> Enum.uniq()
+
+    query = get_notified_from_activity_query(to)
+
+    Repo.all(query)
+  end
+
   def get_notified_from_activity(%Activity{recipients: to}) do
-    query =
-      from(
-        u in User,
-        where: u.ap_id in ^to,
-        where: u.local == true
-      )
+    query = get_notified_from_activity_query(to)
 
     Repo.all(query)
   end