Added option to filter messages of unknown senders

This commit is contained in:
M66B
2020-02-04 14:22:19 +01:00
parent 9e7c2ddcec
commit 8c2850ffe4
6 changed files with 39 additions and 9 deletions

View File

@@ -41,6 +41,7 @@ public interface DaoMessage {
String is_drafts = "folder.type = '" + EntityFolder.DRAFTS + "'";
String is_outbox = "folder.type = '" + EntityFolder.OUTBOX + "'";
String is_sent = "folder.type = '" + EntityFolder.SENT + "'";
@Query("SELECT message.*" +
", account.pop AS accountProtocol, account.name AS accountName, COALESCE(identity.color, folder.color, account.color) AS accountColor" +
@@ -77,6 +78,7 @@ public interface DaoMessage {
" ELSE SUM(CASE WHEN folder.type = :type THEN 1 ELSE 0 END) > 0 END)" +
" AND (NOT :filter_seen OR SUM(1 - message.ui_seen) > 0)" +
" AND (NOT :filter_unflagged OR COUNT(message.id) - SUM(1 - message.ui_flagged) > 0)" +
" AND (NOT :filter_unknown OR (message.avatar IS NOT NULL AND message.sender <> identity.email))" +
" AND (NOT :filter_snoozed OR message.ui_snoozed IS NULL OR " + is_drafts + ")" +
" ORDER BY -IFNULL(MAX(message.importance), 1)" +
", CASE" +
@@ -96,7 +98,7 @@ public interface DaoMessage {
String type,
boolean threading,
String sort, boolean ascending,
boolean filter_seen, boolean filter_unflagged, boolean filter_snoozed,
boolean filter_seen, boolean filter_unflagged, boolean filter_unknown, boolean filter_snoozed,
boolean found,
boolean debug);
@@ -130,6 +132,8 @@ public interface DaoMessage {
" HAVING SUM(CASE WHEN folder.id = :folder THEN 1 ELSE 0 END) > 0" +
" AND (NOT :filter_seen OR SUM(1 - message.ui_seen) > 0 OR " + is_outbox + ")" +
" AND (NOT :filter_unflagged OR COUNT(message.id) - SUM(1 - message.ui_flagged) > 0 OR " + is_outbox + ")" +
" AND (NOT :filter_unknown OR (message.avatar IS NOT NULL AND message.sender <> identity.email)" +
" OR " + is_outbox + " OR " + is_drafts + " OR " + is_sent + ")" +
" AND (NOT :filter_snoozed OR message.ui_snoozed IS NULL OR " + is_outbox + " OR " + is_drafts + ")" +
" ORDER BY -IFNULL(MAX(message.importance), 1)" +
", CASE" +
@@ -148,7 +152,7 @@ public interface DaoMessage {
DataSource.Factory<Integer, TupleMessageEx> pagedFolder(
long folder, boolean threading,
String sort, boolean ascending,
boolean filter_seen, boolean filter_unflagged, boolean filter_snoozed,
boolean filter_seen, boolean filter_unflagged, boolean filter_unknown, boolean filter_snoozed,
boolean found,
boolean debug);