Added rule option to reply/forward raw message file

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

@ -62,6 +62,7 @@ import java.util.regex.Pattern;
import javax.mail.Address;
import javax.mail.Header;
import javax.mail.MessagingException;
import javax.mail.Part;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.InternetHeaders;
@ -639,6 +640,7 @@ public class EntityRule {
DB db = DB.getInstance(context);
String to = jargs.optString("to");
boolean resend = jargs.optBoolean("resend");
boolean attached = jargs.optBoolean("attached");
boolean attachments = jargs.optBoolean("attachments");
if (TextUtils.isEmpty(to) &&
@ -667,6 +669,11 @@ public class EntityRule {
EntityOperation.queue(context, message, EntityOperation.HEADERS);
}
if (!resend && attached && !Boolean.TRUE.equals(message.raw)) {
complete = false;
EntityOperation.queue(context, message, EntityOperation.RAW);
}
if (!complete) {
EntityOperation.queue(context, message, EntityOperation.RULE, this.id);
return false;
@ -699,6 +706,7 @@ public class EntityRule {
boolean attachments = jargs.optBoolean("attachments");
String to = jargs.optString("to");
boolean resend = jargs.optBoolean("resend");
boolean attached = jargs.optBoolean("attached");
boolean cc = jargs.optBoolean("cc");
boolean isReply = TextUtils.isEmpty(to);
@ -835,6 +843,22 @@ public class EntityRule {
if (attachments || resend)
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);
// Batch send operations, wait until after commit

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

@ -911,6 +911,15 @@
app:layout_constraintStart_toStartOf="parent"
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
android:id="@+id/cbCc"
android:layout_width="wrap_content"
@ -918,7 +927,7 @@
android:layout_marginTop="12dp"
android:text="@string/title_rule_cc"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbResend" />
app:layout_constraintTop_toBottomOf="@id/cbAttached" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvAnswerRemark"
@ -1093,7 +1102,7 @@
android:id="@+id/grpAnswer"
android:layout_width="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
android:id="@+id/grpTts"

@ -1614,6 +1614,7 @@
<string name="title_rule_original_text">Include original message text</string>
<string name="title_rule_forward_to">Forward to</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_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>

Loading…
Cancel
Save