Order conversation fetches like GS does.
authorRoger Braun <roger@rogerbraun.net>
Fri, 30 Jun 2017 14:30:19 +0000 (16:30 +0200)
committerRoger Braun <roger@rogerbraun.net>
Fri, 30 Jun 2017 14:30:19 +0000 (16:30 +0200)
lib/pleroma/web/activity_pub/activity_pub.ex
test/web/activity_pub/activity_pub_test.exs
test/web/twitter_api/twitter_api_test.exs

index 74df3c469c438e7620fdedb58c7572c6c852270c..25560f4c96f5e7bc071a5011eb1d6eeb78a1fa57 100644 (file)
@@ -77,7 +77,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub 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
 
index 8e747359194a630799085098c1490096176d2d5e..0dfaaa99cd0963c88637128afe715cf0f6304704 100644 (file)
@@ -75,7 +75,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
 
       activities = ActivityPub.fetch_activities_for_context("2hu")
 
-      assert activities == [activity, activity_two]
+      assert activities == [activity_two, activity]
     end
   end
 
index 4708fe093ff8e4700666aaee473ea57bf31b8551..f591bef4a02ad6f1cbb772d25095208e2047e4ff 100644 (file)
@@ -227,8 +227,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest 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