mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 13:08:42 +00:00
fix #324
This commit is contained in:
parent
b8c063cc29
commit
6ab11c4e69
1 changed files with 25 additions and 23 deletions
|
|
@ -31,6 +31,7 @@ class MediaFileService {
|
||||||
for (final file in files) {
|
for (final file in files) {
|
||||||
final mediaId = basename(file.path).split('.').first;
|
final mediaId = basename(file.path).split('.').first;
|
||||||
|
|
||||||
|
// in case the mediaID is unknown the file will be deleted
|
||||||
var delete = true;
|
var delete = true;
|
||||||
|
|
||||||
final service = await MediaFileService.fromMediaId(mediaId);
|
final service = await MediaFileService.fromMediaId(mediaId);
|
||||||
|
|
@ -46,8 +47,10 @@ class MediaFileService {
|
||||||
// in case messages in empty the file will be deleted, as delete is true by default
|
// in case messages in empty the file will be deleted, as delete is true by default
|
||||||
|
|
||||||
for (final message in messages) {
|
for (final message in messages) {
|
||||||
if (message.senderId == null) {
|
if (service.mediaFile.type == MediaType.audio) {
|
||||||
// Media was send by me
|
delete = false; // do not delete voice messages
|
||||||
|
}
|
||||||
|
|
||||||
if (message.openedAt == null) {
|
if (message.openedAt == null) {
|
||||||
// Message was not yet opened from all persons, so wait...
|
// Message was not yet opened from all persons, so wait...
|
||||||
delete = false;
|
delete = false;
|
||||||
|
|
@ -58,19 +61,18 @@ class MediaFileService {
|
||||||
// this is just to make it easier to understand :)
|
// this is just to make it easier to understand :)
|
||||||
} else if (message.openedAt!
|
} else if (message.openedAt!
|
||||||
.isAfter(DateTime.now().subtract(const Duration(days: 2)))) {
|
.isAfter(DateTime.now().subtract(const Duration(days: 2)))) {
|
||||||
// Message was opened by all persons, as it can be reopened and then stored by a other person keep it for
|
// In case the image was opened, but send with unlimited time or no authentication.
|
||||||
// two day just to be sure.
|
if (message.senderId == null) {
|
||||||
delete = false;
|
delete = false;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// this media was received from another person
|
// Check weather the image was send in a group. Then the images is preserved for two days in case another person stores the image.
|
||||||
if (message.openedAt == null) {
|
// This also allows to reopen this image for two days.
|
||||||
// Message was not yet opened, so do not remove it.
|
final group = await twonlyDB.groupsDao.getGroup(message.groupId);
|
||||||
|
if (group != null && !group.isDirectChat) {
|
||||||
delete = false;
|
delete = false;
|
||||||
}
|
}
|
||||||
if (service.mediaFile.type == MediaType.audio) {
|
|
||||||
delete = false; // do not delete voice messages
|
|
||||||
}
|
}
|
||||||
|
// In case the app was send in a direct chat, then it can be deleted.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue