Added message age rule condition

This commit is contained in:
M66B
2022-12-23 16:06:40 +01:00
parent 49c5167e10
commit d718c7a6a6
5 changed files with 76 additions and 7 deletions

View File

@@ -158,6 +158,21 @@ public class EntityRule {
try {
JSONObject jcondition = new JSONObject(condition);
// general
if (this.daily) {
JSONObject jgeneral = jcondition.optJSONObject("general");
if (jgeneral != null) {
int age = jgeneral.optInt("age");
if (age > 0) {
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(message.received);
cal.add(Calendar.DAY_OF_MONTH, age);
if (cal.getTimeInMillis() > new Date().getTime())
return false;
}
}
}
// Sender
JSONObject jsender = jcondition.optJSONObject("sender");
if (jsender != null) {