Added rule option to reply/forward raw message file

pull/207/head
M66B 3 years ago
parent 4f31e65cf0
commit 8b946b6df1

@ -62,6 +62,7 @@ import java.util.regex.Pattern;
import javax.mail.Address; import javax.mail.Address;
import javax.mail.Header; import javax.mail.Header;
import javax.mail.MessagingException; import javax.mail.MessagingException;
import javax.mail.Part;
import javax.mail.internet.AddressException; import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress; import javax.mail.internet.InternetAddress;
import javax.mail.internet.InternetHeaders; import javax.mail.internet.InternetHeaders;
@ -639,6 +640,7 @@ public class EntityRule {
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
String to = jargs.optString("to"); String to = jargs.optString("to");
boolean resend = jargs.optBoolean("resend"); boolean resend = jargs.optBoolean("resend");
boolean attached = jargs.optBoolean("attached");
boolean attachments = jargs.optBoolean("attachments"); boolean attachments = jargs.optBoolean("attachments");
if (TextUtils.isEmpty(to) && if (TextUtils.isEmpty(to) &&
@ -667,6 +669,11 @@ public class EntityRule {
EntityOperation.queue(context, message, EntityOperation.HEADERS); EntityOperation.queue(context, message, EntityOperation.HEADERS);
} }
if (!resend && attached && !Boolean.TRUE.equals(message.raw)) {
complete = false;
EntityOperation.queue(context, message, EntityOperation.RAW);
}
if (!complete) { if (!complete) {
EntityOperation.queue(context, message, EntityOperation.RULE, this.id); EntityOperation.queue(context, message, EntityOperation.RULE, this.id);
return false; return false;
@ -699,6 +706,7 @@ public class EntityRule {
boolean attachments = jargs.optBoolean("attachments"); boolean attachments = jargs.optBoolean("attachments");
String to = jargs.optString("to"); String to = jargs.optString("to");
boolean resend = jargs.optBoolean("resend"); boolean resend = jargs.optBoolean("resend");
boolean attached = jargs.optBoolean("attached");
boolean cc = jargs.optBoolean("cc"); boolean cc = jargs.optBoolean("cc");
boolean isReply = TextUtils.isEmpty(to); boolean isReply = TextUtils.isEmpty(to);
@ -835,6 +843,22 @@ public class EntityRule {
if (attachments || resend) if (attachments || resend)
EntityAttachment.copy(context, message.id, reply.id); EntityAttachment.copy(context, message.id, reply.id);
if (!resend && attached) {
EntityAttachment attachment = new EntityAttachment();
attachment.message = reply.id;
attachment.sequence = 1;
attachment.name = "email.eml";
attachment.type = "message/rfc822";
attachment.disposition = Part.ATTACHMENT;
attachment.progress = 0;
attachment.id = db.attachment().insertAttachment(attachment);
File source = message.getRawFile(context);
File target = attachment.getFile(context);
Helper.copy(source, target);
db.attachment().setDownloaded(attachment.id, target.length());
}
EntityOperation.queue(context, reply, EntityOperation.SEND); EntityOperation.queue(context, reply, EntityOperation.SEND);
// Batch send operations, wait until after commit // Batch send operations, wait until after commit

@ -148,6 +148,7 @@ public class FragmentRule extends FragmentBase {
private EditText etTo; private EditText etTo;
private ImageButton ibTo; private ImageButton ibTo;
private CheckBox cbResend; private CheckBox cbResend;
private CheckBox cbAttached;
private CheckBox cbCc; private CheckBox cbCc;
private Button btnTtsSetup; private Button btnTtsSetup;
@ -301,6 +302,7 @@ public class FragmentRule extends FragmentBase {
etTo = view.findViewById(R.id.etTo); etTo = view.findViewById(R.id.etTo);
ibTo = view.findViewById(R.id.ibTo); ibTo = view.findViewById(R.id.ibTo);
cbResend = view.findViewById(R.id.cbResend); cbResend = view.findViewById(R.id.cbResend);
cbAttached = view.findViewById(R.id.cbAttached);
cbCc = view.findViewById(R.id.cbCc); cbCc = view.findViewById(R.id.cbCc);
btnTtsSetup = view.findViewById(R.id.btnTtsSetup); btnTtsSetup = view.findViewById(R.id.btnTtsSetup);
@ -652,6 +654,7 @@ public class FragmentRule extends FragmentBase {
cbAnswerSubject.setEnabled(!checked); cbAnswerSubject.setEnabled(!checked);
cbOriginalText.setEnabled(!checked); cbOriginalText.setEnabled(!checked);
cbWithAttachments.setEnabled(!checked); cbWithAttachments.setEnabled(!checked);
cbAttached.setEnabled(false);
} }
}); });
@ -1177,6 +1180,7 @@ public class FragmentRule extends FragmentBase {
etTo.setText(jaction.optString("to")); etTo.setText(jaction.optString("to"));
cbResend.setChecked(jaction.optBoolean("resend")); cbResend.setChecked(jaction.optBoolean("resend"));
cbAttached.setChecked(jaction.optBoolean("attached"));
cbCc.setChecked(jaction.optBoolean("cc")); cbCc.setChecked(jaction.optBoolean("cc"));
break; break;
@ -1520,6 +1524,7 @@ public class FragmentRule extends FragmentBase {
jaction.put("attachments", cbWithAttachments.isChecked()); jaction.put("attachments", cbWithAttachments.isChecked());
jaction.put("to", etTo.getText().toString().trim()); jaction.put("to", etTo.getText().toString().trim());
jaction.put("resend", cbResend.isChecked()); jaction.put("resend", cbResend.isChecked());
jaction.put("attached", cbAttached.isChecked());
jaction.put("cc", cbCc.isChecked()); jaction.put("cc", cbCc.isChecked());
break; break;

@ -911,6 +911,15 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etTo" /> app:layout_constraintTop_toBottomOf="@id/etTo" />
<CheckBox
android:id="@+id/cbAttached"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_rule_attached"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbResend" />
<CheckBox <CheckBox
android:id="@+id/cbCc" android:id="@+id/cbCc"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -918,7 +927,7 @@
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_rule_cc" android:text="@string/title_rule_cc"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbResend" /> app:layout_constraintTop_toBottomOf="@id/cbAttached" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView
android:id="@+id/tvAnswerRemark" android:id="@+id/tvAnswerRemark"
@ -1093,7 +1102,7 @@
android:id="@+id/grpAnswer" android:id="@+id/grpAnswer"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
app:constraint_referenced_ids="tvAnswerIdentity,spIdent,tvAnswerTemplate,spAnswer,cbAnswerSubject,cbOriginalText,cbWithAttachments,tvTo,etTo,ibTo,cbResend,cbCc,tvAnswerRemark" /> app:constraint_referenced_ids="tvAnswerIdentity,spIdent,tvAnswerTemplate,spAnswer,cbAnswerSubject,cbOriginalText,cbWithAttachments,tvTo,etTo,ibTo,cbResend,cbAttached,cbCc,tvAnswerRemark" />
<androidx.constraintlayout.widget.Group <androidx.constraintlayout.widget.Group
android:id="@+id/grpTts" android:id="@+id/grpTts"

@ -1614,6 +1614,7 @@
<string name="title_rule_original_text">Include original message text</string> <string name="title_rule_original_text">Include original message text</string>
<string name="title_rule_forward_to">Forward to</string> <string name="title_rule_forward_to">Forward to</string>
<string name="title_rule_resend">Resend</string> <string name="title_rule_resend">Resend</string>
<string name="title_rule_attached">Attach raw message file</string>
<string name="title_rule_cc">Reply to CC addresses</string> <string name="title_rule_cc">Reply to CC addresses</string>
<string name="title_rule_with_attachments">With attachments</string> <string name="title_rule_with_attachments">With attachments</string>
<string name="title_rule_answer_remark">Only one reply will be sent for any conversation, to avoid reply loops</string> <string name="title_rule_answer_remark">Only one reply will be sent for any conversation, to avoid reply loops</string>

Loading…
Cancel
Save