mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 11:18:41 +00:00
remove old retransmission messages
This commit is contained in:
parent
c70413cf6a
commit
c4b928f1b9
3 changed files with 16 additions and 4 deletions
|
|
@ -46,7 +46,8 @@ void main() async {
|
|||
twonlyDB = TwonlyDatabase();
|
||||
|
||||
await twonlyDB.messagesDao.resetPendingDownloadState();
|
||||
await twonlyDB.messagesDao.handleMediaFilesOlderThan7Days();
|
||||
await twonlyDB.messagesDao.handleMediaFilesOlderThan30Days();
|
||||
await twonlyDB.messageRetransmissionDao.purgeOldRetransmissions();
|
||||
await twonlyDB.signalDao.purgeOutDatedPreKeys();
|
||||
|
||||
// Purge media files in the background
|
||||
|
|
|
|||
|
|
@ -22,6 +22,17 @@ class MessageRetransmissionDao extends DatabaseAccessor<TwonlyDatabase>
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> purgeOldRetransmissions() async {
|
||||
// delete entries older than two weeks
|
||||
await (delete(messageRetransmissions)
|
||||
..where((t) => (t.acknowledgeByServerAt.isSmallerThanValue(
|
||||
DateTime.now().subtract(
|
||||
const Duration(days: 25),
|
||||
),
|
||||
))))
|
||||
.go();
|
||||
}
|
||||
|
||||
Future<List<int>> getRetransmitAbleMessages() async {
|
||||
final countDeleted = await (delete(messageRetransmissions)
|
||||
..where((t) =>
|
||||
|
|
|
|||
|
|
@ -69,8 +69,8 @@ class MessagesDao extends DatabaseAccessor<TwonlyDatabase>
|
|||
.write(const MessagesCompanion(contentJson: Value(null)));
|
||||
}
|
||||
|
||||
Future<void> handleMediaFilesOlderThan7Days() {
|
||||
/// media files will be deleted by the server after 7 days, so delete them here also
|
||||
Future<void> handleMediaFilesOlderThan30Days() {
|
||||
/// media files will be deleted by the server after 30 days, so delete them here also
|
||||
return (update(messages)
|
||||
..where(
|
||||
(t) => (t.kind.equals(MessageKind.media.name) &
|
||||
|
|
@ -78,7 +78,7 @@ class MessagesDao extends DatabaseAccessor<TwonlyDatabase>
|
|||
t.messageOtherId.isNull() &
|
||||
(t.sendAt.isSmallerThanValue(
|
||||
DateTime.now().subtract(
|
||||
const Duration(days: 8),
|
||||
const Duration(days: 30),
|
||||
),
|
||||
))),
|
||||
))
|
||||
|
|
|
|||
Loading…
Reference in a new issue