-
-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include redundant members in most timeline filters #4329
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
|
||
const userId = "@alice:localhost"; | ||
const userName = "Alice"; | ||
const altName = "meow"; | ||
const accessToken = "aseukfgwef"; | ||
const roomId = "!foo:bar"; | ||
const otherUserId = "@bob:localhost"; | ||
|
@@ -747,7 +748,9 @@ | |
}; | ||
}); | ||
req.check((request) => { | ||
expect(request.queryParams?.filter).toEqual(JSON.stringify(Filter.LAZY_LOADING_MESSAGES_FILTER)); | ||
expect(request.queryParams?.filter).toEqual( | ||
JSON.stringify(Filter.LAZY_LOADING_MESSAGES_REDUNDANT_FILTER), | ||
); | ||
}); | ||
|
||
await Promise.all([ | ||
|
@@ -1076,6 +1079,150 @@ | |
httpBackend.flushAllExpected(), | ||
]); | ||
}); | ||
it("event will have a sender profile if /context and /messages returns state", async () => { | ||
// @ts-ignore | ||
client.clientOpts.lazyLoadMembers = false; | ||
const room = client.getRoom(roomId)!; | ||
const timelineSet = room.getTimelineSets()[0]; | ||
|
||
httpBackend | ||
.when("GET", "/rooms/!foo%3Abar/context/" + encodeURIComponent(EVENTS[0].event_id!)) | ||
.respond(200, function () { | ||
return { | ||
start: "start_token0", | ||
events_before: [], | ||
event: EVENTS[0], | ||
events_after: [], | ||
end: "end_token0", | ||
state: [ | ||
utils.mkMembership({ | ||
mship: KnownMembership.Join, | ||
room: roomId, | ||
user: userId, | ||
name: altName, | ||
event: true, | ||
}), | ||
utils.mkMembership({ | ||
mship: KnownMembership.Join, | ||
room: roomId, | ||
user: otherUserId, | ||
event: true, | ||
}), | ||
], | ||
}; | ||
}); | ||
|
||
// Server thinks the client has cached the member event | ||
httpBackend | ||
.when("GET", "/rooms/!foo%3Abar/messages") | ||
.check(function (req) { | ||
const params = req.queryParams!; | ||
expect(params.filter).toBeNull(); | ||
Check failure on line 1120 in spec/integ/matrix-client-event-timeline.spec.ts GitHub Actions / Jest [integ] (Node lts/*)MatrixClient event timelines › paginateEventTimeline › event will have a sender profile if /context and /messages returns state
Check failure on line 1120 in spec/integ/matrix-client-event-timeline.spec.ts GitHub Actions / Jest [integ] (Node 22)MatrixClient event timelines › paginateEventTimeline › event will have a sender profile if /context and /messages returns state
|
||
}) | ||
.respond(200, function () { | ||
return { | ||
chunk: [EVENTS[1], EVENTS[2]], | ||
end: "start_token1", | ||
state: [ | ||
utils.mkMembership({ | ||
mship: KnownMembership.Join, | ||
room: roomId, | ||
user: userId, | ||
name: altName, | ||
event: true, | ||
}), | ||
utils.mkMembership({ | ||
mship: KnownMembership.Join, | ||
room: roomId, | ||
user: otherUserId, | ||
event: true, | ||
}), | ||
], | ||
}; | ||
}); | ||
|
||
let tl: EventTimeline; | ||
return Promise.all([ | ||
client | ||
.getEventTimeline(timelineSet, EVENTS[0].event_id!) | ||
.then(function (tl0) { | ||
tl = tl0!; | ||
return client.paginateEventTimeline(tl, { backwards: true }); | ||
}) | ||
.then(function (success) { | ||
expect(success).toBeTruthy(); | ||
expect(tl!.getEvents()[0].sender?.name).toEqual(altName); | ||
expect(tl!.getEvents()[1].sender?.name).toEqual(altName); | ||
expect(tl!.getEvents()[2].sender?.name).toEqual(altName); | ||
}), | ||
httpBackend.flushAllExpected(), | ||
]); | ||
}); | ||
|
||
it("event will sometimes have no sender profile if /context but not /messages doesn't return state", async () => { | ||
// @ts-ignore | ||
client.clientOpts.lazyLoadMembers = true; | ||
const room = client.getRoom(roomId)!; | ||
const timelineSet = room.getTimelineSets()[0]; | ||
|
||
httpBackend | ||
.when("GET", "/rooms/!foo%3Abar/context/" + encodeURIComponent(EVENTS[0].event_id!)) | ||
.respond(200, function () { | ||
return { | ||
start: "start_token0", | ||
events_before: [], | ||
event: EVENTS[0], | ||
events_after: [], | ||
end: "end_token0", | ||
state: [ | ||
utils.mkMembership({ | ||
mship: KnownMembership.Join, | ||
room: roomId, | ||
user: userId, | ||
name: altName, | ||
event: true, | ||
}), | ||
], | ||
}; | ||
}); | ||
|
||
// Lazy loaded members with redundant members removed since the server just sent it above | ||
|
||
httpBackend | ||
.when("GET", "/rooms/!foo%3Abar/messages") | ||
.check(function (req) { | ||
const params = req.queryParams!; | ||
expect(params.filter).toEqual(JSON.stringify(Filter.LAZY_LOADING_MESSAGES_REDUNDANT_FILTER)); | ||
}) | ||
.respond(200, function () { | ||
return { | ||
chunk: [EVENTS[1], EVENTS[2]], | ||
end: "start_token1", | ||
}; | ||
}); | ||
|
||
logger.log("hello world"); | ||
let tl: EventTimeline; | ||
return Promise.all([ | ||
client | ||
.getEventTimeline(timelineSet, EVENTS[0].event_id!) | ||
.then(function (tl0) { | ||
tl = tl0!; | ||
return client.paginateEventTimeline(tl, { backwards: true }); | ||
}) | ||
.then(function (success) { | ||
logger.log("abcd, ", tl!.getEvents()[0].sender); | ||
expect(success).toBeTruthy(); | ||
expect(tl!.getEvents().length).toEqual(3); | ||
expect(tl!.getEvents()[0].sender?.name).toEqual(altName); | ||
expect(tl!.getEvents()[1].sender?.name).toEqual(altName); | ||
|
||
// Lost track of the member state? | ||
expect(tl!.getEvents()[2].sender).toBeNull(); | ||
Check failure on line 1221 in spec/integ/matrix-client-event-timeline.spec.ts GitHub Actions / Jest [integ] (Node lts/*)MatrixClient event timelines › paginateEventTimeline › event will sometimes have no sender profile if /context but not /messages doesn't return state
Check failure on line 1221 in spec/integ/matrix-client-event-timeline.spec.ts GitHub Actions / Jest [integ] (Node 22)MatrixClient event timelines › paginateEventTimeline › event will sometimes have no sender profile if /context but not /messages doesn't return state
|
||
}), | ||
httpBackend.flushAllExpected(), | ||
]); | ||
}); | ||
}); | ||
|
||
it("should ensure thread events are ordered correctly", async () => { | ||
|
@@ -1781,6 +1928,7 @@ | |
expect(request.queryParams?.filter).toEqual( | ||
JSON.stringify({ | ||
lazy_load_members: true, | ||
include_redundant_members: true, | ||
}), | ||
); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Things exported in the public API should have documentation