From f7039080af2d608a49f8423899129349fdafe98a Mon Sep 17 00:00:00 2001 From: Beaudan Date: Thu, 1 Aug 2019 15:12:16 +1000 Subject: [PATCH] Remove accidental swapfile, save messages with the id given to them from public server --- js/background.js | 1 + js/models/messages.js | 15 ++++++++++++--- js/modules/loki_public_chat_api.js | 4 +++- js/views/.inbox_view.js.swp | Bin 24576 -> 0 bytes 4 files changed, 16 insertions(+), 4 deletions(-) delete mode 100644 js/views/.inbox_view.js.swp diff --git a/js/background.js b/js/background.js index c8674a4cd..b7e5fd804 100644 --- a/js/background.js +++ b/js/background.js @@ -1411,6 +1411,7 @@ const { isError } = options; let messageData = { + id: data.id, source: data.source, sourceDevice: data.sourceDevice, sent_at: data.timestamp, diff --git a/js/models/messages.js b/js/models/messages.js index d1f77a3a5..b5204c504 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -2014,9 +2014,18 @@ } else { await conversation.onFriendRequestAccepted(); } - const id = await window.Signal.Data.saveMessage(message.attributes, { - Message: Whisper.Message, - }); + let id; + // Force save if the message already has an id, used for public channels + if (message.id) { + id = await window.Signal.Data.saveMessage(message.attributes, { + forceSave: true, + Message: Whisper.Message, + }); + } else { + id = await window.Signal.Data.saveMessage(message.attributes, { + Message: Whisper.Message, + }); + } message.set({ id }); MessageController.register(message.id, message); diff --git a/js/modules/loki_public_chat_api.js b/js/modules/loki_public_chat_api.js index b93a36184..edc020059 100644 --- a/js/modules/loki_public_chat_api.js +++ b/js/modules/loki_public_chat_api.js @@ -159,12 +159,14 @@ class LokiPublicChannelAPI { let timestamp = new Date(adnMessage.created_at).getTime(); let from = adnMessage.user.username; let source; + let id; if (adnMessage.annotations.length) { const noteValue = adnMessage.annotations[0].value; - ({ from, timestamp, source } = noteValue); + ({ from, timestamp, source, id } = noteValue); } const messageData = { + id, friendRequest: false, source, sourceDevice: 1, diff --git a/js/views/.inbox_view.js.swp b/js/views/.inbox_view.js.swp deleted file mode 100644 index 460fcffa56b5a06b899333d606641f374dcf6c98..0000000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