Don't try to fetch OP if none is there.
authorlain <lain@soykaf.club>
Tue, 27 Mar 2018 15:43:08 +0000 (17:43 +0200)
committerlain <lain@soykaf.club>
Tue, 27 Mar 2018 15:43:08 +0000 (17:43 +0200)
lib/pleroma/web/mastodon_api/views/status_view.ex
test/web/mastodon_api/status_view_test.exs

index 62b967e02ffe770aef4196c5a7168a2527487078..822a6800cd59b6b4b94d1f119dac0d86ace217f2 100644 (file)
@@ -73,7 +73,11 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
     created_at = Utils.to_masto_date(object["published"])
 
     # TODO: Add cached version.
-    reply_to = Activity.get_create_activity_by_object_ap_id(object["inReplyTo"])
+    reply_to = if object["inReplyTo"] && object["inReplyTo"] != "" do
+      Activity.get_create_activity_by_object_ap_id(object["inReplyTo"])
+    else
+      nil
+    end
     reply_to_user = reply_to && User.get_cached_by_ap_id(reply_to.data["actor"])
 
     emojis = (activity.data["object"]["emoji"] || [])
index a58f729a617a85e1bcf99442dc4eb3ad2f5108cb..b0812763971bd54e53176b5eb5a1e6ce3c112fa3 100644 (file)
@@ -54,6 +54,14 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
     assert status == expected
   end
 
+  test "a reply" do
+    note = insert(:note_activity)
+    user = insert(:user)
+    {:ok, activity} = CommonAPI.post(user, %{"status" => "he", "in_reply_to_status_id" => note.id})
+
+    assert activity.data["object"]["inReplyTo"] == note.data["object"]["id"]
+  end
+
   test "contains mentions" do
     incoming = File.read!("test/fixtures/incoming_reply_mastodon.xml")
     # a user with this ap id might be in the cache.