Clean up old messages, better handle errors from sending
This commit is contained in:
parent
bf63c7cc13
commit
727925a266
10 changed files with 232 additions and 66 deletions
|
@ -346,6 +346,49 @@
|
|||
});
|
||||
}
|
||||
|
||||
Views.Initialization.setMessage(window.i18n('optimizingApplication'));
|
||||
|
||||
window.log.info('Cleanup: starting...');
|
||||
const messagesForCleanup = await window.Signal.Data.getOutgoingWithoutExpiresAt(
|
||||
{
|
||||
MessageCollection: Whisper.MessageCollection,
|
||||
}
|
||||
);
|
||||
window.log.info(
|
||||
`Cleanup: Found ${messagesForCleanup.length} messages for cleanup`
|
||||
);
|
||||
await Promise.all(
|
||||
messagesForCleanup.map(async message => {
|
||||
const delivered = message.get('delivered');
|
||||
const sentAt = message.get('sent_at');
|
||||
const expirationStartTimestamp = message.get(
|
||||
'expirationStartTimestamp'
|
||||
);
|
||||
|
||||
if (message.hasErrors()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (delivered) {
|
||||
window.log.info(
|
||||
`Cleanup: Starting timer for delivered message ${sentAt}`
|
||||
);
|
||||
message.set(
|
||||
'expirationStartTimestamp',
|
||||
expirationStartTimestamp || sentAt
|
||||
);
|
||||
await message.setToExpire();
|
||||
return;
|
||||
}
|
||||
|
||||
window.log.info(`Cleanup: Deleting unsent message ${sentAt}`);
|
||||
await window.Signal.Data.removeMessage(message.id, {
|
||||
Message: Whisper.Message,
|
||||
});
|
||||
})
|
||||
);
|
||||
window.log.info('Cleanup: complete');
|
||||
|
||||
Views.Initialization.setMessage(window.i18n('loading'));
|
||||
|
||||
// Note: We are not invoking the second set of IndexedDB migrations because it is
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue