activitypub: utils: wrap Note objects in a Create when extracting mentions
authorWilliam Pitcock <nenolod@dereferenced.org>
Fri, 9 Nov 2018 08:55:52 +0000 (08:55 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Fri, 9 Nov 2018 09:01:40 +0000 (09:01 +0000)
lib/pleroma/web/activity_pub/utils.ex

index a9a4c895b60b835d966df77422b7d0daa7fa3a2c..d438236c7f81fc8aabba97fa4a683701a5ec2704 100644 (file)
@@ -95,6 +95,17 @@ defmodule Pleroma.Web.ActivityPub.Utils do
     "#{Web.base_url()}/#{type}/#{UUID.generate()}"
   end
 
+  def get_notified_from_object(%{"type" => type} = object) when type == "Note" do
+    fake_create_activity = %{
+      "to" => object["to"],
+      "cc" => object["cc"],
+      "type" => "Create",
+      "object" => object
+    }
+
+    Notification.get_notified_from_activity(%Activity{data: fake_create_activity}, false)
+  end
+
   def get_notified_from_object(object) do
     Notification.get_notified_from_activity(%Activity{data: object}, false)
   end