Merge branch 'bug/790-repeated-posts-that-are-replies-have-in-reply-to-id-null' into 'develop'

in_reply_to_id - null

See merge request pleroma/pleroma!1037
This commit is contained in:
kaniini 2019-04-12 02:21:32 +00:00
commit 9825a94391
2 changed files with 49 additions and 2 deletions

View File

@ -301,8 +301,10 @@ def render("attachment.json", %{attachment: attachment}) do
end
def get_reply_to(activity, %{replied_to_activities: replied_to_activities}) do
_id = activity.data["object"]["inReplyTo"]
replied_to_activities[activity.data["object"]["inReplyTo"]]
with nil <- replied_to_activities[activity.data["object"]["inReplyTo"]] do
# If user didn't participate in the thread
Activity.get_in_reply_to_activity(activity)
end
end
def get_reply_to(%{data: %{"object" => object}}, _) do

View File

@ -2653,4 +2653,49 @@ test "deletes a scheduled activity", %{conn: conn} do
assert %{"error" => "Record not found"} = json_response(res_conn, 404)
end
end
test "Repeated posts that are replies incorrectly have in_reply_to_id null", %{conn: conn} do
user1 = insert(:user)
user2 = insert(:user)
user3 = insert(:user)
{:ok, replied_to} = TwitterAPI.create_status(user1, %{"status" => "cofe"})
# Reply to status from another user
conn1 =
conn
|> assign(:user, user2)
|> post("/api/v1/statuses", %{"status" => "xD", "in_reply_to_id" => replied_to.id})
assert %{"content" => "xD", "id" => id} = json_response(conn1, 200)
activity = Activity.get_by_id(id)
assert activity.data["object"]["inReplyTo"] == replied_to.data["object"]["id"]
assert activity.data["object"]["inReplyToStatusId"] == replied_to.id
# Reblog from the third user
conn2 =
conn
|> assign(:user, user3)
|> post("/api/v1/statuses/#{activity.id}/reblog")
assert %{"reblog" => %{"id" => id, "reblogged" => true, "reblogs_count" => 1}} =
json_response(conn2, 200)
assert to_string(activity.id) == id
# Getting third user status
conn3 =
conn
|> assign(:user, user3)
|> get("api/v1/timelines/home")
[reblogged_activity] = json_response(conn3, 200)
assert reblogged_activity["reblog"]["in_reply_to_id"] == replied_to.id
replied_to_user = User.get_by_ap_id(replied_to.data["actor"])
assert reblogged_activity["reblog"]["in_reply_to_account_id"] == replied_to_user.id
end
end