From d4de38e8fff3154259e08292de60900488c210d6 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Fri, 30 Jun 2017 16:30:19 +0200 Subject: [PATCH] Order conversation fetches like GS does. --- lib/pleroma/web/activity_pub/activity_pub.ex | 3 ++- test/web/activity_pub/activity_pub_test.exs | 2 +- test/web/twitter_api/twitter_api_test.exs | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 74df3c469..25560f4c9 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -77,7 +77,8 @@ def unfollow(follower, followed, local \\ true) do def fetch_activities_for_context(context) do query = from activity in Activity, - where: fragment("? @> ?", activity.data, ^%{ context: context }) + where: fragment("? @> ?", activity.data, ^%{ context: context }), + order_by: [desc: :inserted_at] Repo.all(query) end diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 8e7473591..0dfaaa99c 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -75,7 +75,7 @@ test "retrieves activities that have a given context" do activities = ActivityPub.fetch_activities_for_context("2hu") - assert activities == [activity, activity_two] + assert activities == [activity_two, activity] end end diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index 4708fe093..f591bef4a 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -227,8 +227,8 @@ test "fetch statuses in a context using the conversation id" do statuses = TwitterAPI.fetch_conversation(user, object.id) assert length(statuses) == 2 - assert Enum.at(statuses, 0)["id"] == activity.id - assert Enum.at(statuses, 1)["id"] == activity_two.id + assert Enum.at(statuses, 1)["id"] == activity.id + assert Enum.at(statuses, 0)["id"] == activity_two.id end test "upload a file" do