1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-25 05:23:13 +03:00

Merge branch 'develop' into gsouquet/threaded-messaging-2349

This commit is contained in:
Germain Souquet
2021-08-19 10:45:23 +01:00
4 changed files with 16 additions and 17 deletions

View File

@@ -521,7 +521,7 @@ interface IMessagesResponse {
state: IStateEvent[]; state: IStateEvent[];
} }
interface IRequestTokenResponse { export interface IRequestTokenResponse {
sid: string; sid: string;
submit_url?: string; submit_url?: string;
} }
@@ -600,7 +600,7 @@ interface IUserDirectoryResponse {
limited: boolean; limited: boolean;
} }
interface IMyDevice { export interface IMyDevice {
device_id: string; device_id: string;
display_name?: string; display_name?: string;
last_seen_ip?: string; last_seen_ip?: string;
@@ -5078,7 +5078,7 @@ export class MatrixClient extends EventEmitter {
email: string, email: string,
clientSecret: string, clientSecret: string,
sendAttempt: number, sendAttempt: number,
nextLink: string, nextLink?: string,
): Promise<IRequestTokenResponse> { ): Promise<IRequestTokenResponse> {
return this.requestTokenFromEndpoint( return this.requestTokenFromEndpoint(
"/account/password/email/requestToken", "/account/password/email/requestToken",
@@ -7991,10 +7991,7 @@ export class MatrixClient extends EventEmitter {
autoJoinOnly?: boolean, autoJoinOnly?: boolean,
limit?: number, limit?: number,
batch?: string, batch?: string,
): Promise<{ ): Promise<{rooms: ISpaceSummaryRoom[], events: ISpaceSummaryEvent[]}> {
rooms: ISpaceSummaryRoom[];
events: ISpaceSummaryEvent[];
}> {
const path = utils.encodeUri("/rooms/$roomId/spaces", { const path = utils.encodeUri("/rooms/$roomId/spaces", {
$roomId: roomId, $roomId: roomId,
}); });

View File

@@ -59,7 +59,7 @@ export class EncryptionSetupBuilder {
* @param {Object.<String, MatrixEvent>} accountData pre-existing account data, will only be read, not written. * @param {Object.<String, MatrixEvent>} 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 * @param {CryptoCallbacks} delegateCryptoCallbacks crypto callbacks to delegate to if the key isn't in cache yet
*/ */
constructor(accountData: Record<string, MatrixEvent>, delegateCryptoCallbacks: ICryptoCallbacks) { constructor(accountData: Record<string, MatrixEvent>, delegateCryptoCallbacks?: ICryptoCallbacks) {
this.accountDataClientAdapter = new AccountDataClientAdapter(accountData); this.accountDataClientAdapter = new AccountDataClientAdapter(accountData);
this.crossSigningCallbacks = new CrossSigningCallbacks(); this.crossSigningCallbacks = new CrossSigningCallbacks();
this.ssssCryptoCallbacks = new SSSSCryptoCallbacks(delegateCryptoCallbacks); this.ssssCryptoCallbacks = new SSSSCryptoCallbacks(delegateCryptoCallbacks);
@@ -351,7 +351,7 @@ class CrossSigningCallbacks implements ICryptoCallbacks, ICacheCallbacks {
class SSSSCryptoCallbacks { class SSSSCryptoCallbacks {
private readonly privateKeys = new Map<string, Uint8Array>(); private readonly privateKeys = new Map<string, Uint8Array>();
constructor(private readonly delegateCryptoCallbacks: ICryptoCallbacks) {} constructor(private readonly delegateCryptoCallbacks?: ICryptoCallbacks) {}
public async getSecretStorageKey( public async getSecretStorageKey(
{ keys }: { keys: Record<string, ISecretStorageKeyInfo> }, { keys }: { keys: Record<string, ISecretStorageKeyInfo> },

View File

@@ -18,7 +18,7 @@ import { MatrixClient } from "../client";
import { EventType, IEncryptedFile, MsgType, UNSTABLE_MSC3089_BRANCH, UNSTABLE_MSC3089_LEAF } from "../@types/event"; import { EventType, IEncryptedFile, MsgType, UNSTABLE_MSC3089_BRANCH, UNSTABLE_MSC3089_LEAF } from "../@types/event";
import { Room } from "./room"; import { Room } from "./room";
import { logger } from "../logger"; import { logger } from "../logger";
import { MatrixEvent } from "./event"; import { IContent, MatrixEvent } from "./event";
import { import {
averageBetweenStrings, averageBetweenStrings,
DEFAULT_ALPHABET, DEFAULT_ALPHABET,
@@ -451,11 +451,14 @@ export class MSC3089TreeSpace {
* @param {string} name The name of the file. * @param {string} name The name of the file.
* @param {ArrayBuffer} encryptedContents The encrypted contents. * @param {ArrayBuffer} encryptedContents The encrypted contents.
* @param {Partial<IEncryptedFile>} info The encrypted file information. * @param {Partial<IEncryptedFile>} info The encrypted file information.
* @param {IContent} additionalContent Optional event content fields to include in the message.
* @returns {Promise<void>} Resolves when uploaded. * @returns {Promise<void>} Resolves when uploaded.
*/ */
public async createFile( public async createFile(
name: string, name: string,
encryptedContents: ArrayBuffer, info: Partial<IEncryptedFile>, encryptedContents: ArrayBuffer,
info: Partial<IEncryptedFile>,
additionalContent?: IContent,
): Promise<void> { ): Promise<void> {
const mxc = await this.client.uploadContent(new Blob([encryptedContents]), { const mxc = await this.client.uploadContent(new Blob([encryptedContents]), {
includeFilename: false, includeFilename: false,
@@ -464,6 +467,7 @@ export class MSC3089TreeSpace {
info.url = mxc; info.url = mxc;
const res = await this.client.sendMessage(this.roomId, { const res = await this.client.sendMessage(this.roomId, {
...(additionalContent ?? {}),
msgtype: MsgType.File, msgtype: MsgType.File,
body: name, body: name,
url: mxc, url: mxc,

View File

@@ -80,7 +80,7 @@ export class CallEventHandler {
continue; continue;
} }
try { try {
this.handleCallEvent(e); await this.handleCallEvent(e);
} catch (e) { } catch (e) {
logger.error("Caught exception handling call event", e); logger.error("Caught exception handling call event", e);
} }
@@ -100,7 +100,7 @@ export class CallEventHandler {
if (event.isBeingDecrypted() || event.isDecryptionFailure()) { if (event.isBeingDecrypted() || event.isDecryptionFailure()) {
// add an event listener for once the event is decrypted. // 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.eventIsACall(event)) return;
if (this.callEventBuffer.includes(event)) { 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 // This one wasn't buffered so just run the event handler for it
// straight away // straight away
try { try {
this.handleCallEvent(event); await this.handleCallEvent(event);
} catch (e) { } catch (e) {
logger.error("Caught exception handling call event", e); logger.error("Caught exception handling call event", e);
} }
@@ -169,7 +169,7 @@ export class CallEventHandler {
} }
call.callId = content.call_id; call.callId = content.call_id;
const initWithInvitePromise = call.initWithInvite(event); await call.initWithInvite(event);
this.calls.set(call.callId, call); this.calls.set(call.callId, call);
// if we stashed candidate events for that call ID, play them back now // 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 + "Glare detected: answering incoming call " + call.callId +
" and canceling outgoing call " + existingCall.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); existingCall.replacedBy(call);
call.answer(); call.answer();
} else { } else {