From 8d29cb98303ee8f3f9ce0d6643435c438ad8d30e Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Wed, 14 Jun 2017 10:58:05 -0700 Subject: [PATCH] Prevent access to Safety Number when talking to yourself FREEBIE --- background.html | 4 +++- js/models/conversations.js | 16 ++++++++++------ js/views/conversation_view.js | 1 + test/index.html | 4 +++- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/background.html b/background.html index 88f6a30451e..dfc775876f0 100644 --- a/background.html +++ b/background.html @@ -102,7 +102,9 @@ {{/group}} {{^group}} -
  • {{ show-identity }}
  • + {{ ^isMe }} +
  • {{ show-identity }}
  • + {{ /isMe }}
  • {{ end-session }}
  • {{/group}}
  • {{ destroy }}
  • diff --git a/js/models/conversations.js b/js/models/conversations.js index 6fc0aab33aa..12a572468cc 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -56,6 +56,10 @@ this.on('destroy', this.revokeAvatarUrl); }, + isMe: function() { + return this.id === this.ourNumber; + }, + updateVerified: function() { function checkTrustStore(value) { return Promise.resolve(value); @@ -73,7 +77,7 @@ } else { return this.fetchContacts().then(function() { return Promise.all(this.contactCollection.map(function(contact) { - if (contact.id !== this.ourNumber) { + if (!contact.isMe()) { return contact.updateVerified(); } }.bind(this))); @@ -121,7 +125,7 @@ } return this.contactCollection.every(function(contact) { - if (contact.id === this.ourNumber) { + if (contact.isMe()) { return true; } else { return contact.isVerified(); @@ -139,7 +143,7 @@ } return this.contactCollection.any(function(contact) { - if (contact.id === this.ourNumber) { + if (contact.isMe()) { return false; } else { return contact.isUnverified(); @@ -152,7 +156,7 @@ return this.isUnverified() ? new Backbone.Collection([this]) : new Backbone.Collection(); } else { return new Backbone.Collection(this.contactCollection.filter(function(contact) { - if (contact.id === this.ourNumber) { + if (contact.isMe()) { return false; } else { return contact.isUnverified(); @@ -174,7 +178,7 @@ } return Promise.all(this.contactCollection.map(function(contact) { - if (contact.id === this.ourNumber) { + if (contact.isMe()) { return false; } else { return contact.isUntrusted(); @@ -199,7 +203,7 @@ }.bind(this)); } else { return Promise.all(this.contactCollection.map(function(contact) { - if (contact.id === this.ourNumber) { + if (contact.isMe()) { return [false, contact]; } else { return Promise.all([this.isUntrusted(), contact]); diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index 016233b3d4f..e39b196d2b3 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -82,6 +82,7 @@ render_attributes: function() { return { group: this.model.get('type') === 'group', + isMe: this.model.isMe(), avatar: this.model.getAvatar(), expireTimer: this.model.get('expireTimer'), 'show-members' : i18n('showMembers'), diff --git a/test/index.html b/test/index.html index 5a2ebaeb76a..bc5cfd1b055 100644 --- a/test/index.html +++ b/test/index.html @@ -105,7 +105,9 @@ {{/group}} {{^group}} -
  • {{ show-identity }}
  • + {{ ^isMe }} +
  • {{ show-identity }}
  • + {{ /isMe }}
  • {{ end-session }}
  • {{/group}}
  • {{ destroy }}