Allow no template when forwarding

This commit is contained in:
M66B
2021-04-01 18:35:52 +02:00
parent 7e41786536
commit c2de70e91d
2 changed files with 30 additions and 10 deletions

View File

@@ -405,11 +405,15 @@ public class EntityRule {
throw new IllegalArgumentException("Identity not found");
long aid = jargs.optLong("answer", -1);
if (aid < 0)
throw new IllegalArgumentException(context.getString(R.string.title_rule_answer_missing));
EntityAnswer answer = db.answer().getAnswer(aid);
if (answer == null)
throw new IllegalArgumentException("Answer not found");
if (aid < 0) {
String to = jargs.optString("to");
if (TextUtils.isEmpty(to))
throw new IllegalArgumentException(context.getString(R.string.title_rule_answer_missing));
} else {
EntityAnswer answer = db.answer().getAnswer(aid);
if (answer == null)
throw new IllegalArgumentException("Template not found");
}
return;
case TYPE_TTS:
return;
@@ -541,9 +545,18 @@ public class EntityRule {
if (identity == null)
throw new IllegalArgumentException("Rule identity not found name=" + rule.name);
EntityAnswer answer = db.answer().getAnswer(aid);
if (answer == null)
throw new IllegalArgumentException("Rule answer not found name=" + rule.name);
EntityAnswer answer;
if (aid < 0) {
if (TextUtils.isEmpty(to))
throw new IllegalArgumentException("Rule template missing name=" + rule.name);
answer = new EntityAnswer();
answer.text = "";
} else {
answer = db.answer().getAnswer(aid);
if (answer == null)
throw new IllegalArgumentException("Rule template not found name=" + rule.name);
}
EntityFolder outbox = db.folder().getOutbox();
if (outbox == null) {