diff options
author | lain <lain@soykaf.club> | 2018-03-27 17:43:08 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2018-03-27 17:43:08 +0200 |
commit | ff7afe46b9b08fc59ea1451add167f0856d15dbf (patch) | |
tree | 07a0d06a452e353d65b9e27fbbb28e8a29d6ef62 | |
parent | d2099c849d355a9b8d3b1f2e0342dfe3c7e3497c (diff) | |
download | pleroma-ff7afe46b9b08fc59ea1451add167f0856d15dbf.tar.gz |
Don't try to fetch OP if none is there.
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/status_view.ex | 6 | ||||
-rw-r--r-- | test/web/mastodon_api/status_view_test.exs | 8 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 62b967e02..822a6800c 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -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"] || []) diff --git a/test/web/mastodon_api/status_view_test.exs b/test/web/mastodon_api/status_view_test.exs index a58f729a6..b08127639 100644 --- a/test/web/mastodon_api/status_view_test.exs +++ b/test/web/mastodon_api/status_view_test.exs @@ -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. |