From d1c6b743de5266876fc2e565dc6c7d299cc57a57 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Tue, 26 Oct 2021 17:38:31 -0500 Subject: [PATCH 1/2] Allow sending no ?state_events_at_start when user is already part of the current room state Synapse changes in https://github.com/matrix-org/synapse/pull/11188 --- tests/msc2716_test.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/msc2716_test.go b/tests/msc2716_test.go index dda40892..f2e404e4 100644 --- a/tests/msc2716_test.go +++ b/tests/msc2716_test.go @@ -485,6 +485,48 @@ func TestImportHistoricalMessages(t *testing.T) { }) }) + t.Run("Should be able to send a batch without any state_events_at_start - user already joined in the current room state", func(t *testing.T) { + t.Parallel() + + roomID := as.CreateRoom(t, createPublicRoomOpts) + alice.JoinRoom(t, roomID, nil) + + // Create the "live" event we are going to import our historical events next to + eventIDsBefore := createMessagesInRoom(t, alice, roomID, 1) + eventIdBefore := eventIDsBefore[0] + timeAfterEventBefore := time.Now() + + // Import a historical event + batchSendRes := batchSendHistoricalMessages( + t, + as, + roomID, + eventIdBefore, + "", + // This is the key thing we're testing, + // no `?state_events_at_start` given + make([]map[string]interface{}, 0), + createMessageEventsForBatchSendRequest([]string{alice.UserID}, timeAfterEventBefore, 3), + // Status + 200, + ) + batchSendResBody := client.ParseJSON(t, batchSendRes) + historicalEventIDs := client.GetJSONFieldStringArray(t, batchSendResBody, "event_ids") + + messagesRes := alice.MustDoFunc(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "messages"}, client.WithContentType("application/json"), client.WithQueries(url.Values{ + "dir": []string{"b"}, + "limit": []string{"100"}, + })) + + must.MatchResponse(t, messagesRes, match.HTTPResponse{ + JSON: []match.JSON{ + match.JSONCheckOffAllowUnwanted("chunk", makeInterfaceSlice(historicalEventIDs), func(r gjson.Result) interface{} { + return r.Get("event_id").Str + }, nil), + }, + }) + }) + t.Run("TODO: Test if historical avatar/display name set back in time are picked up on historical messages", func(t *testing.T) { t.Skip("Skipping until implemented") // TODO: Try adding avatar and displayName and see if historical messages get this info From 400b9e47d9d2f5ef051202ad976a727a3e1e537b Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Tue, 26 Oct 2021 17:52:53 -0500 Subject: [PATCH 2/2] Better comment --- tests/msc2716_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/msc2716_test.go b/tests/msc2716_test.go index f2e404e4..04f337ad 100644 --- a/tests/msc2716_test.go +++ b/tests/msc2716_test.go @@ -503,8 +503,8 @@ func TestImportHistoricalMessages(t *testing.T) { roomID, eventIdBefore, "", - // This is the key thing we're testing, - // no `?state_events_at_start` given + // The key thing we're testing here is that we can still batch send + // messages when no `state_events_at_start` are given make([]map[string]interface{}, 0), createMessageEventsForBatchSendRequest([]string{alice.UserID}, timeAfterEventBefore, 3), // Status