Remove accidental swapfile, save messages with the id given to them from public server

pull/388/head
Beaudan 6 years ago
parent f718bf15d2
commit f7039080af

@ -1411,6 +1411,7 @@
const { isError } = options; const { isError } = options;
let messageData = { let messageData = {
id: data.id,
source: data.source, source: data.source,
sourceDevice: data.sourceDevice, sourceDevice: data.sourceDevice,
sent_at: data.timestamp, sent_at: data.timestamp,

@ -2014,9 +2014,18 @@
} else { } else {
await conversation.onFriendRequestAccepted(); await conversation.onFriendRequestAccepted();
} }
const id = await window.Signal.Data.saveMessage(message.attributes, { let id;
Message: Whisper.Message, // 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 }); message.set({ id });
MessageController.register(message.id, message); MessageController.register(message.id, message);

@ -159,12 +159,14 @@ class LokiPublicChannelAPI {
let timestamp = new Date(adnMessage.created_at).getTime(); let timestamp = new Date(adnMessage.created_at).getTime();
let from = adnMessage.user.username; let from = adnMessage.user.username;
let source; let source;
let id;
if (adnMessage.annotations.length) { if (adnMessage.annotations.length) {
const noteValue = adnMessage.annotations[0].value; const noteValue = adnMessage.annotations[0].value;
({ from, timestamp, source } = noteValue); ({ from, timestamp, source, id } = noteValue);
} }
const messageData = { const messageData = {
id,
friendRequest: false, friendRequest: false,
source, source,
sourceDevice: 1, sourceDevice: 1,

Binary file not shown.
Loading…
Cancel
Save