diff --git a/app/sql.js b/app/sql.js index 8253cafee..8f73610c7 100644 --- a/app/sql.js +++ b/app/sql.js @@ -834,109 +834,6 @@ async function updateToLokiSchemaVersion1(currentVersion, instance) { );` ); - const initConversation = async data => { - // eslint-disable-next-line camelcase - const { id, active_at, type, name } = data; - await instance.run( - `INSERT INTO conversations ( - id, - json, - active_at, - type, - members, - name - ) values ( - $id, - $json, - $active_at, - $type, - $members, - $name, - );`, - { - $id: id, - $json: objectToJSON(data), - $active_at: active_at, - $type: type, - $members: null, - $name: name, - } - ); - }; - - const lokiPublicServerData = { - // make sure we don't have a trailing slash just in case - serverUrl: config.get('defaultPublicChatServer').replace(/\/*$/, ''), - token: null, - }; - console.log('lokiPublicServerData', lokiPublicServerData); - - const baseData = { - active_at: Date.now(), - sealedSender: 0, - sessionResetStatus: 0, - swarmNodes: [], - type: 'group', - unlockTimestamp: null, - unreadCount: 0, - verified: 0, - version: 2, - }; - - const publicChatData = { - ...baseData, - id: `publicChat:1@${lokiPublicServerData.serverUrl.replace( - /^https?:\/\//i, - '' - )}`, - server: lokiPublicServerData.serverUrl, - name: 'Loki Public Chat', - channelId: '1', - }; - - const { serverUrl, token } = lokiPublicServerData; - - await instance.run( - `INSERT INTO servers ( - serverUrl, - token - ) values ( - $serverUrl, - $token - );`, - { - $serverUrl: serverUrl, - $token: token, - } - ); - - const newsRssFeedData = { - ...baseData, - id: 'rss://loki.network/feed/', - rssFeed: 'https://loki.network/feed/', - closable: true, - name: 'Loki News', - profileAvatar: 'images/session/session_chat_icon.png', - }; - - const updatesRssFeedData = { - ...baseData, - id: 'rss://loki.network/category/messenger-updates/feed/', - rssFeed: 'https://loki.network/category/messenger-updates/feed/', - closable: false, - name: 'Session Updates', - profileAvatar: 'images/session/session_chat_icon.png', - }; - - const autoJoinLokiChats = false; - - if (autoJoinLokiChats) { - await initConversation(publicChatData); - } - - await initConversation(newsRssFeedData); - await initConversation(updatesRssFeedData); - await instance.run( `INSERT INTO loki_schema ( version @@ -2483,7 +2380,7 @@ async function getMessageBySender({ source, sourceDevice, sent_at }) { async function getAllUnsentMessages() { const rows = await db.all(` SELECT json FROM messages WHERE - type IN ('outgoing', 'session-request') AND + type IN ('outgoing') AND NOT sent ORDER BY sent_at DESC; `); diff --git a/background.html b/background.html index e4efe99a9..e97a9f00e 100644 --- a/background.html +++ b/background.html @@ -507,7 +507,7 @@ - + diff --git a/background_test.html b/background_test.html index c47e98b62..de4dac8ae 100644 --- a/background_test.html +++ b/background_test.html @@ -507,7 +507,7 @@ - + diff --git a/js/background.js b/js/background.js index bbb192166..ba59932d3 100644 --- a/js/background.js +++ b/js/background.js @@ -504,9 +504,6 @@ window.Signal.Data.getOutgoingWithoutExpiresAt({ MessageCollection: Whisper.MessageCollection, }), - window.Signal.Data.getAllUnsentMessages({ - MessageCollection: Whisper.MessageCollection, - }), ]); // Combine the models @@ -526,11 +523,6 @@ 'expirationStartTimestamp' ); - // Make sure we only target outgoing messages - if (message.isEndSession() && message.get('direction') === 'incoming') { - return; - } - if (message.isEndSession()) { return; } @@ -1160,12 +1152,6 @@ }); }; - Whisper.events.on('createNewGroup', async () => { - if (appView) { - appView.showCreateGroup(); - } - }); - Whisper.events.on('updateGroupName', async groupConvo => { if (appView) { appView.showUpdateGroupNameDialog(groupConvo); diff --git a/js/models/conversations.js b/js/models/conversations.js index c71146a00..7b90fb90a 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -2014,7 +2014,7 @@ const hasSession = await libsession.Protocols.SessionProtocol.hasSession( devicePubkey ); - if (hasSession) { + if (!hasSession) { return; } diff --git a/js/models/messages.js b/js/models/messages.js index 2fd259693..5fe9a8521 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -277,9 +277,6 @@ isKeyChange() { return this.get('type') === 'keychange'; }, - isSessionRequest() { - return this.get('type') === 'session-request'; - }, isGroupInvitation() { return !!this.get('groupInvitation'); }, @@ -523,10 +520,8 @@ return 'error'; } - const isOutgoing = this.isOutgoing(); - // Only return the status on outgoing messages - if (!isOutgoing) { + if (!this.isOutgoing()) { return null; } diff --git a/js/modules/signal.js b/js/modules/signal.js index 38d5c5293..e5c1ca6f0 100644 --- a/js/modules/signal.js +++ b/js/modules/signal.js @@ -95,8 +95,8 @@ const { UpdateGroupMembersDialog, } = require('../../ts/components/conversation/UpdateGroupMembersDialog'); const { - InviteFriendsDialog, -} = require('../../ts/components/conversation/InviteFriendsDialog'); + InviteContactsDialog, +} = require('../../ts/components/conversation/InviteContactsDialog'); const { AddModeratorsDialog, @@ -295,7 +295,7 @@ exports.setup = (options = {}) => { ConfirmDialog, UpdateGroupNameDialog, UpdateGroupMembersDialog, - InviteFriendsDialog, + InviteContactsDialog, AddModeratorsDialog, RemoveModeratorsDialog, GroupInvitation, diff --git a/js/notifications.js b/js/notifications.js index 823aa7d4c..faa39f9fb 100644 --- a/js/notifications.js +++ b/js/notifications.js @@ -93,9 +93,13 @@ let iconUrl; // The number of notifications excluding session request - const messagesNotificationCount = this.models.filter( - n => !n.get('isSessionRequest') - ).length; + // FIXME do we need to filter out session request? + // I don't think the filter below might work also add this.models + // is created by Whisper.Notifications.add which as not this field + const messagesNotificationCount = this.models.length; + // const messagesNotificationCount = this.models.filter( + // n => !n.get('isSessionRequest') + // ).length; // NOTE: i18n has more complex rules for pluralization than just // distinguishing between zero (0) and other (non-zero), diff --git a/js/views/app_view.js b/js/views/app_view.js index 4f9110408..34acb03cd 100644 --- a/js/views/app_view.js +++ b/js/views/app_view.js @@ -221,13 +221,6 @@ const dialog = new Whisper.DevicePairingWordsDialogView(); this.el.prepend(dialog.el); }, - showCreateGroup() { - // TODO: make it impossible to open 2 dialogs as once - // Currently, if the button is in focus, it is possible to - // create a new dialog by pressing 'Enter' - const dialog = new Whisper.CreateGroupDialogView(); - this.el.append(dialog.el); - }, showUpdateGroupNameDialog(groupConvo) { const dialog = new Whisper.UpdateGroupNameDialogView(groupConvo); this.el.append(dialog.el); @@ -236,7 +229,6 @@ const dialog = new Whisper.UpdateGroupMembersDialogView(groupConvo); this.el.append(dialog.el); }, - showSessionRestoreConfirmation(options) { const dialog = new Whisper.ConfirmSessionResetView(options); this.el.append(dialog.el); diff --git a/js/views/create_group_dialog_view.js b/js/views/create_group_dialog_view.js index e15d2f665..345820807 100644 --- a/js/views/create_group_dialog_view.js +++ b/js/views/create_group_dialog_view.js @@ -6,108 +6,6 @@ window.Whisper = window.Whisper || {}; - Whisper.CreateGroupDialogView = Whisper.View.extend({ - className: 'loki-dialog modal', - initialize() { - this.titleText = i18n('createGroupDialogTitle'); - this.okText = i18n('ok'); - this.cancelText = i18n('cancel'); - this.close = this.close.bind(this); - - const convos = window.getConversations().models; - - let allMembers = convos.filter(d => !!d && d.isPrivate() && !d.isMe()); - allMembers = _.uniq(allMembers, true, d => d.id); - - this.membersToShow = allMembers; - - this.$el.focus(); - this.render(); - }, - render() { - this.dialogView = new Whisper.ReactWrapperView({ - className: 'create-group-dialog', - Component: window.Signal.Components.CreateGroupDialog, - props: { - titleText: this.titleText, - okText: this.okText, - cancelText: this.cancelText, - contactList: this.membersToShow, - onClose: this.close, - }, - }); - - this.$el.append(this.dialogView.el); - return this; - }, - close() { - this.remove(); - }, - }); - - Whisper.UpdateGroupNameDialogView = Whisper.View.extend({ - className: 'loki-dialog modal', - initialize(groupConvo) { - this.groupName = groupConvo.get('name'); - - this.conversation = groupConvo; - this.titleText = i18n('updateGroupDialogTitle'); - this.close = this.close.bind(this); - this.onSubmit = this.onSubmit.bind(this); - this.isPublic = groupConvo.isPublic(); - this.groupId = groupConvo.id; - this.members = groupConvo.get('members') || []; - this.avatarPath = groupConvo.getAvatarPath(); - - const ourPK = textsecure.storage.user.getNumber(); - - this.isAdmin = groupConvo.get('groupAdmins').includes(ourPK); - - // public chat settings overrides - if (this.isPublic) { - // fix the title - this.titleText = `${i18n('updatePublicGroupDialogTitle')}: ${ - this.groupName - }`; - // I'd much prefer to integrate mods with groupAdmins - // but lets discuss first... - this.isAdmin = groupConvo.isModerator( - window.storage.get('primaryDevicePubKey') - ); - } - - this.$el.focus(); - this.render(); - }, - render() { - this.dialogView = new Whisper.ReactWrapperView({ - className: 'create-group-dialog', - Component: window.Signal.Components.UpdateGroupNameDialog, - props: { - titleText: this.titleText, - isPublic: this.isPublic, - groupName: this.groupName, - okText: i18n('ok'), - cancelText: i18n('cancel'), - isAdmin: this.isAdmin, - i18n, - onSubmit: this.onSubmit, - onClose: this.close, - avatarPath: this.avatarPath, - }, - }); - - this.$el.append(this.dialogView.el); - return this; - }, - onSubmit(groupName, avatar) { - window.doUpdateGroup(this.groupId, groupName, this.members, avatar); - }, - close() { - this.remove(); - }, - }); - Whisper.UpdateGroupMembersDialogView = Whisper.View.extend({ className: 'loki-dialog modal', initialize(groupConvo) { diff --git a/js/views/invite_friends_dialog_view.js b/js/views/invite_contacts_dialog_view.js similarity index 94% rename from js/views/invite_friends_dialog_view.js rename to js/views/invite_contacts_dialog_view.js index f29a0febd..31f3fd086 100644 --- a/js/views/invite_friends_dialog_view.js +++ b/js/views/invite_contacts_dialog_view.js @@ -14,7 +14,9 @@ const convos = window.getConversations().models; - this.contacts = convos.filter(d => !!d && d.isPrivate() && !d.isMe()); + this.contacts = convos.filter( + d => !!d && !d.isBlocked() && d.isPrivate() && !d.isMe() + ); if (!convo.isPublic()) { const members = convo.get('members') || []; this.contacts = this.contacts.filter(d => !members.includes(d.id)); @@ -32,7 +34,7 @@ render() { const view = new Whisper.ReactWrapperView({ className: 'invite-friends-dialog', - Component: window.Signal.Components.InviteFriendsDialog, + Component: window.Signal.Components.InviteContactsDialog, props: { contactList: this.contacts, onSubmit: this.submit, diff --git a/js/views/moderators_add_dialog_view.js b/js/views/moderators_add_dialog_view.js index 2d2773957..039baa87e 100644 --- a/js/views/moderators_add_dialog_view.js +++ b/js/views/moderators_add_dialog_view.js @@ -21,9 +21,14 @@ const modPubKeys = await this.channelAPI.getModerators(); const convos = window.getConversations().models; - // private friends (not you) that aren't already moderators + // private contacts (not you) that aren't already moderators const contacts = convos.filter( - d => !!d && d.isPrivate() && !d.isMe() && !modPubKeys.includes(d.id) + d => + !!d && + d.isPrivate() && + !d.isBlocked() && + !d.isMe() && + !modPubKeys.includes(d.id) ); this.contacts = contacts; diff --git a/libloki/api.js b/libloki/api.js index a5a88a643..6e591d360 100644 --- a/libloki/api.js +++ b/libloki/api.js @@ -48,12 +48,6 @@ } } - function logSessionRequest(...args) { - if (debugFlags & DebugFlagsEnum.SESSION_REQUEST_MESSAGES) { - debugLogFn(...args); - } - } - function logBackgroundMessage(...args) { if (debugFlags & DebugFlagsEnum.SESSION_BACKGROUND_MESSAGE) { debugLogFn(...args); @@ -290,7 +284,6 @@ const debug = { logContactSync, logGroupSync, - logSessionRequest, logSessionMessageSending, logBackgroundMessage, logGroupRequestInfo, diff --git a/libtextsecure/outgoing_message.js b/libtextsecure/outgoing_message.js index a38df2a10..44ab61e2f 100644 --- a/libtextsecure/outgoing_message.js +++ b/libtextsecure/outgoing_message.js @@ -14,8 +14,6 @@ const NUM_SEND_CONNECTIONS = 3; const getTTLForType = type => { switch (type) { - case 'session-request': - return 4 * 24 * 60 * 60 * 1000; // 4 days for session request message case 'device-unpairing': return 4 * 24 * 60 * 60 * 1000; // 4 days for device unpairing case 'onlineBroadcast': @@ -106,15 +104,9 @@ function getStaleDeviceIdsForNumber(number) { } const DebugMessageType = { - SESSION_REQUEST: 'session-request', - SESSION_REQUEST_ACCEPT: 'session-request-accepted', - SESSION_RESET: 'session-reset', SESSION_RESET_RECV: 'session-reset-received', - OUTGOING_FR_ACCEPTED: 'outgoing-friend-request-accepted', - INCOMING_FR_ACCEPTED: 'incoming-friend-request-accept', - REQUEST_SYNC_SEND: 'request-sync-send', CONTACT_SYNC_SEND: 'contact-sync-send', CLOSED_GROUP_SYNC_SEND: 'closed-group-sync-send', @@ -355,8 +347,7 @@ OutgoingMessage.prototype = { const keysFound = await this.getKeysForNumber(devicePubKey, updatedDevices); // Check if we need to attach the preKeys - const enableFallBackEncryption = - !keysFound || this.messageType === 'session-request'; + const enableFallBackEncryption = !keysFound; const flags = this.message.dataMessage ? this.message.dataMessage.get_flags() : null; @@ -414,7 +405,6 @@ OutgoingMessage.prototype = { sourceDevice: 1, plaintext, pubKey: devicePubKey, - isFriendRequest: enableFallBackEncryption, isSessionRequest, enableFallBackEncryption, }; @@ -434,7 +424,6 @@ OutgoingMessage.prototype = { plaintext, pubKey, isSessionRequest, - isFriendRequest, enableFallBackEncryption, } = clearMessage; // Session doesn't use the deviceId scheme, it's always 1. @@ -480,7 +469,6 @@ OutgoingMessage.prototype = { sourceDevice, content, pubKey, - isFriendRequest, isSessionRequest, }; }, @@ -551,8 +539,6 @@ OutgoingMessage.prototype = { ourKey: ourIdentity, sourceDevice: 1, content: contentOuter.encode().toArrayBuffer(), - isFriendRequest: false, - isSessionRequest: false, }; // TODO: Rather than using sealed sender, we just generate a key pair, perform an ECDH against @@ -672,10 +658,7 @@ OutgoingMessage.buildSessionRequestMessage = function buildSessionRequestMessage dataMessage, }); - const options = { - messageType: 'session-request', - debugMessageType: DebugMessageType.SESSION_REQUEST, - }; + const options = {}; // Send a empty message with information about how to contact us directly return new OutgoingMessage( null, // server diff --git a/libtextsecure/sendmessage.js b/libtextsecure/sendmessage.js index 6d67ee2ad..077e9bc61 100644 --- a/libtextsecure/sendmessage.js +++ b/libtextsecure/sendmessage.js @@ -439,8 +439,7 @@ MessageSender.prototype = { haveSession || keysFound || options.isPublic || - options.isMediumGroup || - options.messageType === 'session-request' + options.isMediumGroup ) { const outgoing = new OutgoingMessage( this.server, diff --git a/test/index.html b/test/index.html index a5ffa28a3..eb6a097c9 100644 --- a/test/index.html +++ b/test/index.html @@ -555,7 +555,7 @@ - + diff --git a/ts/components/conversation/InviteFriendsDialog.tsx b/ts/components/conversation/InviteContactsDialog.tsx similarity index 98% rename from ts/components/conversation/InviteFriendsDialog.tsx rename to ts/components/conversation/InviteContactsDialog.tsx index 0066a5813..c77d044b9 100644 --- a/ts/components/conversation/InviteFriendsDialog.tsx +++ b/ts/components/conversation/InviteContactsDialog.tsx @@ -18,7 +18,7 @@ interface State { contactList: Array; } -export class InviteFriendsDialog extends React.Component { +export class InviteContactsDialog extends React.Component { constructor(props: any) { super(props); diff --git a/ts/components/session/SessionClosableOverlay.tsx b/ts/components/session/SessionClosableOverlay.tsx index 74f702e5a..d9ad94de4 100644 --- a/ts/components/session/SessionClosableOverlay.tsx +++ b/ts/components/session/SessionClosableOverlay.tsx @@ -72,7 +72,8 @@ export class SessionClosableOverlay extends React.Component { return ( !conversation.isMe() && conversation.isPrivate() && - !conversation.isSecondaryDevice() + !conversation.isSecondaryDevice() && + !conversation.isBlocked() ); }); diff --git a/ts/receiver/queuedJob.ts b/ts/receiver/queuedJob.ts index fcfbb0805..f6022d00e 100644 --- a/ts/receiver/queuedJob.ts +++ b/ts/receiver/queuedJob.ts @@ -437,7 +437,7 @@ async function handleRegularMessage( handleMentions(message, conversation, ourNumber); - if (type === 'incoming' || message.isEndSession()) { + if (type === 'incoming') { updateReadStatus(message, conversation); } diff --git a/ts/receiver/receiver.ts b/ts/receiver/receiver.ts index 9e2ba86cf..070077e32 100644 --- a/ts/receiver/receiver.ts +++ b/ts/receiver/receiver.ts @@ -26,7 +26,6 @@ interface MessageCreationData { receivedAt: number; sourceDevice: number; // always 1 isn't it? unidentifiedDeliveryReceived: any; // ??? - isSessionRequest: boolean; isRss: boolean; source: boolean; serverId: string; @@ -534,7 +533,6 @@ export async function handleDataMessage( ev.confirm = () => removeFromCache(envelope); ev.data = { - isSessionRequest: envelope.type === SESSION_REQUEST, source, sourceDevice: envelope.sourceDevice, timestamp: toNumber(envelope.timestamp), @@ -593,8 +591,6 @@ export async function handleMessageEvent(event: any): Promise { const isDuplicate = await isMessageDuplicate(data); - const testNb: number = 3.1545; - if (isDuplicate) { // RSS expects duplicates, so squelch log if (!source.match(/^rss:/)) { @@ -604,11 +600,9 @@ export async function handleMessageEvent(event: any): Promise { return; } - // Note(LOKI): don't send receipt for FR as we don't have a session yet const shouldSendReceipt = isIncoming && data.unidentifiedDeliveryReceived && - !data.isSessionRequest && !isGroupMessage; if (shouldSendReceipt) { diff --git a/ts/session/protocols/SessionProtocol.ts b/ts/session/protocols/SessionProtocol.ts index 282fb33d9..acd21dab4 100644 --- a/ts/session/protocols/SessionProtocol.ts +++ b/ts/session/protocols/SessionProtocol.ts @@ -174,8 +174,6 @@ export class SessionProtocol { if (!SessionProtocol.dbLoaded) { const sentItem = await getItemById('sentSessionsTimestamp'); if (sentItem) { - // FIXME we must update the existing map with those items - // or empty the existing map, not create a new one SessionProtocol.sentSessionsTimestamp = sentItem.value; } else { SessionProtocol.sentSessionsTimestamp = {};