You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
some cleanups
This commit is contained in:
@@ -516,9 +516,8 @@ describe("MegolmDecryption", function() {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
let run = false;
|
const sendPromise = new Promise((resolve, reject) => {
|
||||||
aliceClient.sendToDevice = async (msgtype, contentMap) => {
|
aliceClient.sendToDevice = async (msgtype, contentMap) => {
|
||||||
run = true;
|
|
||||||
expect(msgtype).toBe("org.matrix.room_key.withheld");
|
expect(msgtype).toBe("org.matrix.room_key.withheld");
|
||||||
expect(contentMap).toStrictEqual({
|
expect(contentMap).toStrictEqual({
|
||||||
'@bob:example.com': {
|
'@bob:example.com': {
|
||||||
@@ -530,7 +529,9 @@ describe("MegolmDecryption", function() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
resolve();
|
||||||
};
|
};
|
||||||
|
});
|
||||||
|
|
||||||
const event = new MatrixEvent({
|
const event = new MatrixEvent({
|
||||||
type: "m.room.message",
|
type: "m.room.message",
|
||||||
@@ -540,14 +541,7 @@ describe("MegolmDecryption", function() {
|
|||||||
content: {},
|
content: {},
|
||||||
});
|
});
|
||||||
await aliceClient._crypto.encryptEvent(event, aliceRoom);
|
await aliceClient._crypto.encryptEvent(event, aliceRoom);
|
||||||
await new Promise((resolve) => {
|
await sendPromise;
|
||||||
// encryptMessage retries senders in the background before giving
|
|
||||||
// up and telling them that there's no olm channel, so we need to
|
|
||||||
// wait a bit before checking that we got the message
|
|
||||||
setTimeout(resolve, 100);
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(run).toBe(true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("throws an error describing why it doesn't have a key", async function() {
|
it("throws an error describing why it doesn't have a key", async function() {
|
||||||
|
|||||||
@@ -244,8 +244,6 @@ MegolmEncryption.prototype._ensureOutboundSession = async function(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const errorDevices = [];
|
|
||||||
|
|
||||||
const key = this._olmDevice.getOutboundGroupSessionKey(session.sessionId);
|
const key = this._olmDevice.getOutboundGroupSessionKey(session.sessionId);
|
||||||
const payload = {
|
const payload = {
|
||||||
type: "m.room_key",
|
type: "m.room_key",
|
||||||
@@ -269,6 +267,8 @@ MegolmEncryption.prototype._ensureOutboundSession = async function(
|
|||||||
);
|
);
|
||||||
})(),
|
})(),
|
||||||
(async () => {
|
(async () => {
|
||||||
|
const errorDevices = [];
|
||||||
|
|
||||||
// meanwhile, establish olm sessions for devices that we don't
|
// meanwhile, establish olm sessions for devices that we don't
|
||||||
// already have a session for, and share keys with them. Use a
|
// already have a session for, and share keys with them. Use a
|
||||||
// shorter timeout when fetching one-time keys.
|
// shorter timeout when fetching one-time keys.
|
||||||
@@ -769,11 +769,12 @@ MegolmEncryption.prototype._notifyBlockedDevices = async function(
|
|||||||
* @param {module:models/room} room the room the event is in
|
* @param {module:models/room} room the room the event is in
|
||||||
*/
|
*/
|
||||||
MegolmEncryption.prototype.prepareToEncrypt = function(room) {
|
MegolmEncryption.prototype.prepareToEncrypt = function(room) {
|
||||||
logger.log(`Preparing to encrypt events for ${this._roomId}`);
|
logger.debug(`Preparing to encrypt events for ${this._roomId}`);
|
||||||
|
|
||||||
if (this.encryptionPreparation) {
|
if (this.encryptionPreparation) {
|
||||||
// We're already preparing something, so don't do anything else.
|
// We're already preparing something, so don't do anything else.
|
||||||
// FIXME: check if we need to restart
|
// FIXME: check if we need to restart
|
||||||
|
// (https://github.com/matrix-org/matrix-js-sdk/issues/1255)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -807,7 +808,8 @@ MegolmEncryption.prototype.encryptMessage = async function(room, eventType, cont
|
|||||||
|
|
||||||
if (this.encryptionPreparation) {
|
if (this.encryptionPreparation) {
|
||||||
// If we started sending keys, wait for it to be done.
|
// If we started sending keys, wait for it to be done.
|
||||||
// FIXME: check if we need to restart
|
// FIXME: check if we need to cancel
|
||||||
|
// (https://github.com/matrix-org/matrix-js-sdk/issues/1255)
|
||||||
try {
|
try {
|
||||||
await this.encryptionPreparation;
|
await this.encryptionPreparation;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user