From 07cc93cca2cc1dc47f138ffade56c00e8681ada9 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 17 Jan 2020 16:58:19 +0100 Subject: [PATCH] fix lint --- src/crypto/index.js | 8 +++++--- src/crypto/verification/request/InRoomChannel.js | 13 +++++++++---- .../verification/request/VerificationRequest.js | 11 +++++++---- src/sync.js | 3 ++- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/crypto/index.js b/src/crypto/index.js index fec8251eb..65cb7da79 100644 --- a/src/crypto/index.js +++ b/src/crypto/index.js @@ -1600,7 +1600,8 @@ Crypto.prototype._requestVerificationWithChannel = async function( // 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 // 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); return request; @@ -2579,7 +2580,8 @@ Crypto.prototype._handleVerificationEvent = async function( request = createRequest(event); // a request could not be made from this event, so ignore event 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; } isNewRequest = true; @@ -2594,7 +2596,7 @@ Crypto.prototype._handleVerificationEvent = async function( this._baseApis.emit("crypto.verification.start", request.verifier); } } catch (err) { - console.error("error while handling verification event", event, err); + logger.error("error while handling verification event: " + err.message); } const shouldEmit = isNewRequest && !request.initiatedByMe && diff --git a/src/crypto/verification/request/InRoomChannel.js b/src/crypto/verification/request/InRoomChannel.js index c6dde65ae..57f2139f8 100644 --- a/src/crypto/verification/request/InRoomChannel.js +++ b/src/crypto/verification/request/InRoomChannel.js @@ -21,6 +21,7 @@ import { READY_TYPE, START_TYPE, } from "./VerificationRequest"; +import {logger} from '../../../logger'; const MESSAGE_TYPE = "m.room.message"; const M_REFERENCE = "m.reference"; @@ -127,20 +128,23 @@ export class InRoomChannel { static validateEvent(event, client) { const txnId = InRoomChannel.getTransactionId(event); 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; } const type = InRoomChannel.getEventType(event); const content = event.getContent(); if (type === REQUEST_TYPE) { 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; } // ignore requests that are not direct to or sent by the syncing user 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; } } @@ -196,7 +200,8 @@ export class InRoomChannel { const sender = event.getSender(); if (this.userId !== null) { 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; } } diff --git a/src/crypto/verification/request/VerificationRequest.js b/src/crypto/verification/request/VerificationRequest.js index f5456ddb8..c6d9117b1 100644 --- a/src/crypto/verification/request/VerificationRequest.js +++ b/src/crypto/verification/request/VerificationRequest.js @@ -83,17 +83,19 @@ export class VerificationRequest extends EventEmitter { const content = event.getContent(); if (!content) { - console.log("VerificationRequest: validateEvent: no content", type); + logger.log("VerificationRequest: validateEvent: no content"); } 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; } if (type === REQUEST_TYPE || type === READY_TYPE) { if (!Array.isArray(content.methods)) { - console.log("VerificationRequest: validateEvent: fail because methods", type); + logger.log("VerificationRequest: validateEvent: " + + "fail because methods"); return false; } } @@ -102,7 +104,8 @@ export class VerificationRequest extends EventEmitter { if (typeof content.from_device !== "string" || content.from_device.length === 0 ) { - console.log("VerificationRequest: validateEvent: fail because from_device", type); + logger.log("VerificationRequest: validateEvent: "+ + "fail because from_device"); return false; } } diff --git a/src/sync.js b/src/sync.js index a8946ef52..24d419317 100644 --- a/src/sync.js +++ b/src/sync.js @@ -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, // because it will trigger a name calculation