Browse Source

Sent fixes

main
M66B 6 years ago
parent
commit
fa97fa48e6
2 changed files with 13 additions and 9 deletions
  1. +5
    -1
      app/src/main/java/eu/faircode/email/DaoMessage.java
  2. +8
    -8
      app/src/main/java/eu/faircode/email/ServiceSynchronize.java

+ 5
- 1
app/src/main/java/eu/faircode/email/DaoMessage.java View File

@ -80,7 +80,11 @@ public interface DaoMessage {
@Query("SELECT * FROM message WHERE folder = :folder AND uid = :uid") @Query("SELECT * FROM message WHERE folder = :folder AND uid = :uid")
EntityMessage getMessageByUid(long folder, long uid); EntityMessage getMessageByUid(long folder, long uid);
@Query("SELECT * FROM message WHERE msgid = :msgid")
@Query("SELECT message.* FROM message" +
" JOIN folder ON folder.id = message.folder" +
" WHERE msgid = :msgid" +
" AND folder.type <> '" + EntityFolder.INBOX + "'" +
" AND folder.type <> '" + EntityFolder.ARCHIVE + "'")
EntityMessage getMessageByMsgId(String msgid); EntityMessage getMessageByMsgId(String msgid);
@Query("SELECT message.* FROM message" + @Query("SELECT message.* FROM message" +


+ 8
- 8
app/src/main/java/eu/faircode/email/ServiceSynchronize.java View File

@ -970,8 +970,8 @@ public class ServiceSynchronize extends LifecycleService {
message.ui_seen = true; message.ui_seen = true;
db.message().updateMessage(message); db.message().updateMessage(message);
if (sent != null)
EntityOperation.queue(db, message, EntityOperation.ADD); // Could already exist
//if (sent != null)
// EntityOperation.queue(db, message, EntityOperation.ADD); // Could already exist
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} finally { } finally {
@ -1193,14 +1193,15 @@ public class ServiceSynchronize extends LifecycleService {
// Find message by Message-ID (slow, headers required) // Find message by Message-ID (slow, headers required)
// - messages in inbox have same id as message sent to self // - messages in inbox have same id as message sent to self
// - messages in archive have same id as original // - messages in archive have same id as original
if (message == null &&
!EntityFolder.SENT.equals(folder.type) &&
!EntityFolder.ARCHIVE.equals(folder.type)) {
if (message == null) {
// Will fetch headers within database transaction // Will fetch headers within database transaction
String msgid = imessage.getMessageID(); String msgid = imessage.getMessageID();
message = db.message().getMessageByMsgId(msgid); message = db.message().getMessageByMsgId(msgid);
if (message != null) { if (message != null) {
if (message.folder == folder.id || EntityFolder.OUTBOX.equals(folder.type)) {
EntityFolder mfolder = db.folder().getFolder(message.folder);
Log.i(Helper.TAG, folder.name + " found as id=" + message.id +
" folder=" + mfolder.type + ":" + message.folder + "/" + folder.type + ":" + folder.id);
if (message.folder.equals(folder.id) || EntityFolder.OUTBOX.equals(mfolder.type)) {
Log.i(Helper.TAG, folder.name + " found as id=" + message.id + " uid=" + message.uid + " msgid=" + msgid); Log.i(Helper.TAG, folder.name + " found as id=" + message.id + " uid=" + message.uid + " msgid=" + msgid);
message.folder = folder.id; message.folder = folder.id;
message.uid = uid; message.uid = uid;
@ -1243,8 +1244,7 @@ public class ServiceSynchronize extends LifecycleService {
message.folder = folder.id; message.folder = folder.id;
message.uid = uid; message.uid = uid;
if (!EntityFolder.SENT.equals(folder.type) &&
!EntityFolder.ARCHIVE.equals(folder.type)) {
if (!EntityFolder.ARCHIVE.equals(folder.type)) {
message.msgid = helper.getMessageID(); message.msgid = helper.getMessageID();
if (TextUtils.isEmpty(message.msgid)) if (TextUtils.isEmpty(message.msgid))
Log.w(Helper.TAG, "No Message-ID id=" + message.id + " uid=" + message.uid); Log.w(Helper.TAG, "No Message-ID id=" + message.id + " uid=" + message.uid);


Loading…
Cancel
Save