Add experimental code to fetch an event's context

This commit is contained in:
Danila Fedorin 2021-09-07 13:28:28 -07:00
parent 299abe3e7e
commit 8592fcf8c7

View file

@ -110,6 +110,18 @@ export class Room extends BaseRoom {
} }
} }
async fetchContext(eventId, log = null) {
const response = await this._hsApi.context(this._roomId, eventId, {}, {log}).response();
await this._fetchEvents(response, async (txn, gapWriter) => {
// Just in case we somehow receive remote echoes during event fetch
const beforeExtra = await this._writeGapFill(response.events_before, txn, log);
const afterExtra = await this._writeGapFill(response.events_after, txn, log);
beforeExtra.append(...afterExtra);
const gapResult = await gapWriter.writeContext(response, txn, log);
return { extraGapFillChanges: beforeExtra, gapResult };
}, log);
}
/** @package */ /** @package */
async writeSync(roomResponse, isInitialSync, {summaryChanges, decryptChanges, roomEncryption, retryEntries}, txn, log) { async writeSync(roomResponse, isInitialSync, {summaryChanges, decryptChanges, roomEncryption, retryEntries}, txn, log) {
log.set("id", this.id); log.set("id", this.id);