From 5f7c82d41dc1416eec0ee6839bd5f44705e48a81 Mon Sep 17 00:00:00 2001 From: Vincent Date: Thu, 30 Apr 2020 13:40:56 +1000 Subject: [PATCH] Cleanup --- js/models/conversations.js | 18 ---------------- js/modules/loki_message_api.js | 2 -- js/modules/signal.js | 2 -- js/views/conversation_view.js | 13 ----------- libtextsecure/outgoing_message.js | 36 ++----------------------------- libtextsecure/sendmessage.js | 2 -- 6 files changed, 2 insertions(+), 71 deletions(-) diff --git a/js/models/conversations.js b/js/models/conversations.js index 68ec1f659..48c6781df 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -649,8 +649,6 @@ ); }, async updateVerified() { - // console.log('[vince] conversations.js --> updateVerified()'); - if (this.isPrivate()) { await this.initialPromise; const verified = await this.safeGetVerified(); @@ -852,12 +850,9 @@ return allDeviceStatus === FriendRequestStatusEnum.friends; }, getFriendRequestStatus() { - return this.get('friendRequestStatus'); }, async getPrimaryConversation() { - // console.log('[vince] conversation.js --> getPrimaryConversation'); - if (!this.isSecondaryDevice()) { // This is already the primary conversation return this; @@ -875,8 +870,6 @@ return this; }, async updateTextInputState() { - // console.log('[vince] conversation.js --> updateTextInputState'); - if (this.isRss()) { // or if we're an rss conversation, disable it this.trigger('disable:input', true); @@ -926,8 +919,6 @@ return this.get('primaryDevicePubKey') || this.id; }, async setSecondaryStatus(newStatus, primaryDevicePubKey) { - // console.log('[vince] conversation.js --> setSecondaryStatus'); - if (this.get('secondaryStatus') !== newStatus) { this.set({ secondaryStatus: newStatus, @@ -939,8 +930,6 @@ } }, async setFriendRequestStatus(newStatus, options = {}) { - // console.log('[vince] conversation.js --> setFriendRequestStatus'); - const { blockSync } = options; // Ensure that the new status is a valid FriendStatusEnum value if (!(newStatus in Object.values(FriendRequestStatusEnum))) { @@ -1547,13 +1536,6 @@ ) { this.clearTypingTimers(); - // console.log(`[vince] conversations.js --> body:`, body); - // console.log(`[vince] conversations.js --> attachments:`, attachments); - // console.log(`[vince] conversations.js --> quote:`, quote); - // console.log(`[vince] conversations.js --> preview:`, preview); - // console.log(`[vince] conversations.js --> groupInvitation:`, groupInvitation); - // console.log(`[vince] conversations.js --> otherOptions:`, otherOptions); - const destination = this.id; const expireTimer = this.get('expireTimer'); const recipients = this.getRecipients(); diff --git a/js/modules/loki_message_api.js b/js/modules/loki_message_api.js index 2fab43c56..8c7de6553 100644 --- a/js/modules/loki_message_api.js +++ b/js/modules/loki_message_api.js @@ -40,8 +40,6 @@ class LokiMessageAPI { } async sendMessage(pubKey, data, messageTimeStamp, ttl, options = {}) { - // console.log('[vince] outgoing_message.js --> loki_message_api.js --> sendMessage'); - const { isPublic = false, numConnections = DEFAULT_CONNECTIONS, diff --git a/js/modules/signal.js b/js/modules/signal.js index 04bcb5874..c676c5845 100644 --- a/js/modules/signal.js +++ b/js/modules/signal.js @@ -235,8 +235,6 @@ function initializeMigrations({ logger, }), upgradeMessageSchema: (message, options = {}) => { - // console.log('[vince] signal.js --> upgradeMessageSchema'); - const { maxVersion } = options; return MessageType.upgradeSchema(message, { diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index 4180eae77..858cfccee 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -1629,8 +1629,6 @@ }, showSendConfirmationDialog(e, contacts) { - // console.log('[vince] conversation_view.js --> showSendConfirmationDialog'); - let message; const isUnverified = this.model.isUnverified(); @@ -1706,8 +1704,6 @@ }, async handleSubmitPressed(e, options = {}) { - console.log(`[vince] handleSubmitPressed e:`, e); - if (this.memberView.membersShown()) { const member = this.memberView.selectedMember(); this.selectMember(member); @@ -1717,8 +1713,6 @@ }, async checkUnverifiedSendMessage(e, options = {}) { - console.log(`[vince] checkUnverifiedSendMessage e:`, e); - e.preventDefault(); this.sendStart = Date.now(); this.$messageField.attr('disabled', true); @@ -1752,8 +1746,6 @@ }, async checkUntrustedSendMessage(e, options = {}) { - console.log(`[vince] checkUntrustedSendMessage e:`, e); - _.defaults(options, { force: false }); try { @@ -1915,8 +1907,6 @@ let message = this.memberView.replaceMentions(input.val()); message = window.Signal.Emoji.replaceColons(message).trim(); - - const toastOptions = { type: 'info' }; // let it pass if we're still trying to read it or it's false... if (extension.expiredStatus() === true) { @@ -2480,9 +2470,6 @@ !event.shiftKey && !event.ctrlKey ) { - - // console.log('[vince] conversation_view.hs --> handleInputEvent:', Date.now()); - // enter pressed - submit the form now event.preventDefault(); this.$('.bottom-bar form').submit(); diff --git a/libtextsecure/outgoing_message.js b/libtextsecure/outgoing_message.js index a75530a57..25fc9ce67 100644 --- a/libtextsecure/outgoing_message.js +++ b/libtextsecure/outgoing_message.js @@ -1,5 +1,4 @@ /* global - _, textsecure, libsignal, window, @@ -218,18 +217,7 @@ OutgoingMessage.prototype = { async transmitMessage(number, data, timestamp, ttl = 24 * 60 * 60 * 1000) { const pubKey = number; - const b2Pubkey = "05d3a0c9e5c3a205d5ec609e04b444e28a28158045c0746dc401862ebe13350504"; - if (number === b2Pubkey && !window.sendForB2){ - // Set window.sendForB2 to true when you want to retry, from console - - console.log('[vince] b2Pubkey found, failing message.:', b2Pubkey); - throw new window.textsecure.PublicChatError( - 'b2Pubkey found, failing message' - ); - } - - - try { + try { // TODO: Make NUM_CONCURRENT_CONNECTIONS a global constant const options = { numConnections: NUM_SEND_CONNECTIONS, @@ -489,15 +477,8 @@ OutgoingMessage.prototype = { }, // Send a message to a private group or a session chat (one to one) async sendSessionMessage(outgoingObjects) { - if (this.errors.length){ - throw this.errors[0]; - } - - console.log('[vince] pubKeys:', outgoingObjects.map(obj => obj.pubKey)); - // TODO: handle multiple devices/messages per transmit const promises = outgoingObjects.map(outgoingObject => async () => { - if (!outgoingObject) { return; } @@ -509,7 +490,7 @@ OutgoingMessage.prototype = { } = outgoingObject; try { const socketMessage = await this.wrapInWebsocketMessage(outgoingObject); - + await this.transmitMessage( destination, socketMessage, @@ -533,20 +514,7 @@ OutgoingMessage.prototype = { await Promise.all(promises.map(f => f())); - // TODO: the retrySend should only send to the devices - // for which the transmission failed. - - const failedDevices = this.errors.map(e => e.number); - - if (failedDevices && outgoingObjects.length) { - const retryOutgoingObjects = outgoingObjects.filter(obj => _.includes(failedDevices, obj.pubKey)) - - console.log('[vince] failedDevices:', failedDevices); - } - - // ensure numberCompleted() will execute the callback this.numbersCompleted += this.successfulNumbers.length; - this.numberCompleted(); }, async buildAndEncrypt(devicePubKey) { diff --git a/libtextsecure/sendmessage.js b/libtextsecure/sendmessage.js index 057bb6956..a0bfe4267 100644 --- a/libtextsecure/sendmessage.js +++ b/libtextsecure/sendmessage.js @@ -514,8 +514,6 @@ MessageSender.prototype = { }, createSyncMessage() { - // console.log('[vince] sendmessage.js --> createSyncMessage'); - const syncMessage = new textsecure.protobuf.SyncMessage(); // Generate a random int from 1 and 512