feat: added new_question_post and new_discussion_post notification (#33043)

This commit is contained in:
Muhammad Adeel Tajamul
2023-08-31 14:29:21 +05:00
committed by GitHub
parent 9db024c435
commit 4efd54a3fd
10 changed files with 424 additions and 16 deletions

View File

@@ -13,7 +13,6 @@ COURSE_NOTIFICATION_TYPES = {
'notification_app': 'discussion',
'name': 'new_comment_on_response',
'is_core': True,
'info': 'Comment on response',
'content_template': _('<{p}><{strong}>{replier_name}</{strong}> commented on your response to the post '
'<{strong}>{post_title}</{strong}></{p}>'),
'content_context': {
@@ -26,8 +25,6 @@ COURSE_NOTIFICATION_TYPES = {
'notification_app': 'discussion',
'name': 'new_comment',
'is_core': True,
'info': 'Comment on post',
'non_editable': ['web', 'email'],
'content_template': _('<{p}><{strong}>{replier_name}</{strong}> commented on <{strong}>{author_name}\'s'
'</{strong}> response to your post <{strong}>{post_title}</{strong}></{p}>'),
'content_context': {
@@ -41,8 +38,6 @@ COURSE_NOTIFICATION_TYPES = {
'notification_app': 'discussion',
'name': 'new_response',
'is_core': True,
'info': 'Response on post',
'non_editable': [],
'content_template': _('<{p}><{strong}>{replier_name}</{strong}> responded to your '
'post <{strong}>{post_title}</{strong}></{p}>'),
'content_context': {
@@ -51,6 +46,38 @@ COURSE_NOTIFICATION_TYPES = {
},
'email_template': '',
},
'new_discussion_post': {
'notification_app': 'discussion',
'name': 'new_discussion_post',
'is_core': False,
'info': '',
'web': False,
'email': False,
'push': False,
'non_editable': [],
'content_template': _('<{p}><{strong}>{username}</{strong}> posted <{strong}>{post_title}</{strong}></{p}>'),
'content_context': {
'post_title': 'Post title',
'username': 'Post author name',
},
'email_template': '',
},
'new_question_post': {
'notification_app': 'discussion',
'name': 'new_question_post',
'is_core': False,
'info': '',
'web': False,
'email': False,
'push': False,
'non_editable': [],
'content_template': _('<{p}><{strong}>{username}</{strong}> asked <{strong}>{post_title}</{strong}></{p}>'),
'content_context': {
'post_title': 'Post title',
'username': 'Post author name',
},
'email_template': '',
}
}
COURSE_NOTIFICATION_APPS = {

View File

@@ -21,7 +21,7 @@ log = logging.getLogger(__name__)
NOTIFICATION_CHANNELS = ['web', 'push', 'email']
# Update this version when there is a change to any course specific notification type or app.
COURSE_NOTIFICATION_CONFIG_VERSION = 2
COURSE_NOTIFICATION_CONFIG_VERSION = 3
def get_course_notification_preference_config():

View File

@@ -276,7 +276,7 @@ class NotificationPreferenceValidationTest(ModuleStoreTestCase):
Tests if COURSE_NOTIFICATION_TYPES constant has all required keys with valid
data type for core notification type
"""
str_keys = ['notification_app', 'name', 'info', 'email_template']
str_keys = ['notification_app', 'name', 'email_template']
notification_types = base_notification.COURSE_NOTIFICATION_TYPES
assert "" not in notification_types.keys()
for notification_type in notification_types.values():

View File

@@ -224,7 +224,9 @@ class UserNotificationPreferenceAPITest(ModuleStoreTestCase):
'email': True,
'push': True,
'info': ''
}
},
'new_discussion_post': {'web': False, 'email': False, 'push': False, 'info': ''},
'new_question_post': {'web': False, 'email': False, 'push': False, 'info': ''}
},
'non_editable': {
'core': ['web']