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
fix lint
This commit is contained in:
@@ -1600,7 +1600,8 @@ Crypto.prototype._requestVerificationWithChannel = async function(
|
|||||||
// but if the other party is really fast they could potentially respond to the
|
// but if the other party is really fast they could potentially respond to the
|
||||||
// request before the server tells us the event got sent, and we would probably
|
// request before the server tells us the event got sent, and we would probably
|
||||||
// create a new request object
|
// create a new request object
|
||||||
console.log(`Crypto: adding new request to requestsByTxnId with id ${channel.transactionId}`);
|
logger.log(`Crypto: adding new request to ` +
|
||||||
|
`requestsByTxnId with id ${channel.transactionId}`);
|
||||||
requestsMap.setRequestByChannel(channel, request);
|
requestsMap.setRequestByChannel(channel, request);
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
@@ -2579,7 +2580,8 @@ Crypto.prototype._handleVerificationEvent = async function(
|
|||||||
request = createRequest(event);
|
request = createRequest(event);
|
||||||
// a request could not be made from this event, so ignore event
|
// a request could not be made from this event, so ignore event
|
||||||
if (!request) {
|
if (!request) {
|
||||||
console.log(`Crypto: could not find VerificationRequest for ${event.getType()}, and could not create one, so ignoring.`);
|
logger.log(`Crypto: could not find VerificationRequest for ` +
|
||||||
|
`${event.getType()}, and could not create one, so ignoring.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
isNewRequest = true;
|
isNewRequest = true;
|
||||||
@@ -2594,7 +2596,7 @@ Crypto.prototype._handleVerificationEvent = async function(
|
|||||||
this._baseApis.emit("crypto.verification.start", request.verifier);
|
this._baseApis.emit("crypto.verification.start", request.verifier);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("error while handling verification event", event, err);
|
logger.error("error while handling verification event: " + err.message);
|
||||||
}
|
}
|
||||||
const shouldEmit = isNewRequest &&
|
const shouldEmit = isNewRequest &&
|
||||||
!request.initiatedByMe &&
|
!request.initiatedByMe &&
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import {
|
|||||||
READY_TYPE,
|
READY_TYPE,
|
||||||
START_TYPE,
|
START_TYPE,
|
||||||
} from "./VerificationRequest";
|
} from "./VerificationRequest";
|
||||||
|
import {logger} from '../../../logger';
|
||||||
|
|
||||||
const MESSAGE_TYPE = "m.room.message";
|
const MESSAGE_TYPE = "m.room.message";
|
||||||
const M_REFERENCE = "m.reference";
|
const M_REFERENCE = "m.reference";
|
||||||
@@ -127,20 +128,23 @@ export class InRoomChannel {
|
|||||||
static validateEvent(event, client) {
|
static validateEvent(event, client) {
|
||||||
const txnId = InRoomChannel.getTransactionId(event);
|
const txnId = InRoomChannel.getTransactionId(event);
|
||||||
if (typeof txnId !== "string" || txnId.length === 0) {
|
if (typeof txnId !== "string" || txnId.length === 0) {
|
||||||
console.log("InRoomChannel: validateEvent: no valid txnId", type, txnId);
|
logger.log("InRoomChannel: validateEvent: no valid txnId " + txnId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const type = InRoomChannel.getEventType(event);
|
const type = InRoomChannel.getEventType(event);
|
||||||
const content = event.getContent();
|
const content = event.getContent();
|
||||||
if (type === REQUEST_TYPE) {
|
if (type === REQUEST_TYPE) {
|
||||||
if (!content || typeof content.to !== "string" || !content.to.length) {
|
if (!content || typeof content.to !== "string" || !content.to.length) {
|
||||||
console.log("InRoomChannel: validateEvent: no valid to", type, content.to);
|
logger.log("InRoomChannel: validateEvent: " +
|
||||||
|
"no valid to " + (content && content.to));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore requests that are not direct to or sent by the syncing user
|
// ignore requests that are not direct to or sent by the syncing user
|
||||||
if (!InRoomChannel.getOtherPartyUserId(event, client)) {
|
if (!InRoomChannel.getOtherPartyUserId(event, client)) {
|
||||||
console.log("InRoomChannel: validateEvent: not directed to or sent by me", type, event.getSender(), content.to);
|
logger.log("InRoomChannel: validateEvent: " +
|
||||||
|
`not directed to or sent by me: ${event.getSender()}` +
|
||||||
|
`, ${content && content.to}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -196,7 +200,8 @@ export class InRoomChannel {
|
|||||||
const sender = event.getSender();
|
const sender = event.getSender();
|
||||||
if (this.userId !== null) {
|
if (this.userId !== null) {
|
||||||
if (sender !== ownUserId && sender !== this.userId) {
|
if (sender !== ownUserId && sender !== this.userId) {
|
||||||
console.log(`InRoomChannel: ignoring verification event from non-participating sender ${sender}`);
|
logger.log(`InRoomChannel: ignoring verification event from ` +
|
||||||
|
`non-participating sender ${sender}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,17 +83,19 @@ export class VerificationRequest extends EventEmitter {
|
|||||||
const content = event.getContent();
|
const content = event.getContent();
|
||||||
|
|
||||||
if (!content) {
|
if (!content) {
|
||||||
console.log("VerificationRequest: validateEvent: no content", type);
|
logger.log("VerificationRequest: validateEvent: no content");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!type.startsWith(EVENT_PREFIX)) {
|
if (!type.startsWith(EVENT_PREFIX)) {
|
||||||
console.log("VerificationRequest: validateEvent: fail because type doesnt start with " + EVENT_PREFIX, type);
|
logger.log("VerificationRequest: validateEvent: " +
|
||||||
|
"fail because type doesnt start with " + EVENT_PREFIX);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === REQUEST_TYPE || type === READY_TYPE) {
|
if (type === REQUEST_TYPE || type === READY_TYPE) {
|
||||||
if (!Array.isArray(content.methods)) {
|
if (!Array.isArray(content.methods)) {
|
||||||
console.log("VerificationRequest: validateEvent: fail because methods", type);
|
logger.log("VerificationRequest: validateEvent: " +
|
||||||
|
"fail because methods");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,7 +104,8 @@ export class VerificationRequest extends EventEmitter {
|
|||||||
if (typeof content.from_device !== "string" ||
|
if (typeof content.from_device !== "string" ||
|
||||||
content.from_device.length === 0
|
content.from_device.length === 0
|
||||||
) {
|
) {
|
||||||
console.log("VerificationRequest: validateEvent: fail because from_device", type);
|
logger.log("VerificationRequest: validateEvent: "+
|
||||||
|
"fail because from_device");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1238,7 +1238,8 @@ SyncApi.prototype._processSyncResponse = async function(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self._processRoomEvents(room, stateEvents, timelineEvents, syncEventData.fromCache);
|
self._processRoomEvents(room, stateEvents,
|
||||||
|
timelineEvents, syncEventData.fromCache);
|
||||||
|
|
||||||
// set summary after processing events,
|
// set summary after processing events,
|
||||||
// because it will trigger a name calculation
|
// because it will trigger a name calculation
|
||||||
|
|||||||
Reference in New Issue
Block a user