|
|
@ -157,38 +157,41 @@ public class EntityRule {
|
|
|
|
boolean known = jsender.optBoolean("known");
|
|
|
|
boolean known = jsender.optBoolean("known");
|
|
|
|
|
|
|
|
|
|
|
|
boolean matches = false;
|
|
|
|
boolean matches = false;
|
|
|
|
if (message.from != null) {
|
|
|
|
List<Address> senders = new ArrayList<>();
|
|
|
|
for (Address from : message.from) {
|
|
|
|
if (message.from != null)
|
|
|
|
InternetAddress ia = (InternetAddress) from;
|
|
|
|
senders.addAll(Arrays.asList(message.from));
|
|
|
|
String email = ia.getAddress();
|
|
|
|
if (message.reply != null)
|
|
|
|
String personal = ia.getPersonal();
|
|
|
|
senders.addAll(Arrays.asList(message.reply));
|
|
|
|
|
|
|
|
for (Address sender : senders) {
|
|
|
|
if (known) {
|
|
|
|
InternetAddress ia = (InternetAddress) sender;
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
String email = ia.getAddress();
|
|
|
|
boolean suggest_sent = prefs.getBoolean("suggest_sent", true);
|
|
|
|
String personal = ia.getPersonal();
|
|
|
|
if (suggest_sent) {
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
|
|
|
EntityContact contact =
|
|
|
|
|
|
|
|
db.contact().getContact(message.account, EntityContact.TYPE_TO, email);
|
|
|
|
|
|
|
|
if (contact != null) {
|
|
|
|
|
|
|
|
Log.i(email + " is local contact");
|
|
|
|
|
|
|
|
matches = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(message.avatar)) {
|
|
|
|
if (known) {
|
|
|
|
Log.i(email + " is Android contact");
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
matches = true;
|
|
|
|
boolean suggest_sent = prefs.getBoolean("suggest_sent", true);
|
|
|
|
break;
|
|
|
|
if (suggest_sent) {
|
|
|
|
}
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
} else {
|
|
|
|
EntityContact contact =
|
|
|
|
String formatted = ((personal == null ? "" : personal + " ") + "<" + email + ">");
|
|
|
|
db.contact().getContact(message.account, EntityContact.TYPE_TO, email);
|
|
|
|
if (matches(context, message, value, formatted, regex)) {
|
|
|
|
if (contact != null) {
|
|
|
|
|
|
|
|
Log.i(email + " is local contact");
|
|
|
|
matches = true;
|
|
|
|
matches = true;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(message.avatar)) {
|
|
|
|
|
|
|
|
Log.i(email + " is Android contact");
|
|
|
|
|
|
|
|
matches = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
String formatted = ((personal == null ? "" : personal + " ") + "<" + email + ">");
|
|
|
|
|
|
|
|
if (matches(context, message, value, formatted, regex)) {
|
|
|
|
|
|
|
|
matches = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!matches)
|
|
|
|
if (!matches)
|
|
|
|