mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 12:44:42 +00:00
Plain text: always attach images
This commit is contained in:
parent
c009f1c4bf
commit
50bea656ea
2 changed files with 24 additions and 9 deletions
|
@ -87,6 +87,11 @@ public interface DaoAttachment {
|
|||
" WHERE id = :id")
|
||||
void setError(long id, String error);
|
||||
|
||||
@Query("UPDATE attachment" +
|
||||
" SET disposition = :disposition" +
|
||||
" WHERE id = :id")
|
||||
void setDisposition(long id, String disposition);
|
||||
|
||||
@Query("UPDATE attachment" +
|
||||
" SET cid = :cid" +
|
||||
" WHERE id = :id")
|
||||
|
|
|
@ -4098,20 +4098,30 @@ public class FragmentCompose extends FragmentBase {
|
|||
}
|
||||
|
||||
} else if (action == R.id.action_send) {
|
||||
// Remove unused inline images
|
||||
List<String> cids = new ArrayList<>();
|
||||
if (draft.plain_only == null || !draft.plain_only)
|
||||
for (Element element : JsoupEx.parse(body).select("img")) {
|
||||
if (draft.plain_only == null || !draft.plain_only) {
|
||||
// Remove unused inline images
|
||||
List<String> cids = new ArrayList<>();
|
||||
Document d = JsoupEx.parse(body);
|
||||
for (Element element : d.select("img")) {
|
||||
String src = element.attr("src");
|
||||
if (src.startsWith("cid:"))
|
||||
cids.add("<" + src.substring(4) + ">");
|
||||
}
|
||||
|
||||
for (EntityAttachment attachment : new ArrayList<>(attachments))
|
||||
if (attachment.isInline() && !cids.contains(attachment.cid)) {
|
||||
Log.i("Removing unused inline attachment cid=" + attachment.cid);
|
||||
db.attachment().deleteAttachment(attachment.id);
|
||||
}
|
||||
for (EntityAttachment attachment : new ArrayList<>(attachments))
|
||||
if (attachment.isInline() && !cids.contains(attachment.cid)) {
|
||||
Log.i("Removing unused inline attachment cid=" + attachment.cid);
|
||||
db.attachment().deleteAttachment(attachment.id);
|
||||
}
|
||||
} else {
|
||||
// Convert inline images to attachments
|
||||
for (EntityAttachment attachment : new ArrayList<>(attachments))
|
||||
if (attachment.isInline()) {
|
||||
Log.i("Converting to attachment cid=" + attachment.cid);
|
||||
attachment.disposition = Part.ATTACHMENT;
|
||||
db.attachment().setDisposition(attachment.id, attachment.disposition);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete draft (cannot move to outbox)
|
||||
EntityOperation.queue(context, draft, EntityOperation.DELETE);
|
||||
|
|
Loading…
Reference in a new issue