|
34 | 34 | from api.nodes.serializers import NodeSerializer, RegionRelationshipField |
35 | 35 | from framework.auth.views import send_confirm_email_async |
36 | 36 | from osf.exceptions import ValidationValueError, ValidationError, BlockedEmailError |
37 | | -from osf.models import Email, Node, OSFUser, Preprint, Registration, UserMessage, Institution |
| 37 | +from osf.models import Email, Node, OSFUser, Preprint, Registration, UserMessage, Institution, NotificationType |
38 | 38 | from osf.models.user_message import MessageTypes |
39 | 39 | from osf.models.provider import AbstractProviderGroupObjectPermission |
40 | 40 | from osf.utils.requests import string_type_request_headers |
@@ -711,6 +711,17 @@ def update(self, instance, validated_data): |
711 | 711 | if primary and instance.confirmed: |
712 | 712 | user.username = instance.address |
713 | 713 | user.save() |
| 714 | + notification_type = NotificationType.Type.USER_PRIMARY_EMAIL_CHANGED |
| 715 | + notification_type.instance.emit( |
| 716 | + subscribed_object=user, |
| 717 | + user=user, |
| 718 | + event_context={ |
| 719 | + 'user_fullname': user.fullname, |
| 720 | + 'new_address': user.username, |
| 721 | + 'can_change_preferences': False, |
| 722 | + 'osf_contact_email': settings.OSF_CONTACT_EMAIL, |
| 723 | + } |
| 724 | + ) |
714 | 725 | elif primary and not instance.confirmed: |
715 | 726 | raise exceptions.ValidationError('You cannot set an unconfirmed email address as your primary email address.') |
716 | 727 |
|
|
0 commit comments