diff --git a/lms/djangoapps/discussion/signals/handlers.py b/lms/djangoapps/discussion/signals/handlers.py index 7512bc87403c..bf46b5fbf658 100644 --- a/lms/djangoapps/discussion/signals/handlers.py +++ b/lms/djangoapps/discussion/signals/handlers.py @@ -116,7 +116,7 @@ def create_message_context(comment, site): 'comment_body_text': comment.body_text, 'comment_author_id': comment.user_id, 'comment_created_at': comment.created_at, # comment_client models dates are already serialized - 'comment_parent_id': getattr(comment, 'parent_id', ''), + 'comment_parent_id': comment.parent_id, 'thread_id': thread.id, 'thread_title': thread.title, 'thread_author_id': thread.user_id, diff --git a/lms/djangoapps/discussion/tasks.py b/lms/djangoapps/discussion/tasks.py index 7b6c88fd6a24..23a641fae958 100644 --- a/lms/djangoapps/discussion/tasks.py +++ b/lms/djangoapps/discussion/tasks.py @@ -198,7 +198,7 @@ def _should_send_subcomment_message(context): def _comment_author_is_thread_author(context): - return context['comment_author_id'] == context['thread_author_id'] + return context.get('comment_author_id', '') == context['thread_author_id'] def _is_content_still_reported(context): @@ -267,9 +267,9 @@ def _build_message_context(context, notification_type='forum_comment'): # lint- 'post_link': post_link, 'push_notification_extra_context': { 'course_id': str(context['course_id']), - 'parent_id': str(context.get('comment_parent_id', '')), + 'parent_id': str(context['comment_parent_id']), 'notification_type': notification_type, - 'topic_id': str(context.get('thread_commentable_id', '')), + 'topic_id': str(context['thread_commentable_id']), 'thread_id': context['thread_id'], 'comment_id': context['comment_id'], }, diff --git a/lms/djangoapps/discussion/tests/test_tasks.py b/lms/djangoapps/discussion/tests/test_tasks.py index be9d2e994b70..f687b3240e6b 100644 --- a/lms/djangoapps/discussion/tests/test_tasks.py +++ b/lms/djangoapps/discussion/tests/test_tasks.py @@ -278,6 +278,7 @@ def test_send_discussion_email_notification(self, user_subscribed): 'comment_body_text': comment.body_text, 'comment_created_at': ONE_HOUR_AGO, 'comment_id': comment['id'], + 'comment_parent_id': comment['parent_id'], 'comment_username': self.comment_author.username, 'course_id': self.course.id, 'thread_author_id': self.thread_author.id, @@ -292,6 +293,8 @@ def test_send_discussion_email_notification(self, user_subscribed): 'push_notification_extra_context': { 'notification_type': 'forum_response', 'topic_id': thread['commentable_id'], + 'course_id': comment['course_id'], + 'parent_id': str(comment['parent_id']), 'thread_id': thread['id'], 'comment_id': comment['id'], },