Added option to block return path

This commit is contained in:
M66B
2022-01-29 13:22:53 +01:00
parent 220eb6dfda
commit 84c94c79db
7 changed files with 112 additions and 18 deletions

View File

@@ -4051,6 +4051,37 @@ public class MessageHelper {
return result.toArray(new InternetAddress[0]);
}
static List<Address> exclusive(Address[] address, Address[] base) {
if (address == null || address.length == 0 ||
base == null || base.length == 0)
return Arrays.asList(address == null ? new Address[0] : address);
// Should dedup
List<Address> result = new ArrayList<>();
for (Address a : address)
if (a instanceof InternetAddress) {
String email = ((InternetAddress) a).getAddress();
if (TextUtils.isEmpty(email))
continue;
boolean found = false;
for (Address b : base)
if (b instanceof InternetAddress) {
String other = ((InternetAddress) b).getAddress();
if (TextUtils.isEmpty(other))
continue;
if (email.equalsIgnoreCase(other)) {
found = true;
break;
}
}
if (!found)
result.add(a);
}
return result;
}
static boolean isRemoved(Throwable ex) {
while (ex != null) {
if (ex instanceof MessageRemovedException ||