diff --git a/src/client.ts b/src/client.ts index 058f22250..abf92b6eb 100644 --- a/src/client.ts +++ b/src/client.ts @@ -521,7 +521,7 @@ interface IMessagesResponse { state: IStateEvent[]; } -interface IRequestTokenResponse { +export interface IRequestTokenResponse { sid: string; submit_url?: string; } @@ -600,7 +600,7 @@ interface IUserDirectoryResponse { limited: boolean; } -interface IMyDevice { +export interface IMyDevice { device_id: string; display_name?: string; last_seen_ip?: string; @@ -5078,7 +5078,7 @@ export class MatrixClient extends EventEmitter { email: string, clientSecret: string, sendAttempt: number, - nextLink: string, + nextLink?: string, ): Promise { return this.requestTokenFromEndpoint( "/account/password/email/requestToken", @@ -7991,10 +7991,7 @@ export class MatrixClient extends EventEmitter { autoJoinOnly?: boolean, limit?: number, batch?: string, - ): Promise<{ - rooms: ISpaceSummaryRoom[]; - events: ISpaceSummaryEvent[]; - }> { + ): Promise<{rooms: ISpaceSummaryRoom[], events: ISpaceSummaryEvent[]}> { const path = utils.encodeUri("/rooms/$roomId/spaces", { $roomId: roomId, }); diff --git a/src/crypto/EncryptionSetup.ts b/src/crypto/EncryptionSetup.ts index 1a36efb70..442149b90 100644 --- a/src/crypto/EncryptionSetup.ts +++ b/src/crypto/EncryptionSetup.ts @@ -59,7 +59,7 @@ export class EncryptionSetupBuilder { * @param {Object.} accountData pre-existing account data, will only be read, not written. * @param {CryptoCallbacks} delegateCryptoCallbacks crypto callbacks to delegate to if the key isn't in cache yet */ - constructor(accountData: Record, delegateCryptoCallbacks: ICryptoCallbacks) { + constructor(accountData: Record, delegateCryptoCallbacks?: ICryptoCallbacks) { this.accountDataClientAdapter = new AccountDataClientAdapter(accountData); this.crossSigningCallbacks = new CrossSigningCallbacks(); this.ssssCryptoCallbacks = new SSSSCryptoCallbacks(delegateCryptoCallbacks); @@ -351,7 +351,7 @@ class CrossSigningCallbacks implements ICryptoCallbacks, ICacheCallbacks { class SSSSCryptoCallbacks { private readonly privateKeys = new Map(); - constructor(private readonly delegateCryptoCallbacks: ICryptoCallbacks) {} + constructor(private readonly delegateCryptoCallbacks?: ICryptoCallbacks) {} public async getSecretStorageKey( { keys }: { keys: Record }, diff --git a/src/models/MSC3089TreeSpace.ts b/src/models/MSC3089TreeSpace.ts index 80ea2b365..27bfe113e 100644 --- a/src/models/MSC3089TreeSpace.ts +++ b/src/models/MSC3089TreeSpace.ts @@ -18,7 +18,7 @@ import { MatrixClient } from "../client"; import { EventType, IEncryptedFile, MsgType, UNSTABLE_MSC3089_BRANCH, UNSTABLE_MSC3089_LEAF } from "../@types/event"; import { Room } from "./room"; import { logger } from "../logger"; -import { MatrixEvent } from "./event"; +import { IContent, MatrixEvent } from "./event"; import { averageBetweenStrings, DEFAULT_ALPHABET, @@ -451,11 +451,14 @@ export class MSC3089TreeSpace { * @param {string} name The name of the file. * @param {ArrayBuffer} encryptedContents The encrypted contents. * @param {Partial} info The encrypted file information. + * @param {IContent} additionalContent Optional event content fields to include in the message. * @returns {Promise} Resolves when uploaded. */ public async createFile( name: string, - encryptedContents: ArrayBuffer, info: Partial, + encryptedContents: ArrayBuffer, + info: Partial, + additionalContent?: IContent, ): Promise { const mxc = await this.client.uploadContent(new Blob([encryptedContents]), { includeFilename: false, @@ -464,6 +467,7 @@ export class MSC3089TreeSpace { info.url = mxc; const res = await this.client.sendMessage(this.roomId, { + ...(additionalContent ?? {}), msgtype: MsgType.File, body: name, url: mxc, diff --git a/src/webrtc/callEventHandler.ts b/src/webrtc/callEventHandler.ts index 68aaffd0a..0ce247263 100644 --- a/src/webrtc/callEventHandler.ts +++ b/src/webrtc/callEventHandler.ts @@ -80,7 +80,7 @@ export class CallEventHandler { continue; } try { - this.handleCallEvent(e); + await this.handleCallEvent(e); } catch (e) { logger.error("Caught exception handling call event", e); } @@ -100,7 +100,7 @@ export class CallEventHandler { if (event.isBeingDecrypted() || event.isDecryptionFailure()) { // add an event listener for once the event is decrypted. - event.once("Event.decrypted", () => { + event.once("Event.decrypted", async () => { if (!this.eventIsACall(event)) return; if (this.callEventBuffer.includes(event)) { @@ -110,7 +110,7 @@ export class CallEventHandler { // This one wasn't buffered so just run the event handler for it // straight away try { - this.handleCallEvent(event); + await this.handleCallEvent(event); } catch (e) { logger.error("Caught exception handling call event", e); } @@ -169,7 +169,7 @@ export class CallEventHandler { } call.callId = content.call_id; - const initWithInvitePromise = call.initWithInvite(event); + await call.initWithInvite(event); this.calls.set(call.callId, call); // if we stashed candidate events for that call ID, play them back now @@ -210,8 +210,6 @@ export class CallEventHandler { "Glare detected: answering incoming call " + call.callId + " and canceling outgoing call " + existingCall.callId, ); - // Await init with invite as we need a peerConn for the following methods - await initWithInvitePromise; existingCall.replacedBy(call); call.answer(); } else {