Migrate to SQLCipher for messages/cache

Quite a few other fixes, including:
  - Sending to contact with no avatar yet (not synced from mobile)
  - Left pane doesn't update quickly or at all on new message
  - Left pane doesn't show sent or error status

Also:
 - Contributing.md: Ensure set of linux dev dependencies is complete
This commit is contained in:
Scott Nonnenberg
2018-07-26 18:13:56 -07:00
parent fc461c82ce
commit 3105b77475
29 changed files with 2006 additions and 716 deletions

View File

@@ -166,7 +166,7 @@ exports._mapAttachments = upgradeAttachment => async (message, context) => {
const upgradeWithContext = attachment =>
upgradeAttachment(attachment, context);
const attachments = await Promise.all(
message.attachments.map(upgradeWithContext)
(message.attachments || []).map(upgradeWithContext)
);
return Object.assign({}, message, { attachments });
};
@@ -356,7 +356,9 @@ exports.upgradeSchema = async (
exports.createAttachmentLoader = loadAttachmentData => {
if (!isFunction(loadAttachmentData)) {
throw new TypeError('`loadAttachmentData` is required');
throw new TypeError(
'createAttachmentLoader: loadAttachmentData is required'
);
}
return async message =>
@@ -367,6 +369,36 @@ exports.createAttachmentLoader = loadAttachmentData => {
});
};
exports.loadQuoteData = loadAttachmentData => {
if (!isFunction(loadAttachmentData)) {
throw new TypeError('loadQuoteData: loadAttachmentData is required');
}
return async quote => {
if (!quote) {
return null;
}
return {
...quote,
attachments: await Promise.all(
(quote.attachments || []).map(async attachment => {
const { thumbnail } = attachment;
if (!thumbnail || !thumbnail.path) {
return attachment;
}
return {
...attachment,
thumbnail: await loadAttachmentData(thumbnail),
};
})
),
};
};
};
exports.deleteAllExternalFiles = ({ deleteAttachmentData, deleteOnDisk }) => {
if (!isFunction(deleteAttachmentData)) {
throw new TypeError(
@@ -392,7 +424,7 @@ exports.deleteAllExternalFiles = ({ deleteAttachmentData, deleteOnDisk }) => {
quote.attachments.map(async attachment => {
const { thumbnail } = attachment;
if (thumbnail.path) {
if (thumbnail && thumbnail.path) {
await deleteOnDisk(thumbnail.path);
}
})