|
|
|
@ -567,7 +567,7 @@ public class EntityRule {
|
|
|
|
|
jcondition.put("sender", jsender);
|
|
|
|
|
|
|
|
|
|
JSONObject jaction = new JSONObject();
|
|
|
|
|
jaction.put("type", EntityRule.TYPE_MOVE);
|
|
|
|
|
jaction.put("type", TYPE_MOVE);
|
|
|
|
|
jaction.put("target", junk.id);
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
@ -584,6 +584,34 @@ public class EntityRule {
|
|
|
|
|
return rule;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boolean isBlockingSender(EntityMessage message, EntityFolder junk) throws JSONException {
|
|
|
|
|
if (message.from == null || message.from.length == 0)
|
|
|
|
|
return false;
|
|
|
|
|
String sender = ((InternetAddress) message.from[0]).getAddress();
|
|
|
|
|
if (sender == null)
|
|
|
|
|
return false;
|
|
|
|
|
int at = sender.indexOf('@');
|
|
|
|
|
String domain = (at < 0 ? sender : sender.substring(at));
|
|
|
|
|
|
|
|
|
|
JSONObject jcondition = new JSONObject(condition);
|
|
|
|
|
if (!jcondition.has("sender"))
|
|
|
|
|
return false;
|
|
|
|
|
JSONObject jsender = jcondition.getJSONObject("sender");
|
|
|
|
|
if (jsender.optBoolean("regex"))
|
|
|
|
|
return false;
|
|
|
|
|
String value = jsender.optString("value");
|
|
|
|
|
if (!sender.equals(value) && !domain.equals(value))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
JSONObject jaction = new JSONObject(action);
|
|
|
|
|
if (jaction.optInt("type", -1) != TYPE_MOVE)
|
|
|
|
|
return false;
|
|
|
|
|
if (jaction.optInt("target", -1) != junk.id)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
|
if (obj instanceof EntityRule) {
|
|
|
|
|