Skip to content

Conversation

erikjohnston
Copy link
Member

@erikjohnston erikjohnston commented Sep 8, 2025

Follows on from #797, which I merged Too Soon

c.f. element-hq/synapse#18823

@erikjohnston erikjohnston requested review from a team as code owners September 8, 2025 10:04
@erikjohnston erikjohnston removed request for a team September 8, 2025 10:04

// Check bob is still invited by doing an initial sync
bob.MustSyncUntil(t, client.SyncReq{}, client.SyncInvitedTo(bob.UserID, roomID2))
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:

		t.Run("Non-inviter user cannot rescind invite over federation", func(t *testing.T) {
			t.Parallel()

			// First create a room that Bob is in. This is so that later we can
			// send a message to test that Bob doesn't see the rescission.
			roomID1 := alice.MustCreateRoom(t, map[string]interface{}{
				"preset": "private_chat",
				"invite": []string{bob.UserID},
			})
			since := bob.MustSyncUntil(t, client.SyncReq{}, client.SyncInvitedTo(bob.UserID, roomID1))
			bob.MustJoinRoom(t, roomID1, []spec.ServerName{})

			// Second room which Alice and Alice2 join, Alice2 invites Bob and
			// then Alice kicks him.
			roomID2 := alice.MustCreateRoom(t, map[string]interface{}{
				"preset": "private_chat",
				"invite": []string{alice2.UserID},
			})
			alice2.MustSyncUntil(t, client.SyncReq{}, client.SyncInvitedTo(alice2.UserID, roomID2))
			alice2.MustJoinRoom(t, roomID2, []spec.ServerName{})

			// `alice2` invites bob
			alice2.MustInviteRoom(t, roomID2, bob.UserID)
			bob.MustSyncUntil(t, client.SyncReq{}, client.SyncInvitedTo(bob.UserID, roomID2))

			// `alice`, not the original inviter (`alice2`), kicks bob.
			alice.MustDo(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID2, "kick"},
				client.WithJSONBody(t, map[string]interface{}{
					"user_id": bob.UserID,
					"reason":  "testing",
				}),
			)

			// Check bob *doesn't* see the rescission.  We do this by sending a message in
			// `roomID1` (on the same homeserver as `roomID2`) and checking that once Bob
			// receives that new message in `roomID1` he still hasn't seen the leave for `roomID2`.
			//
			// Ideally, bob could see the rescission, but currently we have no way to auth
			// that over federation.
			eventID := alice.SendEventSynced(t, roomID1, b.Event{
				Type: "m.room.message",
				Content: map[string]interface{}{
					"body":    "1",
					"msgtype": "m.text",
				},
				Sender: alice.UserID,
			})
			bob.MustSyncUntil(t, client.SyncReq{Since: since}, client.SyncTimelineHasEventID(roomID1, eventID))

			// Check bob is still invited to `roomID2` by doing an initial sync
			bob.MustSyncUntil(t, client.SyncReq{}, client.SyncInvitedTo(bob.UserID, roomID2))
		})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants