Skip to content

Commit 8e6738b

Browse files
committed
More fixes
1 parent 5177693 commit 8e6738b

File tree

2 files changed

+9
-33
lines changed

2 files changed

+9
-33
lines changed

pgcommitfest/commitfest/models.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -208,27 +208,23 @@ def send_closure_notifications(self):
208208
next_cf_url = "https://commitfest.postgresql.org/"
209209

210210
# Collect unique authors and their patches
211-
# Only include authors who have notify_all_author enabled
212211
authors_patches = {}
213212
for poc in open_pocs:
214213
for author in poc.patch.authors.all():
215-
if not author.email:
216-
continue
217-
try:
218-
if not author.userprofile.notify_all_author:
219-
continue
220-
except UserProfile.DoesNotExist:
221-
continue
222214
if author not in authors_patches:
223215
authors_patches[author] = []
224216
authors_patches[author].append(poc)
225217

226-
# Send email to each author
218+
# Send email to each author who has notifications enabled
227219
for author, patches in authors_patches.items():
228-
# Get user's notification email preference
229-
email = author.email
230-
if author.userprofile.notifyemail:
231-
email = author.userprofile.notifyemail.email
220+
try:
221+
if not author.userprofile.notify_all_author:
222+
continue
223+
notifyemail = author.userprofile.notifyemail
224+
except UserProfile.DoesNotExist:
225+
continue
226+
227+
email = notifyemail.email if notifyemail else author.email
232228

233229
send_template_mail(
234230
settings.NOTIFICATION_FROM,

pgcommitfest/commitfest/tests/test_closure_notifications.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -200,26 +200,6 @@ def test_coauthors_both_receive_notification(alice, bob, in_progress_cf, topic):
200200
assert receivers == {alice.email, bob.email}
201201

202202

203-
def test_no_notification_for_author_without_email(bob, in_progress_cf, topic):
204-
"""Authors without email addresses should be skipped even if opted in."""
205-
UserProfile.objects.create(user=bob, notify_all_author=True)
206-
bob.email = ""
207-
bob.save()
208-
209-
patch = Patch.objects.create(name="Test Patch", topic=topic)
210-
patch.authors.add(bob)
211-
PatchOnCommitFest.objects.create(
212-
patch=patch,
213-
commitfest=in_progress_cf,
214-
enterdate=datetime.now(),
215-
status=PatchOnCommitFest.STATUS_REVIEW,
216-
)
217-
218-
in_progress_cf.send_closure_notifications()
219-
220-
assert QueuedMail.objects.count() == 0
221-
222-
223203
def test_no_notification_for_author_without_notify_all_author(
224204
bob, in_progress_cf, topic
225205
):

0 commit comments

Comments
 (0)