|
|
@ -1425,6 +1425,9 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
|
|
|
|
|
|
|
private void doSeen(EntityFolder folder, IMAPFolder ifolder, EntityMessage message, JSONArray jargs, DB db) throws MessagingException, JSONException {
|
|
|
|
private void doSeen(EntityFolder folder, IMAPFolder ifolder, EntityMessage message, JSONArray jargs, DB db) throws MessagingException, JSONException {
|
|
|
|
// Mark message (un)seen
|
|
|
|
// Mark message (un)seen
|
|
|
|
|
|
|
|
if (!ifolder.getPermanentFlags().contains(Flags.Flag.SEEN))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
boolean seen = jargs.getBoolean(0);
|
|
|
|
boolean seen = jargs.getBoolean(0);
|
|
|
|
if (message.seen.equals(seen))
|
|
|
|
if (message.seen.equals(seen))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -1440,6 +1443,9 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
|
|
|
|
|
|
|
private void doAnswered(EntityFolder folder, IMAPFolder ifolder, EntityMessage message, JSONArray jargs, DB db) throws MessagingException, JSONException {
|
|
|
|
private void doAnswered(EntityFolder folder, IMAPFolder ifolder, EntityMessage message, JSONArray jargs, DB db) throws MessagingException, JSONException {
|
|
|
|
// Mark message (un)answered
|
|
|
|
// Mark message (un)answered
|
|
|
|
|
|
|
|
if (!ifolder.getPermanentFlags().contains(Flags.Flag.ANSWERED))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
boolean answered = jargs.getBoolean(0);
|
|
|
|
boolean answered = jargs.getBoolean(0);
|
|
|
|
if (message.answered.equals(answered))
|
|
|
|
if (message.answered.equals(answered))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -1455,6 +1461,9 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
|
|
|
|
|
|
|
private void doFlag(EntityFolder folder, IMAPFolder ifolder, EntityMessage message, JSONArray jargs, DB db) throws MessagingException, JSONException {
|
|
|
|
private void doFlag(EntityFolder folder, IMAPFolder ifolder, EntityMessage message, JSONArray jargs, DB db) throws MessagingException, JSONException {
|
|
|
|
// Star/unstar message
|
|
|
|
// Star/unstar message
|
|
|
|
|
|
|
|
if (!ifolder.getPermanentFlags().contains(Flags.Flag.FLAGGED))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
boolean flagged = jargs.getBoolean(0);
|
|
|
|
boolean flagged = jargs.getBoolean(0);
|
|
|
|
if (message.flagged.equals(flagged))
|
|
|
|
if (message.flagged.equals(flagged))
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -1470,6 +1479,9 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
|
|
|
|
|
|
|
private void doKeyword(EntityFolder folder, IMAPFolder ifolder, EntityMessage message, JSONArray jargs, DB db) throws MessagingException, JSONException {
|
|
|
|
private void doKeyword(EntityFolder folder, IMAPFolder ifolder, EntityMessage message, JSONArray jargs, DB db) throws MessagingException, JSONException {
|
|
|
|
// Set/reset user flag
|
|
|
|
// Set/reset user flag
|
|
|
|
|
|
|
|
if (!ifolder.getPermanentFlags().contains(Flags.Flag.USER))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// https://tools.ietf.org/html/rfc3501#section-2.3.2
|
|
|
|
// https://tools.ietf.org/html/rfc3501#section-2.3.2
|
|
|
|
String keyword = jargs.getString(0);
|
|
|
|
String keyword = jargs.getString(0);
|
|
|
|
boolean set = jargs.getBoolean(1);
|
|
|
|
boolean set = jargs.getBoolean(1);
|
|
|
@ -2096,39 +2108,45 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
attachment.id = db.attachment().insertAttachment(attachment);
|
|
|
|
attachment.id = db.attachment().insertAttachment(attachment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
boolean update = false;
|
|
|
|
|
|
|
|
|
|
|
|
if (!message.seen.equals(seen) || !message.seen.equals(message.ui_seen)) {
|
|
|
|
if (!message.seen.equals(seen) || !message.seen.equals(message.ui_seen)) {
|
|
|
|
|
|
|
|
update = true;
|
|
|
|
message.seen = seen;
|
|
|
|
message.seen = seen;
|
|
|
|
message.ui_seen = seen;
|
|
|
|
message.ui_seen = seen;
|
|
|
|
db.message().updateMessage(message);
|
|
|
|
|
|
|
|
Log.i(Helper.TAG, folder.name + " updated id=" + message.id + " uid=" + message.uid + " seen=" + seen);
|
|
|
|
Log.i(Helper.TAG, folder.name + " updated id=" + message.id + " uid=" + message.uid + " seen=" + seen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!message.answered.equals(answered) || !message.answered.equals(message.ui_answered)) {
|
|
|
|
if (!message.answered.equals(answered) || !message.answered.equals(message.ui_answered)) {
|
|
|
|
|
|
|
|
update = true;
|
|
|
|
message.answered = answered;
|
|
|
|
message.answered = answered;
|
|
|
|
message.ui_answered = answered;
|
|
|
|
message.ui_answered = answered;
|
|
|
|
db.message().updateMessage(message);
|
|
|
|
|
|
|
|
Log.i(Helper.TAG, folder.name + " updated id=" + message.id + " uid=" + message.uid + " answered=" + answered);
|
|
|
|
Log.i(Helper.TAG, folder.name + " updated id=" + message.id + " uid=" + message.uid + " answered=" + answered);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!message.flagged.equals(flagged) || !message.flagged.equals(message.ui_flagged)) {
|
|
|
|
if (!message.flagged.equals(flagged) || !message.flagged.equals(message.ui_flagged)) {
|
|
|
|
|
|
|
|
update = true;
|
|
|
|
message.flagged = flagged;
|
|
|
|
message.flagged = flagged;
|
|
|
|
message.ui_flagged = flagged;
|
|
|
|
message.ui_flagged = flagged;
|
|
|
|
db.message().updateMessage(message);
|
|
|
|
|
|
|
|
Log.i(Helper.TAG, folder.name + " updated id=" + message.id + " uid=" + message.uid + " flagged=" + flagged);
|
|
|
|
Log.i(Helper.TAG, folder.name + " updated id=" + message.id + " uid=" + message.uid + " flagged=" + flagged);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (message.ui_hide) {
|
|
|
|
if (!Helper.equal(message.keywords, keywords)) {
|
|
|
|
|
|
|
|
update = true;
|
|
|
|
|
|
|
|
message.keywords = keywords;
|
|
|
|
|
|
|
|
Log.i(Helper.TAG, folder.name + " updated id=" + message.id + " uid=" + message.uid +
|
|
|
|
|
|
|
|
" keywords=" + TextUtils.join(" ", keywords));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!update && message.ui_hide) {
|
|
|
|
|
|
|
|
update = true;
|
|
|
|
message.ui_hide = false;
|
|
|
|
message.ui_hide = false;
|
|
|
|
db.message().updateMessage(message);
|
|
|
|
db.message().updateMessage(message);
|
|
|
|
Log.i(Helper.TAG, folder.name + " updated id=" + message.id + " uid=" + message.uid + " unhide");
|
|
|
|
Log.i(Helper.TAG, folder.name + " updated id=" + message.id + " uid=" + message.uid + " unhide");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!Helper.equal(message.keywords, keywords)) {
|
|
|
|
if (update)
|
|
|
|
message.keywords = keywords;
|
|
|
|
|
|
|
|
db.message().updateMessage(message);
|
|
|
|
db.message().updateMessage(message);
|
|
|
|
Log.i(Helper.TAG, folder.name + " updated id=" + message.id + " uid=" + message.uid +
|
|
|
|
|
|
|
|
" keywords=" + TextUtils.join(" ", keywords));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return message.id;
|
|
|
|
return message.id;
|
|
|
|