Fixed wakeup with attachments

This commit is contained in:
M66B 2020-06-29 08:13:57 +02:00
parent c5dabd3390
commit 94597ef61b
1 changed files with 33 additions and 3 deletions

View File

@ -464,14 +464,44 @@ public class ServiceUI extends IntentService {
} }
} else { } else {
if (folder.notify) { if (folder.notify) {
List<EntityAttachment> attachments = db.attachment().getAttachments(id);
// A new message ID is needed for a new (wearable) notification // A new message ID is needed for a new (wearable) notification
db.message().deleteMessage(id); db.message().deleteMessage(id);
message.id = null; message.id = null;
message.fts = false; message.fts = false;
message.id = db.message().insertMessage(message); message.id = db.message().insertMessage(message);
if (message.content)
EntityMessage.getFile(this, id) if (message.content) {
.renameTo(message.getFile(this)); File source = EntityMessage.getFile(this, id);
File target = message.getFile(this);
try {
Helper.copy(source, target);
} catch (IOException ex) {
Log.e(ex);
db.message().resetMessageContent(message.id);
}
}
for (EntityAttachment attachment : attachments) {
File source = attachment.getFile(this);
attachment.id = null;
attachment.message = message.id;
attachment.progress = null;
attachment.id = db.attachment().insertAttachment(attachment);
if (attachment.available) {
File target = attachment.getFile(this);
try {
Helper.copy(source, target);
} catch (IOException ex) {
Log.e(ex);
db.attachment().setError(attachment.id, Log.formatThrowable(ex, false));
}
}
}
} }
db.message().setMessageSnoozed(message.id, null); db.message().setMessageSnoozed(message.id, null);
db.message().setMessageUnsnoozed(message.id, true); db.message().setMessageUnsnoozed(message.id, true);