From 57195017f93e3eec2130113557a0135b086a718c Mon Sep 17 00:00:00 2001 From: Mikunj Date: Wed, 17 Apr 2019 12:01:19 +1000 Subject: [PATCH] Linting --- app/sql.js | 10 ++- js/models/conversations.js | 2 +- js/models/messages.js | 2 +- libtextsecure/message_receiver.js | 119 ++++++++++++------------- ts/components/ConversationListItem.tsx | 1 - 5 files changed, 69 insertions(+), 65 deletions(-) diff --git a/app/sql.js b/app/sql.js index 8c8f3b3f2..662e79b53 100644 --- a/app/sql.js +++ b/app/sql.js @@ -8,7 +8,15 @@ const { remove: removeUserConfig } = require('./user_config'); const pify = require('pify'); const uuidv4 = require('uuid/v4'); -const { map, isString, fromPairs, forEach, last, isEmpty, isObject } = require('lodash'); +const { + map, + isString, + fromPairs, + forEach, + last, + isEmpty, + isObject, +} = require('lodash'); // To get long stack traces // https://github.com/mapbox/node-sqlite3/wiki/API#sqlite3verbose diff --git a/js/models/conversations.js b/js/models/conversations.js index 14bf4bc60..394c0da83 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -1342,7 +1342,7 @@ // Add the message sending on another queue so that our UI doesn't get blocked this.queueMessageSend(async () => { - message.send(this.wrapSend(promise)) + message.send(this.wrapSend(promise)); }); return true; diff --git a/js/models/messages.js b/js/models/messages.js index 6d1c88b16..a551534f3 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -23,7 +23,7 @@ Contact, PhoneNumber, Attachment, - Errors + Errors, } = Signal.Types; const { diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index 24e4c21ec..2943ca0d7 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -1021,74 +1021,71 @@ MessageReceiver.prototype.extend({ } return p.then(() => this.processDecrypted(envelope, msg).then(async message => { - const groupId = message.group && message.group.id; - const isBlocked = this.isGroupBlocked(groupId); - const isMe = envelope.source === textsecure.storage.user.getNumber(); - const conversation = window.ConversationController.get( - envelope.source - ); - const isLeavingGroup = Boolean( - message.group && - message.group.type === textsecure.protobuf.GroupContext.Type.QUIT - ); - const friendRequest = - envelope.type === textsecure.protobuf.Envelope.Type.FRIEND_REQUEST; - - // Check if we need to update any profile names - if (!isMe && conversation) { - let profile = null; - if (message.profile) { - profile = JSON.parse(message.profile.encodeJSON()); - } - - // Update the conversation - await conversation.setProfile(profile); + const groupId = message.group && message.group.id; + const isBlocked = this.isGroupBlocked(groupId); + const isMe = envelope.source === textsecure.storage.user.getNumber(); + const conversation = window.ConversationController.get(envelope.source); + const isLeavingGroup = Boolean( + message.group && + message.group.type === textsecure.protobuf.GroupContext.Type.QUIT + ); + const friendRequest = + envelope.type === textsecure.protobuf.Envelope.Type.FRIEND_REQUEST; + + // Check if we need to update any profile names + if (!isMe && conversation) { + let profile = null; + if (message.profile) { + profile = JSON.parse(message.profile.encodeJSON()); } - if (friendRequest && isMe) { - window.log.info('refusing to add a friend request to ourselves'); - throw new Error('Cannot add a friend request for ourselves!'); - } + // Update the conversation + await conversation.setProfile(profile); + } - if (groupId && isBlocked && !(isMe && isLeavingGroup)) { - window.log.warn( - `Message ${this.getEnvelopeId( - envelope - )} ignored; destined for blocked group` - ); - return this.removeFromCache(envelope); - } + if (friendRequest && isMe) { + window.log.info('refusing to add a friend request to ourselves'); + throw new Error('Cannot add a friend request for ourselves!'); + } - if (!message.body) { - // Trigger conversation friend request event for empty message - if (conversation && !message.flags) { - const isFriendRequestAccept = await conversation.onFriendRequestAccepted(); - if (isFriendRequestAccept) { - await conversation.notifyFriendRequest( - envelope.source, - 'accepted' - ); - } + if (groupId && isBlocked && !(isMe && isLeavingGroup)) { + window.log.warn( + `Message ${this.getEnvelopeId( + envelope + )} ignored; destined for blocked group` + ); + return this.removeFromCache(envelope); + } + + if (!message.body) { + // Trigger conversation friend request event for empty message + if (conversation && !message.flags) { + const isFriendRequestAccept = await conversation.onFriendRequestAccepted(); + if (isFriendRequestAccept) { + await conversation.notifyFriendRequest( + envelope.source, + 'accepted' + ); } - this.removeFromCache(envelope); - return null; } - - const ev = new Event('message'); - ev.confirm = this.removeFromCache.bind(this, envelope); - ev.data = { - friendRequest, - source: envelope.source, - sourceDevice: envelope.sourceDevice, - timestamp: envelope.timestamp.toNumber(), - receivedAt: envelope.receivedAt, - unidentifiedDeliveryReceived: envelope.unidentifiedDeliveryReceived, - isP2p: envelope.isP2p, - message, - }; - return this.dispatchAndWait(ev); + this.removeFromCache(envelope); + return null; } - ) + + const ev = new Event('message'); + ev.confirm = this.removeFromCache.bind(this, envelope); + ev.data = { + friendRequest, + source: envelope.source, + sourceDevice: envelope.sourceDevice, + timestamp: envelope.timestamp.toNumber(), + receivedAt: envelope.receivedAt, + unidentifiedDeliveryReceived: envelope.unidentifiedDeliveryReceived, + isP2p: envelope.isP2p, + message, + }; + return this.dispatchAndWait(ev); + }) ); }, handleLegacyMessage(envelope) { diff --git a/ts/components/ConversationListItem.tsx b/ts/components/ConversationListItem.tsx index 6637e9cfe..885717be1 100644 --- a/ts/components/ConversationListItem.tsx +++ b/ts/components/ConversationListItem.tsx @@ -31,7 +31,6 @@ interface Props { showFriendRequestIndicator?: boolean; isBlocked: boolean; isOnline: boolean; - isMe: boolean; hasNickname: boolean; i18n: Localizer;