Skip to content

Commit

Permalink
Session 1.7.2 (#1932)
Browse files Browse the repository at this point in the history
* Keep line breaks when message has some new lines

Relates #1758 and #1898 and #1901

* Fix path building (#1903)

* Keep line breaks when message has some new lines

Relates #1758 and #1898 and #1901

* fix link preview cropped when received

* make sure we fetch from seed if we end up with not enough snodes

* try to download recent previews if we just trusted a user

* throw if we need to rebuild path while fetching snode list from snode

* fixup no refecthing of snode list while we are fetching them already

* added test for fetch from db or seed

* fetch snode list from snode every hour

also make sure the path building does not try to get more snodes. It
just throws

* do not drop a path if an opengroup room is down and we get errors  back

* do not throw an error if the snode in error in not in any path

* fix tests

* bump to v1.7.11

* disable sending on enter while composing (#1909)

Fixes #1899 #1497

* Speedup body update composition box (#1911)

* disable sending on enter while composing

Fixes #1899 #1497

* ask confirmation before deleting account

* move drafts outside of redux to speedup body message writing

* Ask confirm before delete account (#1910)

* disable sending on enter while composing

Fixes #1899 #1497

* ask confirmation before deleting account

* fix app start delete db when passowrd error

* fix double dialog issue with delete account

* fixup login screen

* use timestamp offset in for messages storage requests (#1892)

* add using timestamp offset from network for sending part1

* remove MessageController as we now rely on the database

* fix tests for message sending overriding timestamp

* Fix today for translated date break (#1915)

* add using timestamp offset from network for sending part1

* remove MessageController as we now rely on the database

* fix tests for message sending overriding timestamp

* Fixs date break translations of today etc

Relates #1913

* Fix video play lightbox autostart (#1920)

* disable sending on enter while composing

Fixes #1899 #1497

* ask confirmation before deleting account

* fix app start delete db when passowrd error

* fix double dialog issue with delete account

* fixup login screen

* Fix video autoplay start when not initialized

Relates #1904

* do not overwrite sent_at with network time for synced messages (#1921)

* do not update sent_at for synced messages

* reply to message context menu only visible if msg sent

* Out of sync message sync (#1923)

* do not update sent_at for synced messages

* reply to message context menu only visible if msg sent

* Allow scrolling in mentioning people in composition box

Relates #1849

* Fix select colors for sent messages and link text not selectable (#1924)

* do not update sent_at for synced messages

* reply to message context menu only visible if msg sent

* Allow scrolling in mentioning people in composition box

Relates #1849

* fix selection colors for sent messages and make link selectable

Relates #1922

* Cleanup redux store (#1925)

* do not consider expire timer update unread messages #1881

* cleanup conversation props in redux to only have what cannot be derived

* fix app not starting without the await on convo creation

* cleanup props of message model

* Unsend messages (only message hashes saving for now is enabled) (#1891)

* WIP unsending message.

* retrieving message with hash from db on receiving unsend request.

* outgoing messages hashes updated on message sent success

* unsend messaging

* unsend message - deleting messages and marking as isDeleted.

* add msg hash to unprocessed records.

* Message unsending working for closed groups provided the message has been updated with a hash from server.

* adding 2-stage confirmation modal for message deletion

* adding rendering of removed incoming messages, disabling rendering of unsent outgoing messages in coversation screen.

* Adding logging

* debugging.

* outgoing only saved for sync message instead of regular message.

* deleting locally

* adding post unsend deletioncode.

* starting adding feature flag.

* Added feature flag.

* addding mandatory messageHash  pollling pipeline methods swarm polling.

* Conversation list item message preview showing deletion placeholder text if deleted.

* add condition to drop unsend requests not send by message author

* refactoring deleteMessage. Saving response hash for closed group message sending

* running yarn ready

* removing logging.

* Adding PR fixes

* Minor changes and running yarn ready

* fix typo

* Moved feature flag to lokiFeatureFlags. Fixing linting errors


Co-authored-by: Audric Ackermann <[email protected]>

* fix reply for incoming messages (#1930)

* bump to 1.7.2 (#1926)

* do not consider expire timer update unread messages #1881

* cleanup conversation props in redux to only have what cannot be derived

* fix app not starting without the await on convo creation

* cleanup props of message model

* bump to 1.7.2

* Session 1.7.1 (#1908) (#1931)

* Keep line breaks when message has some new lines

Relates #1758 and #1898 and #1901

* Fix path building (#1903)

* Keep line breaks when message has some new lines

Relates #1758 and #1898 and #1901

* fix link preview cropped when received

* make sure we fetch from seed if we end up with not enough snodes

* try to download recent previews if we just trusted a user

* throw if we need to rebuild path while fetching snode list from snode

* fixup no refecthing of snode list while we are fetching them already

* added test for fetch from db or seed

* fetch snode list from snode every hour

also make sure the path building does not try to get more snodes. It
just throws

* do not drop a path if an opengroup room is down and we get errors  back

* do not throw an error if the snode in error in not in any path

* fix tests

* bump to v1.7.11

* disable unsend request on the UI for now (#1934)

* disable unsend request on the UI too

* do not stop propagation of events for message ctx menu

Co-authored-by: Warrick <[email protected]>
  • Loading branch information
Bilb and warrickct authored Sep 20, 2021
1 parent 797bf06 commit 1768038
Show file tree
Hide file tree
Showing 95 changed files with 1,844 additions and 1,104 deletions.
12 changes: 11 additions & 1 deletion _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@
"moreInformation": "More information",
"resend": "Resend",
"deleteMessage": "Delete Message",
"deleteMessageQuestion": "Delete message?",
"deleteMessagesQuestion": "Delete messages?",
"deleteMessages": "Delete Messages",
"deleteMessageForEveryone": "Delete Message For Everyone",
"deleteMessageForEveryoneLowercase": "Delete Message For Everyone",
"deleteMessagesForEveryone": "Delete Messages For Everyone",
"deleteForEveryone": "Delete for Everyone",
"deleteConversationConfirmation": "Permanently delete the messages in this conversation?",
Expand Down Expand Up @@ -428,8 +431,15 @@
"dialogClearAllDataDeletionQuestion": "Would you like to clear only this device, or delete your entire account?",
"deviceOnly": "Device Only",
"entireAccount": "Entire Account",
"areYouSureDeleteDeviceOnly": "Are you sure you want to delete your device data only?",
"areYouSureDeleteEntireAccount": "Are you sure you want to delete your entire account, including the network data?",
"iAmSure": "I am sure",
"recoveryPhraseSecureTitle": "You're almost finished!",
"recoveryPhraseRevealMessage": "Secure your account by saving your recovery phrase. Reveal your recovery phrase then store it safely to secure it.",
"recoveryPhraseRevealButtonText": "Reveal Recovery Phrase",
"notificationSubtitle": "Notifications - $setting$"
"notificationSubtitle": "Notifications - $setting$",
"deletionTypeTitle": "Deletion Type",
"deleteJustForMe": "Delete just for me",
"messageDeletedPlaceholder": "This message has been deleted",
"messageDeleted": "Message deleted"
}
57 changes: 54 additions & 3 deletions app/sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module.exports = {
getMessageBySender,
getMessageBySenderAndServerId,
getMessageBySenderAndServerTimestamp,
getMessageBySenderAndTimestamp,
getMessageIdsFromServerIds,
getMessageById,
getMessagesBySentAt,
Expand Down Expand Up @@ -833,6 +834,7 @@ const LOKI_SCHEMA_VERSIONS = [
updateToLokiSchemaVersion13,
updateToLokiSchemaVersion14,
updateToLokiSchemaVersion15,
updateToLokiSchemaVersion16,
];

function updateToLokiSchemaVersion1(currentVersion, db) {
Expand Down Expand Up @@ -1195,6 +1197,37 @@ function updateToLokiSchemaVersion15(currentVersion, db) {
console.log(`updateToLokiSchemaVersion${targetVersion}: success!`);
}

function updateToLokiSchemaVersion16(currentVersion, db) {
const targetVersion = 16;
if (currentVersion >= targetVersion) {
return;
}
console.log(`updateToLokiSchemaVersion${targetVersion}: starting...`);

db.transaction(() => {
db.exec(`
ALTER TABLE ${MESSAGES_TABLE} ADD COLUMN serverHash TEXT;
ALTER TABLE ${MESSAGES_TABLE} ADD COLUMN isDeleted BOOLEAN;
CREATE INDEX messages_serverHash ON ${MESSAGES_TABLE} (
serverHash
) WHERE serverHash IS NOT NULL;
CREATE INDEX messages_isDeleted ON ${MESSAGES_TABLE} (
isDeleted
) WHERE isDeleted IS NOT NULL;
ALTER TABLE unprocessed ADD serverHash TEXT;
CREATE INDEX messages_messageHash ON unprocessed (
serverHash
) WHERE serverHash IS NOT NULL;
`);

writeLokiSchemaVersion(targetVersion, db);
})();
console.log(`updateToLokiSchemaVersion${targetVersion}: success!`);
}

function writeLokiSchemaVersion(newVersion, db) {
db.prepare(
`INSERT INTO loki_schema(
Expand Down Expand Up @@ -2040,6 +2073,21 @@ function getMessageBySenderAndServerId({ source, serverId }) {
return map(rows, row => jsonToObject(row.json));
}

function getMessageBySenderAndTimestamp({ source, timestamp }) {
const rows = globalInstance
.prepare(
`SELECT json FROM ${MESSAGES_TABLE} WHERE
source = $source AND
sent_at = $timestamp;`
)
.all({
source,
timestamp,
});

return map(rows, row => jsonToObject(row.json));
}

function getMessageBySenderAndServerTimestamp({ source, serverTimestamp }) {
const rows = globalInstance
.prepare(
Expand Down Expand Up @@ -2230,7 +2278,7 @@ function getNextExpiringMessage() {

/* Unproccessed a received messages not yet processed */
function saveUnprocessed(data) {
const { id, timestamp, version, attempts, envelope, senderIdentity } = data;
const { id, timestamp, version, attempts, envelope, senderIdentity, messageHash } = data;
if (!id) {
throw new Error(`saveUnprocessed: id was falsey: ${id}`);
}
Expand All @@ -2243,14 +2291,16 @@ function saveUnprocessed(data) {
version,
attempts,
envelope,
senderIdentity
senderIdentity,
serverHash
) values (
$id,
$timestamp,
$version,
$attempts,
$envelope,
$senderIdentity
$senderIdentity,
$messageHash
);`
)
.run({
Expand All @@ -2260,6 +2310,7 @@ function saveUnprocessed(data) {
attempts,
envelope,
senderIdentity,
messageHash,
});

return id;
Expand Down
5 changes: 1 addition & 4 deletions js/expiring_messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
_,
Backbone,
i18n,
getMessageController,
moment,
Whisper
*/
Expand All @@ -19,9 +18,7 @@
const messages = await window.Signal.Data.getExpiredMessages();

await Promise.all(
messages.map(async fromDB => {
const message = getMessageController().register(fromDB.id, fromDB);

messages.map(async message => {
window.log.info('Message expired', {
sentAt: message.get('sent_at'),
});
Expand Down
5 changes: 2 additions & 3 deletions js/read_receipts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
Whisper,
Backbone,
_,
getMessageController,
window
window
*/

/* eslint-disable more/no-then */
Expand Down Expand Up @@ -57,7 +56,7 @@
return null;
}

return getMessageController().register(target.id, target);
return target;
},
async onReceipt(receipt) {
try {
Expand Down
16 changes: 7 additions & 9 deletions js/read_syncs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* global
Backbone,
Whisper,
getMessageController
*/

/* eslint-disable more/no-then */
Expand Down Expand Up @@ -53,33 +52,32 @@
return;
}

const message = getMessageController().register(found.id, found);
const readAt = receipt.get('read_at');

// If message is unread, we mark it read. Otherwise, we update the expiration
// timer to the time specified by the read sync if it's earlier than
// the previous read time.
if (message.isUnread() && window.isFocused()) {
await message.markRead(readAt);
if (found.isUnread() && window.isFocused()) {
await found.markRead(readAt);

// onReadMessage may result in messages older than this one being
// marked read. We want those messages to have the same expire timer
// start time as this one, so we pass the readAt value through.
const conversation = message.getConversation();
const conversation = found.getConversation();
if (conversation) {
conversation.onReadMessage(message, readAt);
conversation.onReadMessage(found, readAt);
}
} else {
const now = Date.now();
const existingTimestamp = message.get('expirationStartTimestamp');
const existingTimestamp = found.get('expirationStartTimestamp');
const expirationStartTimestamp = Math.min(
now,
Math.min(existingTimestamp || now, readAt || now)
);
message.set({ expirationStartTimestamp });
found.set({ expirationStartTimestamp });

const force = true;
await message.setToExpire(force);
await found.setToExpire(force);
}

this.remove(receipt);
Expand Down
5 changes: 4 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ function showAbout() {
resizable: false,
title: locale.messages.about,
autoHideMenuBar: true,
backgroundColor: '#2090EA',
backgroundColor: '#ffffff',
show: false,
webPreferences: {
nodeIntegration: false,
Expand Down Expand Up @@ -662,10 +662,13 @@ function getDefaultSQLKey() {
}

async function removeDB() {
// this don't remove attachments and stuff like that...
const userDir = await getRealPath(app.getPath('userData'));
await sql.removeDB(userDir);

try {
console.warn('Remove DB: removing.', userDir);

userConfig.remove();
ephemeralConfig.remove();
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "session-desktop",
"productName": "Session",
"description": "Private messaging from your desktop",
"version": "1.7.1",
"version": "1.7.2",
"license": "GPL-3.0",
"author": {
"name": "Loki Project",
Expand Down
15 changes: 1 addition & 14 deletions password_preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ window.getEnvironment = () => config.environment;
window.getVersion = () => config.version;
window.getAppInstance = () => config.appInstance;

const electron = require('electron');

const ipc = electron.ipcRenderer;
const { SessionPasswordPrompt } = require('./ts/components/session/SessionPasswordPrompt');

window.Signal = {
Expand All @@ -34,21 +31,11 @@ window.Signal = {

window.Signal.Logs = require('./js/modules/logs');

window.resetDatabase = () => {
window.clearLocalData = async () => {
window.log.info('reset database');
ipcRenderer.send('resetDatabase');
};

window.restart = () => {
window.log.info('restart');
ipc.send('restart');
};

window.clearLocalData = async () => {
window.resetDatabase();
window.restart();
};

window.onLogin = passPhrase =>
new Promise((resolve, reject) => {
ipcRenderer.once('password-window-login-response', (event, error) => {
Expand Down
8 changes: 1 addition & 7 deletions preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ window.lokiFeatureFlags = {
useFileOnionRequestsV2: true, // more compact encoding of files in response
padOutgoingAttachments: true,
enablePinConversations: true,
useUnsendRequests: false,
};

window.isBeforeVersion = (toCheck, baseVersion) => {
Expand Down Expand Up @@ -156,11 +157,6 @@ window.restart = () => {
ipc.send('restart');
};

window.resetDatabase = () => {
window.log.info('reset database');
ipc.send('resetDatabase');
};

ipc.on('mediaPermissionsChanged', () => {
Whisper.events.trigger('mediaPermissionsChanged');
});
Expand Down Expand Up @@ -322,8 +318,6 @@ window.models = require('./ts/models');
window.Signal = window.Signal || {};
window.Signal.Data = require('./ts/data/data');

window.getMessageController = () => window.libsession.Messages.getMessageController();

window.Signal.Logs = require('./js/modules/logs');

window.addEventListener('contextmenu', e => {
Expand Down
9 changes: 8 additions & 1 deletion protos/SignalService.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,21 @@ message TypingMessage {
}


message Unsend {
// @required
required uint64 timestamp = 1;
// @required
required string author = 2;
}


message Content {
optional DataMessage dataMessage = 1;
optional ReceiptMessage receiptMessage = 5;
optional TypingMessage typingMessage = 6;
optional ConfigurationMessage configurationMessage = 7;
optional DataExtractionNotification dataExtractionNotification = 8;

optional Unsend unsendMessage = 9;
}

message KeyPair {
Expand Down
3 changes: 2 additions & 1 deletion stylesheets/_global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ button.grey {
}

a {
color: $blue;
cursor: pointer;
user-select: text;
}

.file-input {
Expand Down
6 changes: 0 additions & 6 deletions stylesheets/_modules.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1628,12 +1628,6 @@
background-color: rgba(var(--color-sent-message-text), 0.2);
}

// Module: Highlighted Message Body

.module-message-body__highlight {
font-weight: bold;
}

// Module: Search Results

.module-search-results {
Expand Down
8 changes: 4 additions & 4 deletions stylesheets/_session.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ textarea {
input,
textarea {
user-select: text;

&::selection {
background: var(--color-text-highlight);
}
}
}

::selection {
background: var(--color-text-highlight);
}

.shadowed {
opacity: $session-shadow-opacity;
}
Expand Down
5 changes: 5 additions & 0 deletions stylesheets/_session_conversation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@
min-height: $composition-container-height;
padding: $session-margin-md 0;

ul {
max-height: 70vh;
overflow: auto;
}

textarea {
font-family: $session-font-default;
min-height: $composition-container-height / 3;
Expand Down
Loading

0 comments on commit 1768038

Please sign in to comment.