Skip to content

Commit

Permalink
Merge branch 'master' into certificate_invalidation_view-to-drf
Browse files Browse the repository at this point in the history
  • Loading branch information
awais786 committed Sep 24, 2024
2 parents 79d1e8b + 649bd42 commit be17650
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 21 deletions.
30 changes: 13 additions & 17 deletions lms/djangoapps/bulk_email/signals.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
Signal handlers for the bulk_email app
"""
from django.contrib.auth import get_user_model
from django.dispatch import receiver
from eventtracking import tracker

Expand Down Expand Up @@ -32,29 +31,26 @@ def ace_email_sent_handler(sender, **kwargs):
"""
When an email is sent using ACE, this method will create an event to detect ace email success status
"""
# Fetch the message object from kwargs, defaulting to None if not present
message = kwargs.get('message', None)

user_model = get_user_model()
try:
user_id = user_model.objects.get(email=message.recipient.email_address).id
except user_model.DoesNotExist:
user_id = None
course_email = message.context.get('course_email', None)
course_id = message.context.get('course_id')
# Fetch the message dictionary from kwargs, defaulting to {} if not present
message = kwargs.get('message', {})
recipient = message.get('recipient', {})
message_name = message.get('name', None)
context = message.get('context', {})
email_address = recipient.get('email', None)
user_id = recipient.get('user_id', None)
channel = message.get('channel', None)
course_id = context.get('course_id', None)
if not course_id:
course_email = context.get('course_email', None)
course_id = course_email.course_id if course_email else None
try:
channel = sender.__class__.__name__
except AttributeError:
channel = 'Other'

tracker.emit(
'edx.ace.message_sent',
{
'message_type': message.name,
'message_type': message_name,
'channel': channel,
'course_id': course_id,
'user_id': user_id,
'user_email': message.recipient.email_address,
'user_email': email_address,
}
)
2 changes: 1 addition & 1 deletion requirements/edx/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ drf-yasg==1.21.7
# via
# django-user-tasks
# edx-api-doc-tools
edx-ace==1.11.1
edx-ace==1.11.2
# via -r requirements/edx/kernel.in
edx-api-doc-tools==1.8.0
# via
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ drf-yasg==1.21.7
# -r requirements/edx/testing.txt
# django-user-tasks
# edx-api-doc-tools
edx-ace==1.11.1
edx-ace==1.11.2
# via
# -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ drf-yasg==1.21.7
# -r requirements/edx/base.txt
# django-user-tasks
# edx-api-doc-tools
edx-ace==1.11.1
edx-ace==1.11.2
# via -r requirements/edx/base.txt
edx-api-doc-tools==1.8.0
# via
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ drf-yasg==1.21.7
# -r requirements/edx/base.txt
# django-user-tasks
# edx-api-doc-tools
edx-ace==1.11.1
edx-ace==1.11.2
# via -r requirements/edx/base.txt
edx-api-doc-tools==1.8.0
# via
Expand Down

0 comments on commit be17650

Please sign in to comment.