From abe4feb1ad32427b27100b7bbc2bbcc7c4fd584c Mon Sep 17 00:00:00 2001 From: Ivan Niedielnitsev <81557788+NiedielnitsevIvan@users.noreply.github.com> Date: Wed, 5 Jun 2024 13:19:54 +0300 Subject: [PATCH] feat: [AXM-571] change texts in the push notifications (#2569) * feat: [AXM-571] change texts in the push notifications * fix: [AXM-571] fix notifications to thread author --- lms/djangoapps/discussion/signals/handlers.py | 1 + lms/djangoapps/discussion/tasks.py | 14 ++++++++++---- .../edx_ace/responsenotification/push/body.txt | 3 +-- .../edx_ace/responsenotification/push/subject.txt | 3 +-- lms/djangoapps/discussion/tests/test_tasks.py | 3 +++ .../instructor/edx_ace/addbetatester/push/body.txt | 2 +- .../edx_ace/addbetatester/push/subject.txt | 2 +- .../instructor/edx_ace/allowedenroll/push/body.txt | 2 +- .../edx_ace/allowedenroll/push/subject.txt | 2 +- .../edx_ace/enrolledunenroll/push/body.txt | 2 +- .../edx_ace/enrollenrolled/push/body.txt | 4 ++-- .../edx_ace/removebetatester/push/body.txt | 2 +- .../edx_ace/removebetatester/push/subject.txt | 2 +- 13 files changed, 25 insertions(+), 17 deletions(-) diff --git a/lms/djangoapps/discussion/signals/handlers.py b/lms/djangoapps/discussion/signals/handlers.py index ead8128a0fe0..bf46b5fbf658 100644 --- a/lms/djangoapps/discussion/signals/handlers.py +++ b/lms/djangoapps/discussion/signals/handlers.py @@ -116,6 +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': 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 23af89888134..23a641fae958 100644 --- a/lms/djangoapps/discussion/tasks.py +++ b/lms/djangoapps/discussion/tasks.py @@ -183,20 +183,24 @@ def _should_send_message(context): cc_thread_author = cc.User(id=context['thread_author_id'], course_id=context['course_id']) return ( _is_user_subscribed_to_thread(cc_thread_author, context['thread_id']) and - _is_not_subcomment(context['comment_id']) + _is_not_subcomment(context['comment_id']) and + not _comment_author_is_thread_author(context) ) def _should_send_subcomment_message(context): cc_thread_author = cc.User(id=context['thread_author_id'], course_id=context['course_id']) - comment_author_is_thread_author = context['comment_author_id'] == context['thread_author_id'] return ( _is_user_subscribed_to_thread(cc_thread_author, context['thread_id']) and _is_subcomment(context['comment_id']) and - not comment_author_is_thread_author + not _comment_author_is_thread_author(context) ) +def _comment_author_is_thread_author(context): + return context.get('comment_author_id', '') == context['thread_author_id'] + + def _is_content_still_reported(context): if context.get('comment_id') is not None: return len(cc.Comment.find(context['comment_id']).abuse_flaggers) > 0 @@ -262,8 +266,10 @@ def _build_message_context(context, notification_type='forum_comment'): # lint- 'comment_username': comment_author.username, 'post_link': post_link, 'push_notification_extra_context': { + 'course_id': str(context['course_id']), + 'parent_id': str(context['comment_parent_id']), 'notification_type': notification_type, - 'topic_id': 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/templates/discussion/edx_ace/responsenotification/push/body.txt b/lms/djangoapps/discussion/templates/discussion/edx_ace/responsenotification/push/body.txt index 145d8344d3a1..c1fe3ba35b7f 100644 --- a/lms/djangoapps/discussion/templates/discussion/edx_ace/responsenotification/push/body.txt +++ b/lms/djangoapps/discussion/templates/discussion/edx_ace/responsenotification/push/body.txt @@ -1,3 +1,2 @@ {% load i18n %} -{% blocktrans trimmed %}{{ comment_username }} replied to {{ thread_title }}:{% endblocktrans %} -{{ comment_body_text }} +{% blocktrans trimmed %}{{ comment_username }} replied to {{ thread_title }}{% endblocktrans %} diff --git a/lms/djangoapps/discussion/templates/discussion/edx_ace/responsenotification/push/subject.txt b/lms/djangoapps/discussion/templates/discussion/edx_ace/responsenotification/push/subject.txt index a49eb5dec1c2..03caca997346 100644 --- a/lms/djangoapps/discussion/templates/discussion/edx_ace/responsenotification/push/subject.txt +++ b/lms/djangoapps/discussion/templates/discussion/edx_ace/responsenotification/push/subject.txt @@ -1,3 +1,2 @@ {% load i18n %} - -{% blocktrans %}Response to {{ thread_title }}{% endblocktrans %} \ No newline at end of file +{% blocktrans %}Response to {{ thread_title }}{% endblocktrans %} 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'], }, diff --git a/lms/templates/instructor/edx_ace/addbetatester/push/body.txt b/lms/templates/instructor/edx_ace/addbetatester/push/body.txt index 6cd170cd5ce1..8373638fb41f 100644 --- a/lms/templates/instructor/edx_ace/addbetatester/push/body.txt +++ b/lms/templates/instructor/edx_ace/addbetatester/push/body.txt @@ -1,5 +1,5 @@ {% load i18n %} {% autoescape off %} -{% blocktrans %}Dear {{ full_name }}{% endblocktrans %} +{% blocktrans %}Dear {{ full_name }},{% endblocktrans %} {% blocktrans %}You have been invited to be a beta tester for {{ course_name }} at {{ site_name }}.{% endblocktrans %} {% endautoescape %} diff --git a/lms/templates/instructor/edx_ace/addbetatester/push/subject.txt b/lms/templates/instructor/edx_ace/addbetatester/push/subject.txt index 973411afd35f..f1c4c6826cfa 100644 --- a/lms/templates/instructor/edx_ace/addbetatester/push/subject.txt +++ b/lms/templates/instructor/edx_ace/addbetatester/push/subject.txt @@ -1,4 +1,4 @@ {% load i18n %} {% autoescape off %} -{% blocktrans %}You have been invited to a beta test for {{ course_name }}{% endblocktrans %} +{% blocktrans %}You have been invited to a beta test for {{ course_name }} at {{ site_name }}.{% endblocktrans %} {% endautoescape %} diff --git a/lms/templates/instructor/edx_ace/allowedenroll/push/body.txt b/lms/templates/instructor/edx_ace/allowedenroll/push/body.txt index fc2e3cce4680..14e4915f86e2 100644 --- a/lms/templates/instructor/edx_ace/allowedenroll/push/body.txt +++ b/lms/templates/instructor/edx_ace/allowedenroll/push/body.txt @@ -1,5 +1,5 @@ {% load i18n %} {% autoescape off %} {% blocktrans %}Dear student,{% endblocktrans %} -{% blocktrans %}You have been invited to join {{ course_name }} at {{ site_name }}.{% endblocktrans %} +{% blocktrans %}You have been enrolled in {{ course_name }} at {{ site_name }}. This course will now appear on your {{ site_name }} dashboard.{% endblocktrans %} {% endautoescape %} diff --git a/lms/templates/instructor/edx_ace/allowedenroll/push/subject.txt b/lms/templates/instructor/edx_ace/allowedenroll/push/subject.txt index 1cbe2a29ab05..865657f1fcb1 100644 --- a/lms/templates/instructor/edx_ace/allowedenroll/push/subject.txt +++ b/lms/templates/instructor/edx_ace/allowedenroll/push/subject.txt @@ -1,4 +1,4 @@ {% load i18n %} {% autoescape off %} -{% blocktrans %}You have been invited to register for {{ course_name }}{% endblocktrans %} +{% blocktrans %}You have been invited to register for {{ course_name }}.{% endblocktrans %} {% endautoescape %} diff --git a/lms/templates/instructor/edx_ace/enrolledunenroll/push/body.txt b/lms/templates/instructor/edx_ace/enrolledunenroll/push/body.txt index ce94b24f6167..2bc61a840b48 100644 --- a/lms/templates/instructor/edx_ace/enrolledunenroll/push/body.txt +++ b/lms/templates/instructor/edx_ace/enrolledunenroll/push/body.txt @@ -1,5 +1,5 @@ {% load i18n %} {% autoescape off %} -{% blocktrans %}Dear {{ full_name }}{% endblocktrans %} +{% blocktrans %}Dear {{ full_name }},{% endblocktrans %} {% blocktrans %}You have been unenrolled from {{ course_name }} at {{ site_name }}. This course will no longer appear on your {{ site_name }} dashboard.{% endblocktrans %} {% endautoescape %} diff --git a/lms/templates/instructor/edx_ace/enrollenrolled/push/body.txt b/lms/templates/instructor/edx_ace/enrollenrolled/push/body.txt index 883f14770512..e5ef12dc5f75 100644 --- a/lms/templates/instructor/edx_ace/enrollenrolled/push/body.txt +++ b/lms/templates/instructor/edx_ace/enrollenrolled/push/body.txt @@ -1,5 +1,5 @@ {% load i18n %} {% autoescape off %} -{% blocktrans %}Dear {{ full_name }}{% endblocktrans %} -{% blocktrans %}You have been enrolled in {{ course_name }} at {{ site_name }}. This course will now appear on your {{ site_name }} dashboard.{% endblocktrans %} +{% blocktrans %}Dear {{ full_name }},{% endblocktrans %} +{% blocktrans %}You have been invited to join {{ course_name }} at {{ site_name }}.{% endblocktrans %} {% endautoescape %} diff --git a/lms/templates/instructor/edx_ace/removebetatester/push/body.txt b/lms/templates/instructor/edx_ace/removebetatester/push/body.txt index 4806be929b83..89573aa4be1d 100644 --- a/lms/templates/instructor/edx_ace/removebetatester/push/body.txt +++ b/lms/templates/instructor/edx_ace/removebetatester/push/body.txt @@ -1,5 +1,5 @@ {% load i18n %} {% autoescape off %} -{% blocktrans %}Dear {{ full_name }}{% endblocktrans %} +{% blocktrans %}Dear {{ full_name }},{% endblocktrans %} {% blocktrans %}You have been removed as a beta tester for {{ course_name }} at {{ site_name }}. This course will remain on your dashboard, but you will no longer be part of the beta testing group.{% endblocktrans %} {% endautoescape %} diff --git a/lms/templates/instructor/edx_ace/removebetatester/push/subject.txt b/lms/templates/instructor/edx_ace/removebetatester/push/subject.txt index 33dee3487f96..c09febbb455c 100644 --- a/lms/templates/instructor/edx_ace/removebetatester/push/subject.txt +++ b/lms/templates/instructor/edx_ace/removebetatester/push/subject.txt @@ -1,4 +1,4 @@ {% load i18n %} {% autoescape off %} -{% blocktrans %}You have been removed from a beta test for {{ course_name }}{% endblocktrans %} +{% blocktrans %}You have been removed as a beta tester for {{ course_name }} at {{ site_name }}.{% endblocktrans %} {% endautoescape %}