diff --git a/app/sql.js b/app/sql.js index 79d51f3b5..623f487f1 100644 --- a/app/sql.js +++ b/app/sql.js @@ -1302,7 +1302,9 @@ async function getMessageBySender({ source, sourceDevice, sent_at }) { async function getAllUnsentMessages() { const rows = await db.all(` - SELECT json FROM messages WHERE NOT sent + SELECT json FROM messages WHERE + type IN ('outgoing', 'friend-request') AND + NOT sent ORDER BY sent_at DESC; `); return map(rows, row => jsonToObject(row.json)); diff --git a/js/background.js b/js/background.js index b5a1df155..4e8f20433 100644 --- a/js/background.js +++ b/js/background.js @@ -338,6 +338,11 @@ 'expirationStartTimestamp' ); + // Make sure we only target outgoing messages + if (message.isFriendRequest() && message.get('direction') === 'incoming') { + return; + } + if (message.hasErrors()) { return; } diff --git a/js/blocked_number_controller.js b/js/blocked_number_controller.js index 24cfedd76..4e4fac2d0 100644 --- a/js/blocked_number_controller.js +++ b/js/blocked_number_controller.js @@ -63,10 +63,16 @@ return null; }, + unblockAll() { + const all = blockedNumbers.models; + all.forEach(number => { + storage.removeBlockedNumber(number); + blockedNumbers.remove(number); + }) + }, isBlocked(number) { return storage.isBlocked(number); }, - }; })(); \ No newline at end of file diff --git a/js/models/messages.js b/js/models/messages.js index f3860f648..56ff9bc40 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -331,15 +331,27 @@ window.Whisper.events.trigger('deleteConversation', conversation); }; + const onBlockUser = () => { + conversation.block(); + this.trigger('change'); + }; + + const onUnblockUser = () => { + conversation.unblock(); + this.trigger('change'); + }; + return { text: this.createNonBreakingLastSeparator(this.get('body')), status: this.getMessagePropStatus(), direction, friendStatus, + isBlocked: conversation.isBlocked(), onAccept, onDecline, onDeleteConversation, - onRetrySend: () => this.retrySend(), + onBlockUser, + onUnblockUser, } }, findContact(phoneNumber) { diff --git a/js/views/settings_view.js b/js/views/settings_view.js index 6d2439071..52675463f 100644 --- a/js/views/settings_view.js +++ b/js/views/settings_view.js @@ -150,6 +150,7 @@ mediaPermissionsDescription: i18n('mediaPermissionsDescription'), spellCheckHeader: i18n('spellCheck'), spellCheckDescription: i18n('spellCheckDescription'), + blockedHeader: 'Blocked Users', }; }, onClose() { diff --git a/settings.html b/settings.html index ebc33d209..24586d0c9 100644 --- a/settings.html +++ b/settings.html @@ -109,6 +109,10 @@
{{ clearDataExplanation }}
+