1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

Desktop: Decrypt notes that are meant to be shared

This commit is contained in:
Laurent Cozic
2019-12-17 12:45:57 +00:00
parent f60d6e0748
commit 58200ecdb1
5 changed files with 97 additions and 13 deletions

View File

@ -329,7 +329,7 @@ class BaseItem extends BaseModel {
const serialized = await ItemClass.serialize(item, shownKeys);
if (!Setting.value('encryption.enabled') || !ItemClass.encryptionSupported()) {
if (!Setting.value('encryption.enabled') || !ItemClass.encryptionSupported() || item.is_shared) {
// Normally not possible since itemsThatNeedSync should only return decrypted items
if (item.encryption_applied) throw new JoplinError('Item is encrypted but encryption is currently disabled', 'cannotSyncEncrypted');
return serialized;
@ -716,6 +716,25 @@ class BaseItem extends BaseModel {
}
}
static async updateShareStatus(item, isShared) {
if (!item.id || !item.type_) throw new Error('Item must have an ID and a type');
if (!!item.is_shared === !!isShared) return false;
const ItemClass = this.getClassByItemType(item.type_);
// No auto-timestamp because sharing a note is not seen as an update
await ItemClass.save({
id: item.id,
is_shared: isShared ? 1 : 0,
updated_time: Date.now(),
}, { autoTimestamp: false });
// The timestamps have not been changed but still need the note to be synced
// so we force-sync it.
// await this.forceSync(item.id);
return true;
}
static async forceSync(itemId) {
await this.db().exec('UPDATE sync_items SET force_sync = 1 WHERE item_id = ?', [itemId]);
}