diff --git a/src/matrix/room/BaseRoom.js b/src/matrix/room/BaseRoom.js index 4b6fccd7..c8afc3d3 100644 --- a/src/matrix/room/BaseRoom.js +++ b/src/matrix/room/BaseRoom.js @@ -311,6 +311,22 @@ export class BaseRoom extends EventEmitter { } } + async _fetchContext(eventId, log = null) { + const response = await this._hsApi.context(this._roomId, eventId, {}, {log}).response(); + let contextEvent = null; + await this._fetchEvents(async (txn, gapWriter) => { + // Just in case we somehow receive remote echoes during event fetch + // Keep events in order just in case. + const allEvents = response.events_before.slice().reverse(); + allEvents.push(response.event, ...response.events_after); + const extraGapFillChanges = await this._writeGapFill(allEvents, txn, log); + const gapResult = await gapWriter.writeContext(response, txn, log); + contextEvent = gapResult.contextEvent; + return { extraGapFillChanges, gapResult }; + }, log); + return contextEvent; + } + /** @public */ fillGap(fragmentEntry, amount, log = null) { // TODO move some/all of this out of BaseRoom diff --git a/src/matrix/room/Room.js b/src/matrix/room/Room.js index ec887b23..cab0e13b 100644 --- a/src/matrix/room/Room.js +++ b/src/matrix/room/Room.js @@ -110,22 +110,6 @@ export class Room extends BaseRoom { } } - async _fetchContext(eventId, log = null) { - const response = await this._hsApi.context(this._roomId, eventId, {}, {log}).response(); - let contextEvent = null; - await this._fetchEvents(async (txn, gapWriter) => { - // Just in case we somehow receive remote echoes during event fetch - // Keep events in order just in case. - const allEvents = response.events_before.slice().reverse(); - allEvents.push(response.event, ...response.events_after); - const extraGapFillChanges = await this._writeGapFill(allEvents, txn, log); - const gapResult = await gapWriter.writeContext(response, txn, log); - contextEvent = gapResult.contextEvent; - return { extraGapFillChanges, gapResult }; - }, log); - return contextEvent; - } - /** @package */ async writeSync(roomResponse, isInitialSync, {summaryChanges, decryptChanges, roomEncryption, retryEntries}, txn, log) { log.set("id", this.id);