Sent fixes

This commit is contained in:
M66B 2018-08-12 19:11:53 +00:00
parent 6d790c7d51
commit fa97fa48e6
2 changed files with 13 additions and 9 deletions

View File

@ -80,7 +80,11 @@ public interface DaoMessage {
@Query("SELECT * FROM message WHERE folder = :folder AND uid = :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);
@Query("SELECT message.* FROM message" +

View File

@ -970,8 +970,8 @@ public class ServiceSynchronize extends LifecycleService {
message.ui_seen = true;
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();
} finally {
@ -1193,14 +1193,15 @@ public class ServiceSynchronize extends LifecycleService {
// Find message by Message-ID (slow, headers required)
// - messages in inbox have same id as message sent to self
// - 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
String msgid = imessage.getMessageID();
message = db.message().getMessageByMsgId(msgid);
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);
message.folder = folder.id;
message.uid = uid;
@ -1243,8 +1244,7 @@ public class ServiceSynchronize extends LifecycleService {
message.folder = folder.id;
message.uid = uid;
if (!EntityFolder.SENT.equals(folder.type) &&
!EntityFolder.ARCHIVE.equals(folder.type)) {
if (!EntityFolder.ARCHIVE.equals(folder.type)) {
message.msgid = helper.getMessageID();
if (TextUtils.isEmpty(message.msgid))
Log.w(Helper.TAG, "No Message-ID id=" + message.id + " uid=" + message.uid);