mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-29 11:15:51 +00:00
Prevent answer loop
This commit is contained in:
parent
ad387e133f
commit
7234c33818
3 changed files with 28 additions and 3 deletions
|
@ -396,6 +396,19 @@ public class EntityRule {
|
|||
if (answer == null)
|
||||
throw new IllegalArgumentException("Rule answer not found");
|
||||
|
||||
Address[] from = new InternetAddress[]{new InternetAddress(identity.email, identity.name)};
|
||||
|
||||
// Prevent loop
|
||||
List<EntityMessage> messages = db.message().getMessagesByThread(
|
||||
message.account, message.thread, null, message.folder);
|
||||
for (EntityMessage threaded : messages)
|
||||
if (!threaded.id.equals(message.id) &&
|
||||
MessageHelper.equal(threaded.from, from)) {
|
||||
EntityLog.log(context, "Answer loop" +
|
||||
" name=" + answer.name +
|
||||
" from=" + MessageHelper.formatAddresses(from));
|
||||
return false;
|
||||
}
|
||||
|
||||
EntityMessage reply = new EntityMessage();
|
||||
reply.account = message.account;
|
||||
|
@ -406,7 +419,7 @@ public class EntityRule {
|
|||
reply.inreplyto = message.msgid;
|
||||
reply.thread = message.thread;
|
||||
reply.to = (message.reply == null || message.reply.length == 0 ? message.from : message.reply);
|
||||
reply.from = new InternetAddress[]{new InternetAddress(identity.email, identity.name)};
|
||||
reply.from = from;
|
||||
if (cc)
|
||||
reply.cc = message.cc;
|
||||
reply.unsubscribe = "mailto:" + identity.email;
|
||||
|
|
|
@ -656,6 +656,17 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/spAnswer" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvAnswerRemark"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_rule_answer_remark"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="italic"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbCc" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvAutomation"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -664,7 +675,7 @@
|
|||
android:text="@string/title_rule_automation_hint"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cbCc" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvAnswerRemark" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpReady"
|
||||
|
@ -720,7 +731,7 @@
|
|||
android:id="@+id/grpAnswer"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="tvAnswerIdentity,spIdent,tvAnswerTemplate,spAnswer,cbCc" />
|
||||
app:constraint_referenced_ids="tvAnswerIdentity,spIdent,tvAnswerTemplate,spAnswer,cbCc,tvAnswerRemark" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpAutomation"
|
||||
|
|
|
@ -1038,6 +1038,7 @@
|
|||
<string name="title_rule_identity">Identity</string>
|
||||
<string name="title_rule_template">Reply template</string>
|
||||
<string name="title_rule_cc">Reply to CC addresses</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_name_missing">Rule name missing</string>
|
||||
<string name="title_rule_condition_missing">Condition missing</string>
|
||||
<string name="title_rule_automation_hint">This will send the intent \'%1$s\' with the extras \'%2$s\'</string>
|
||||
|
|
Loading…
Reference in a new issue