1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-01 04:35:57 +00:00

Label classified messages

This commit is contained in:
M66B 2021-04-28 08:09:45 +02:00
parent 369a6f0a23
commit 214ee5b52b
3 changed files with 6 additions and 4 deletions

View file

@ -1084,7 +1084,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
ivFound.setVisibility(message.ui_found && found ? View.VISIBLE : View.GONE);
ivClassified.setVisibility(message.auto_classified ? View.VISIBLE : View.GONE);
ivClassified.setVisibility(message.auto_classified || message.hasKeyword("$Classified") ? View.VISIBLE : View.GONE);
int snoozy = (message.ui_snoozed != null && message.ui_snoozed == Long.MAX_VALUE
? R.drawable.twotone_visibility_off_24
@ -1100,7 +1100,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibSnoozed.setVisibility(message.ui_snoozed == null && !message.ui_unsnoozed ? View.GONE : View.VISIBLE);
ivAnswered.setVisibility(message.ui_answered ? View.VISIBLE : View.GONE);
ivForwarded.setVisibility(message.isForwarded() ? View.VISIBLE : View.GONE);
ivForwarded.setVisibility(message.hasKeyword("$Forwarded") ? View.VISIBLE : View.GONE);
ivAttachments.setVisibility(message.attachments > 0 ? View.VISIBLE : View.GONE);
if (viewType == ViewType.FOLDER)

View file

@ -282,10 +282,10 @@ public class EntityMessage implements Serializable {
return addresses.toArray(new Address[0]);
}
boolean isForwarded() {
boolean hasKeyword(@NonNull String value) {
if (keywords != null)
for (String keyword : keywords)
if ("$Forwarded".equalsIgnoreCase(keyword))
if (value.equalsIgnoreCase(keyword))
return true;
return false;
}

View file

@ -104,6 +104,7 @@ public class MessageClassifier {
if (classified != null &&
!classified.equals(folder.name) &&
!TextUtils.isEmpty(message.msgid) &&
!message.hasKeyword("$Classified") &&
!accountMsgIds.get(folder.account).contains(message.msgid) &&
!EntityFolder.JUNK.equals(folder.type)) {
boolean pro = ActivityBilling.isPro(context);
@ -115,6 +116,7 @@ public class MessageClassifier {
EntityFolder dest = db.folder().getFolderByName(folder.account, classified);
if (dest != null && dest.auto_classify_target &&
(pro || EntityFolder.JUNK.equals(dest.type))) {
EntityOperation.queue(context, message, EntityOperation.KEYWORD, "$Classified", true);
EntityOperation.queue(context, message, EntityOperation.MOVE, dest.id, false, true);
message.ui_hide = true;
}