Skip to content

Commit

Permalink
fix: user id in allow enroll email inconsistent (#36300)
Browse files Browse the repository at this point in the history
  • Loading branch information
AhtishamShahid authored Feb 26, 2025
1 parent 3ef635b commit 6d21b97
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lms/djangoapps/instructor/enrollment.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ def enroll_email(
message_params['email_address'] = student_email
if previous_state.user:
message_params['user_id'] = previous_state.user.id
if previous_state.user.email != student_email:
log.error(
'User email does not match the email being enrolled: %s != %s',
previous_state.user.email, student_email
)
send_mail_to_student(student_email, message_params, language=language)

after_state = EmailEnrollmentState(course_id, student_email)
Expand Down Expand Up @@ -566,9 +571,10 @@ def send_mail_to_student(student, param_dict, language=None):

# Extract an LMS user ID for the student, if possible.
# ACE needs the user ID to be able to send email via Braze.
lms_user_id = 0
if 'user_id' in param_dict and param_dict['user_id'] is not None and param_dict['user_id'] > 0:
lms_user_id = param_dict['user_id']
try:
lms_user_id = User.objects.get(email=student).id
except User.DoesNotExist:
lms_user_id = 0

# see if there is an activation email template definition available as configuration,
# if so, then render that
Expand Down

0 comments on commit 6d21b97

Please sign in to comment.