activity: add normalize() to find a complete activity given either URI or partial...
authorWilliam Pitcock <nenolod@dereferenced.org>
Mon, 18 Jun 2018 20:54:59 +0000 (20:54 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Wed, 27 Jun 2018 13:07:12 +0000 (13:07 +0000)
lib/pleroma/activity.ex

index dd680512548f622bea2dd58f816df0c856405206..bed96861f893043f8651401fb6cc268aa91c2d5a 100644 (file)
@@ -78,4 +78,8 @@ defmodule Pleroma.Activity do
   end
 
   def get_create_activity_by_object_ap_id(_), do: nil
+
+  def normalize(obj) when is_map(obj), do: Activity.get_by_ap_id(obj["id"])
+  def normalize(ap_id) when is_binary(ap_id), do: Activity.get_by_ap_id(ap_id)
+  def normalize(_), do: nil
 end