activity: add helper to fetch an activity's parent
authorWilliam Pitcock <nenolod@dereferenced.org>
Thu, 25 Oct 2018 02:47:55 +0000 (02:47 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Thu, 25 Oct 2018 02:47:55 +0000 (02:47 +0000)
lib/pleroma/activity.ex

index bed96861f893043f8651401fb6cc268aa91c2d5a..c065f3b6ce690a688ead5a087135f46e44f13ba8 100644 (file)
@@ -82,4 +82,10 @@ defmodule Pleroma.Activity do
   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
+
+  def get_in_reply_to_activity(%Activity{data: %{"object" => %{"inReplyTo" => ap_id}}}) do
+    get_create_activity_by_object_ap_id(ap_id)
+  end
+
+  def get_in_reply_to_activity(_), do: nil
 end