When updating message schema pre-SQLCipher, use legacy save

This commit is contained in:
Scott Nonnenberg
2018-08-01 12:38:48 -07:00
parent 3b7ee3e2ce
commit b1c6a5fe19
3 changed files with 22 additions and 12 deletions

View File

@@ -35,6 +35,7 @@ module.exports = {
removeDB,
saveMessage,
saveLegacyMessage,
saveMessages,
removeMessage,
_removeMessages,
@@ -205,6 +206,12 @@ async function saveMessage(data, { forceSave } = {}) {
return id;
}
async function saveLegacyMessage(data, { Message }) {
const message = new Message(data);
await deferredToPromise(message.save());
return message.id;
}
async function saveMessages(arrayOfMessages, { forceSave } = {}) {
await channels.saveMessages(_cleanData(arrayOfMessages), { forceSave });
}