1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-03-20 02:45:30 +00:00

Improved empty message check

This commit is contained in:
M66B 2020-04-18 09:44:16 +02:00
parent f7dff578af
commit 64885369e2
2 changed files with 16 additions and 7 deletions

View file

@ -2375,9 +2375,6 @@ class Core {
}
}
if (message.total != null && message.total == 0)
reportEmptyMessage(context, state, account, istore);
try {
db.beginTransaction();
@ -2448,8 +2445,7 @@ class Core {
Log.i(folder.name + " inline downloaded message id=" + message.id +
" size=" + message.size + "/" + (body == null ? null : body.length()));
Long size = parts.getBodySize();
if (TextUtils.isEmpty(body) && size != null && size > 0)
if (TextUtils.isEmpty(body) && parts.hasBody())
reportEmptyMessage(context, state, account, istore);
}
}
@ -2796,8 +2792,7 @@ class Core {
Log.i(folder.name + " downloaded message id=" + message.id +
" size=" + message.size + "/" + (body == null ? null : body.length()));
Long size = parts.getBodySize();
if (TextUtils.isEmpty(body) && size != null && size > 0)
if (TextUtils.isEmpty(body) && parts.hasBody())
reportEmptyMessage(context, state, account, istore);
}
}

View file

@ -1458,6 +1458,20 @@ public class MessageHelper {
return (html.size() == 0);
}
boolean hasBody() throws MessagingException {
List<Part> all = new ArrayList<>();
all.addAll(plain);
all.addAll(html);
if (all.size() == 0)
return true;
for (Part p : all)
if (p.getSize() > 0)
return true;
return false;
}
Long getBodySize() throws MessagingException {
Long size = null;