You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2026-01-03 23:22:30 +03:00
Remove guest rooms array; replace with a peeking SyncApi
After much discussion, the HS will now behave the same for guests/non-guests wrt joining a room (you get the entire room state on join). This leave "peeking" which never triggers a join. This can be implemented for guests by doing a room initial sync followed by a specific /events poll with a specific room_id. This means there are 2 sync streams: /sync and the peek /events. Architected so you can only have 1 peek stream in progress at a time (if this were arbitrary we'd quickly run into concurrent in-flight browser request limits (5).
This commit is contained in:
@@ -153,7 +153,7 @@ function MatrixClient(opts) {
|
||||
}
|
||||
this._syncState = null;
|
||||
this._syncingRetry = null;
|
||||
this._guestRooms = null;
|
||||
this._peekSync = null;
|
||||
this._isGuest = false;
|
||||
this._ongoingScrollbacks = {};
|
||||
}
|
||||
@@ -605,6 +605,7 @@ MatrixClient.prototype.joinRoom = function(roomIdOrAlias, opts, callback) {
|
||||
opts = opts || {
|
||||
syncRoom: true
|
||||
};
|
||||
|
||||
var room = this.getRoom(roomIdOrAlias);
|
||||
if (room && room.hasMembershipState(this.credentials.userId, "join")) {
|
||||
return q(room);
|
||||
@@ -1939,11 +1940,16 @@ MatrixClient.prototype.registerGuest = function(opts, callback) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Set a list of rooms the Guest is interested in receiving events from.
|
||||
* @param {String[]} roomIds A list of room IDs.
|
||||
* Peek into a room and receive updates about the room. This only works if the
|
||||
* history visibility for the room is world_readable.
|
||||
* @param {String} roomId The room to attempt to peek into.
|
||||
*/
|
||||
MatrixClient.prototype.setGuestRooms = function(roomIds) {
|
||||
this._guestRooms = roomIds;
|
||||
MatrixClient.prototype.peekInRoom = function(roomId) {
|
||||
if (this._peekSync) {
|
||||
this._peekSync.stopPeeking();
|
||||
}
|
||||
this._peekSync = new SyncApi(this);
|
||||
this._peekSync.peek(roomId);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
21
lib/sync.js
21
lib/sync.js
@@ -139,6 +139,23 @@ SyncApi.prototype.syncLeftRooms = function() {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Peek into a room. This will result in the room in question being synced so it
|
||||
* is accessible via getRooms(). Live updates for the room will be provided.
|
||||
* @param {string} roomId The room ID to peek into.
|
||||
*/
|
||||
SyncApi.prototype.peek = function(roomId) {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Stop polling for updates in the peeked room. NOPs if there is no room being
|
||||
* peeked.
|
||||
*/
|
||||
SyncApi.prototype.stopPeeking = function() {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Main entry point
|
||||
*/
|
||||
@@ -556,7 +573,9 @@ SyncApi.prototype._getGuestFilter = function() {
|
||||
}
|
||||
return JSON.stringify({
|
||||
room: {
|
||||
rooms: guestRooms
|
||||
timeline: {
|
||||
limit: 20
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user