Added check for duplicate addresses

This commit is contained in:
M66B
2020-10-01 09:45:59 +02:00
parent 9f1d41ea42
commit 19d5da3280
5 changed files with 31 additions and 1 deletions

View File

@@ -4502,6 +4502,23 @@ public class FragmentCompose extends FragmentBase {
checkAddress(ato, context);
checkAddress(acc, context);
checkAddress(abcc, context);
List<String> all = new ArrayList<>();
List<String> dup = new ArrayList<>();
for (InternetAddress a : Helper.concat(Helper.concat(ato, acc), abcc)) {
String email = a.getAddress();
if (TextUtils.isEmpty(email))
continue;
if (all.contains(a.getAddress()))
dup.add(email);
else
all.add(email);
}
if (dup.size() > 0)
throw new AddressException(context.getString(
R.string.title_address_duplicate,
TextUtils.join(", ", dup)));
} catch (AddressException ex) {
args.putString("address_error", ex.getMessage());
}