pull/156/head
M66B 6 years ago
parent 1764c52b2d
commit 86b55996f4

@ -438,10 +438,22 @@ class Core {
// Add message
DB db = DB.getInstance(context);
// Get arguments
Long tmpid = (jargs.length() > 0 && !jargs.isNull(0) ? jargs.getLong(0) : null);
boolean autoread = (jargs.length() > 1 && jargs.getBoolean(1));
boolean across = (jargs.length() > 2 && jargs.getBoolean(2));
try {
if (TextUtils.isEmpty(message.msgid))
throw new IllegalArgumentException("Message ID missing");
if (EntityFolder.DRAFTS.equals(folder.type) &&
!folder.id.equals(message.folder) &&
!across) {
Log.i("Drafts moved folder=" + message.folder);
return;
}
// Delete previous message(s) with same ID
if (folder.id.equals(message.folder)) {
// Prevent adding/deleting message
@ -483,14 +495,10 @@ class Core {
}
// Handle auto read
boolean autoread = false;
if (jargs.length() > 1) {
autoread = jargs.getBoolean(1);
if (ifolder.getPermanentFlags().contains(Flags.Flag.SEEN)) {
if (autoread && !imessage.isSet(Flags.Flag.SEEN)) {
Log.i(folder.name + " autoread");
imessage.setFlag(Flags.Flag.SEEN, true);
}
if (ifolder.getPermanentFlags().contains(Flags.Flag.SEEN)) {
if (autoread && !imessage.isSet(Flags.Flag.SEEN)) {
Log.i(folder.name + " autoread");
imessage.setFlag(Flags.Flag.SEEN, true);
}
}
@ -532,16 +540,16 @@ class Core {
if (folder.id.equals(message.folder)) {
Log.i(folder.name + " Setting id=" + message.id + " uid=" + uid);
db.message().setMessageUid(message.id, uid);
} else {
// Cross account move
if (jargs.length() > 0 && !jargs.isNull(0)) {
long tmpid = jargs.getLong(0);
Log.i(folder.name + " Setting id=" + tmpid + " (tmp) appended uid=" + uid);
db.message().setMessageUid(tmpid, uid);
}
} else
try {
db.beginTransaction();
// Cross account move
if (tmpid != null) {
Log.i(folder.name + " Setting id=" + tmpid + " (tmp) appended uid=" + uid);
db.message().setMessageUid(tmpid, uid);
}
// Mark source read
if (autoread) {
Log.i(folder.name + " queuing SEEN id=" + message.id);
@ -556,7 +564,6 @@ class Core {
} finally {
db.endTransaction();
}
}
} catch (Throwable ex) {
if (folder.id.equals(message.folder))
db.message().setMessageUid(message.id, message.uid);
@ -664,6 +671,7 @@ class Core {
// Cross account move
long target = jargs.getLong(2);
jargs.remove(2);
jargs.put(2, true); // cross account
Log.i(folder.name + " queuing ADD id=" + message.id + ":" + target);
EntityOperation operation = new EntityOperation();

@ -184,16 +184,17 @@ public class EntityOperation {
EntityAttachment.copy(context, message.id, tmpid);
}
// Cross account move
if (source.account.equals(target.account))
jargs.put(2, tmpid); // Can be null
else {
// Cross account move
if (message.raw != null && message.raw) {
name = ADD;
folder = target.id;
jargs = new JSONArray();
jargs.put(0, tmpid); // Can be null
jargs.put(1, autoread);
jargs.put(2, true); // Cross account
} else {
name = RAW;
jargs = new JSONArray();

Loading…
Cancel
Save