Remove duplicates from identity store before email notifications
I use LDAP for user store. I have set up "mail" and "otherMailbox" as threepid email attributes. When people get invited to rooms, they receive 2 (sometimes 3) invitation e-mails if they have the same e-mail address in LDAP "mail" and "otherMailbox" fields. I think it's a good idea to check identity store for duplicates before sending invitation e-mails.
This commit is contained in:
@@ -144,7 +144,13 @@ public class MembershipEventProcessor implements EventTypeProcessor {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
log.info("Found {} email(s) in identity store for {}", tpids.size(), inviteeId);
|
log.info("Found {} email(s) in identity store for {}", tpids.size(), inviteeId);
|
||||||
|
|
||||||
for (_ThreePid tpid : tpids) {
|
log.info("Removing duplicates from identity store");
|
||||||
|
List<_ThreePid> uniqueTpids = tpids.stream()
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
log.info("There are {} unique email(s) in identity store for {}", uniqueTpids.size(), inviteeId);
|
||||||
|
|
||||||
|
for (_ThreePid tpid : uniqueTpids) {
|
||||||
log.info("Found Email to notify about room invitation: {}", tpid.getAddress());
|
log.info("Found Email to notify about room invitation: {}", tpid.getAddress());
|
||||||
Map<String, String> properties = new HashMap<>();
|
Map<String, String> properties = new HashMap<>();
|
||||||
profiler.getDisplayName(sender).ifPresent(name -> properties.put("sender_display_name", name));
|
profiler.getDisplayName(sender).ifPresent(name -> properties.put("sender_display_name", name));
|
||||||
|
Reference in New Issue
Block a user