Skip to content

Commit a25d90d

Browse files
committed
Notification recipients as a distinct list
1 parent 1faad31 commit a25d90d

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

api/management/commands/index_and_notify.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,13 @@ def notify(self, records, rtype, stype, uid=None):
810810
& Q(is_active=True)
811811
& (~Q(groups__name="IFRC Admins") & ~Q(is_superuser=True))
812812
)
813-
non_ifrc_recipients = list(User.objects.filter(non_ifrc_filters).values_list("email", flat=True))
813+
non_ifrc_recipients = list(
814+
User.objects.filter(non_ifrc_filters)
815+
.exclude(email__isnull=True)
816+
.exclude(email="")
817+
.values_list("email", flat=True)
818+
.distinct()
819+
)
814820

815821
# FIXME: Code duplication but this whole thing would need a huge refactor
816822
# (almost the same as above and in the 'else' part)
@@ -839,8 +845,13 @@ def notify(self, records, rtype, stype, uid=None):
839845
& Q(is_active=True)
840846
& (Q(groups__name="IFRC Admins") | Q(is_superuser=True))
841847
)
842-
ifrc_emails = list(User.objects.filter(ifrc_filters).values_list("email", flat=True))
843-
ifrc_recipients = ifrc_emails
848+
ifrc_recipients = list(
849+
User.objects.filter(ifrc_filters)
850+
.exclude(email__isnull=True)
851+
.exclude(email="")
852+
.values_list("email", flat=True)
853+
.distinct()
854+
)
844855

845856
# FIXME: Code duplication but this whole thing would need a huge refactor
846857
# (almost the same as above and in the 'else' part)

0 commit comments

Comments
 (0)