Skip to content

Commit ffa65ec

Browse files
authored
[ENG-8978] Fix issue with user confirmation/merger creating subscription (#11324)
* Fix issue with user confirmation/merger creating subscription * Add docstrings
1 parent 5e29285 commit ffa65ec

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

framework/auth/views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ def send_confirm_email(user, email, renew=False, external_id_provider=None, exte
847847
# Merge account confirmation
848848
merge_account_data = {
849849
'merge_target_fullname': merge_target.fullname or merge_target.username,
850-
'user_username': user.fullname,
850+
'user_username': user.username,
851851
'email': merge_target.email,
852852
}
853853
notification_type = NotificationType.Type.USER_CONFIRM_MERGE
@@ -862,8 +862,7 @@ def send_confirm_email(user, email, renew=False, external_id_provider=None, exte
862862
notification_type = NotificationType.Type.USER_INITIAL_CONFIRM_EMAIL
863863

864864
notification_type.instance.emit(
865-
user=user,
866-
subscribed_object=user,
865+
destination_address=email,
867866
event_context={
868867
'user_fullname': user.fullname,
869868
'confirmation_url': confirmation_url,
@@ -873,6 +872,7 @@ def send_confirm_email(user, email, renew=False, external_id_provider=None, exte
873872
'osf_support_email': settings.OSF_SUPPORT_EMAIL,
874873
**merge_account_data,
875874
},
875+
save=False
876876
)
877877

878878
def send_confirm_email_async(user, email, renew=False, external_id_provider=None, external_id=None, destination=None):

osf/models/notification_subscription.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ def emit(
7171
destination_address (optional): overides the user's email address for the notification. Good for sending
7272
to a test address or OSF desk support'
7373
email_context (dict, optional): Context for sending the email bcc, reply_to header etc
74+
save (bool, optional): save the notification and creates a subscription object if true, otherwise just
75+
send the notification with no db transaction, therefore message_frequency should always be 'instantly' when
76+
used.
7477
"""
7578
if not settings.CI_ENV:
7679
logging.info(

osf/models/notification_type.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ def emit(
202202
message_frequency (optional): Initializing message frequency.
203203
event_context (dict, optional): Context for rendering the notification template.
204204
email_context (dict, optional): Context for additional email notification information, so as blind cc etc
205+
is_digest (bool, optional): is this email part of a larger digest notification?
206+
save (bool, optional): save the notification and creates a subscription object if true, otherwise just
207+
send the notification with no db transaction, therefore message_frequency should always be 'instantly' when
208+
used.
205209
"""
206210
from osf.models.notification_subscription import NotificationSubscription
207211
if not save:

osf_tests/test_merging_users.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,3 +301,4 @@ def test_send_confirm_email_emits_merge_notification(self):
301301
send_confirm_email(merger, target_email)
302302
assert len(notifications['emits']) == 1
303303
assert notifications['emits'][0]['type'] == NotificationType.Type.USER_CONFIRM_MERGE
304+
assert notifications['emits'][0]['kwargs']['destination_address'] == target_email

0 commit comments

Comments
 (0)