activity: clean up direct use of object data
authorWilliam Pitcock <nenolod@dereferenced.org>
Sun, 25 Nov 2018 18:44:04 +0000 (18:44 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Tue, 4 Dec 2018 04:52:09 +0000 (04:52 +0000)
lib/pleroma/activity.ex

index c065f3b6ce690a688ead5a087135f46e44f13ba8..3c7e150ee308e2478ebf727fb65bd37e6220fb07 100644 (file)
@@ -1,6 +1,6 @@
 defmodule Pleroma.Activity do
   use Ecto.Schema
-  alias Pleroma.{Repo, Activity, Notification}
+  alias Pleroma.{Repo, Activity, Notification, Object}
   import Ecto.Query
 
   schema "activities" do
@@ -83,9 +83,13 @@ defmodule Pleroma.Activity do
   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
+  defp get_in_reply_to_activity_from_object(%Object{data: %{"inReplyTo" => ap_id}}) do
     get_create_activity_by_object_ap_id(ap_id)
   end
 
-  def get_in_reply_to_activity(_), do: nil
+  defp get_in_reply_to_activity_from_object(_), do: nil
+
+  def get_in_reply_to_activity(%Activity{data: %{"object" => object}}) do
+    get_in_reply_to_activity_from_object(Object.normalize(object))
+  end
 end