Skip to content

Commit 0092458

Browse files
chore: enable notification feature by default (#38073)
1 parent ea2f60b commit 0092458

13 files changed

Lines changed: 157 additions & 311 deletions

File tree

cms/djangoapps/contentstore/tests/test_utils.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from django.conf import settings
1010
from django.test import TestCase
1111
from django.test.utils import override_settings
12-
from edx_toggles.toggles.testutils import override_waffle_flag
1312
from opaque_keys.edx.keys import CourseKey
1413
from opaque_keys.edx.locator import CourseLocator, LibraryLocator
1514
from openedx_events.tests.utils import OpenEdxEventsTestMixin
@@ -24,7 +23,6 @@
2423
from cms.djangoapps.contentstore.utils import send_course_update_notification
2524
from common.djangoapps.student.models import CourseEnrollment
2625
from common.djangoapps.student.tests.factories import GlobalStaffFactory, InstructorFactory, UserFactory
27-
from openedx.core.djangoapps.notifications.config.waffle import ENABLE_NOTIFICATIONS
2826
from openedx.core.djangoapps.notifications.models import Notification
2927
from openedx.core.djangoapps.site_configuration.tests.test_util import with_site_configuration_context
3028
from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order
@@ -938,7 +936,6 @@ def test_update_course_details_instructor_paced(self, mock_update):
938936
mock_update.assert_called_once_with(self.course.id, payload, mock_request.user)
939937

940938

941-
@override_waffle_flag(ENABLE_NOTIFICATIONS, active=True)
942939
class CourseUpdateNotificationTests(OpenEdxEventsTestMixin, ModuleStoreTestCase):
943940
"""
944941
Unit tests for the course_update notification.

lms/djangoapps/discussion/rest_api/tasks.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from lms.djangoapps.discussion.rest_api.utils import can_user_notify_all_learners
1818
from openedx.core.djangoapps.django_comment_common.comment_client import Comment
1919
from openedx.core.djangoapps.django_comment_common.comment_client.thread import Thread
20-
from openedx.core.djangoapps.notifications.config.waffle import ENABLE_NOTIFICATIONS
20+
from openedx.core.djangoapps.notifications.config.waffle import DISABLE_NOTIFICATIONS
2121

2222

2323
User = get_user_model()
@@ -31,7 +31,7 @@ def send_thread_created_notification(thread_id, course_key_str, user_id, notify_
3131
Send notification when a new thread is created
3232
"""
3333
course_key = CourseKey.from_string(course_key_str)
34-
if not ENABLE_NOTIFICATIONS.is_enabled():
34+
if DISABLE_NOTIFICATIONS.is_enabled():
3535
return
3636
thread = Thread(id=thread_id).retrieve()
3737
user = User.objects.get(id=user_id)
@@ -55,7 +55,7 @@ def send_response_notifications(thread_id, course_key_str, user_id, comment_id,
5555
Send notifications to users who are subscribed to the thread.
5656
"""
5757
course_key = CourseKey.from_string(course_key_str)
58-
if not ENABLE_NOTIFICATIONS.is_enabled():
58+
if DISABLE_NOTIFICATIONS.is_enabled():
5959
return
6060
thread = Thread(id=thread_id).retrieve()
6161
user = User.objects.get(id=user_id)
@@ -74,7 +74,7 @@ def send_response_endorsed_notifications(thread_id, response_id, course_key_str,
7474
Send notifications when a response is marked answered/ endorsed
7575
"""
7676
course_key = CourseKey.from_string(course_key_str)
77-
if not ENABLE_NOTIFICATIONS.is_enabled():
77+
if DISABLE_NOTIFICATIONS.is_enabled():
7878
return
7979
thread = Thread(id=thread_id).retrieve()
8080
response = Comment(id=response_id).retrieve()

lms/djangoapps/discussion/rest_api/tests/test_tasks_v2.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import ddt
88
import httpretty
99
from django.conf import settings
10-
from edx_toggles.toggles.testutils import override_waffle_flag
1110
from openedx_events.learning.signals import COURSE_NOTIFICATION_REQUESTED, USER_NOTIFICATION_REQUESTED
1211

1312
from common.djangoapps.student.models import CourseEnrollment
@@ -29,7 +28,6 @@
2928
FORUM_ROLE_STUDENT,
3029
CourseDiscussionSettings
3130
)
32-
from openedx.core.djangoapps.notifications.config.waffle import ENABLE_NOTIFICATIONS
3331
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
3432
from xmodule.modulestore.tests.factories import CourseFactory
3533

@@ -45,7 +43,6 @@ def _get_mfe_url(course_id, post_id):
4543

4644

4745
@ddt.ddt
48-
@override_waffle_flag(ENABLE_NOTIFICATIONS, active=True)
4946
class TestSendResponseNotifications(DiscussionAPIViewTestMixin, ModuleStoreTestCase):
5047
"""
5148
Test for the send_response_notifications function
@@ -404,7 +401,6 @@ def _register_subscriptions_endpoint(self):
404401

405402

406403
@ddt.ddt
407-
@override_waffle_flag(ENABLE_NOTIFICATIONS, active=True)
408404
class TestSendCommentNotification(DiscussionAPIViewTestMixin, ModuleStoreTestCase):
409405
"""
410406
Test case to send new_comment notification
@@ -497,7 +493,6 @@ def test_new_comment_notification(self, is_subscribed):
497493
@ddt.ddt
498494
@httpretty.activate
499495
@mock.patch.dict("django.conf.settings.FEATURES", {"ENABLE_DISCUSSION_SERVICE": True})
500-
@override_waffle_flag(ENABLE_NOTIFICATIONS, active=True)
501496
class TestNewThreadCreatedNotification(DiscussionAPIViewTestMixin, ModuleStoreTestCase):
502497
"""
503498
Test cases related to new_discussion_post and new_question_post notification types
@@ -690,7 +685,6 @@ def test_notification_is_send_to_cohort_ids(self, cohort_text, notification_type
690685
self.assertEqual(handler.call_count, 1)
691686

692687

693-
@override_waffle_flag(ENABLE_NOTIFICATIONS, active=True)
694688
class TestResponseEndorsedNotifications(DiscussionAPIViewTestMixin, ModuleStoreTestCase):
695689
"""
696690
Test case to send response endorsed notifications

openedx/core/djangoapps/enrollments/tests/test_views.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from django.test import Client
2121
from django.test.utils import override_settings
2222
from django.urls import reverse
23-
from edx_toggles.toggles.testutils import override_waffle_flag
2423
from freezegun import freeze_time
2524
from rest_framework import status
2625
from rest_framework.test import APITestCase
@@ -39,7 +38,6 @@
3938
from openedx.core.djangoapps.enrollments import api, data
4039
from openedx.core.djangoapps.enrollments.errors import CourseEnrollmentError
4140
from openedx.core.djangoapps.enrollments.views import EnrollmentUserThrottle
42-
from openedx.core.djangoapps.notifications.config.waffle import ENABLE_NOTIFICATIONS
4341
from openedx.core.djangoapps.oauth_dispatch.jwt import create_jwt_for_user
4442
from openedx.core.djangoapps.user_api.models import RetirementState, UserOrgTag, UserRetirementStatus
4543
from openedx.core.djangolib.testing.utils import skip_unless_lms
@@ -155,7 +153,6 @@ def _get_enrollments(self):
155153

156154

157155
@override_settings(EDX_API_KEY="i am a key")
158-
@override_waffle_flag(ENABLE_NOTIFICATIONS, True)
159156
@ddt.ddt
160157
@skip_unless_lms
161158
class EnrollmentTest(EnrollmentTestMixin, ModuleStoreTestCase, APITestCase, EnterpriseServiceMockMixin):

openedx/core/djangoapps/notifications/config/waffle.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@
77

88
WAFFLE_NAMESPACE = 'notifications'
99

10-
# .. toggle_name: notifications.enable_notifications
11-
# .. toggle_implementation: CourseWaffleFlag
10+
# .. toggle_name: notifications.disable_notifications
11+
# .. toggle_implementation: WaffleFlag
1212
# .. toggle_default: False
13-
# .. toggle_description: Waffle flag to enable the Notifications feature
14-
# .. toggle_use_cases: temporary, open_edx
15-
# .. toggle_creation_date: 2023-05-05
13+
# .. toggle_description: Waffle flag to disable the Notifications feature
14+
# .. toggle_use_cases: open_edx
15+
# .. toggle_creation_date: 2026-02-03
1616
# .. toggle_target_removal_date: None
17-
# .. toggle_warning: When the flag is ON, Notifications feature is enabled.
18-
# .. toggle_tickets: INF-866
19-
ENABLE_NOTIFICATIONS = WaffleFlag(f'{WAFFLE_NAMESPACE}.enable_notifications', __name__)
17+
# .. toggle_warning: When the flag is ON, Notifications feature is disabled.
18+
# .. toggle_tickets: None
19+
DISABLE_NOTIFICATIONS = WaffleFlag(f'{WAFFLE_NAMESPACE}.disable_notifications', __name__)
2020

21-
# .. toggle_name: notifications.enable_email_notifications
21+
# .. toggle_name: notifications.disable_email_notifications
2222
# .. toggle_implementation: WaffleFlag
2323
# .. toggle_default: False
24-
# .. toggle_description: Waffle flag to enable the Email Notifications feature
25-
# .. toggle_use_cases: temporary, open_edx
26-
# .. toggle_creation_date: 2024-03-25
27-
# .. toggle_target_removal_date: 2025-06-01
28-
# .. toggle_warning: When the flag is ON, Email Notifications feature is enabled.
24+
# .. toggle_description: Waffle flag to disable the Email Notifications feature
25+
# .. toggle_use_cases: open_edx
26+
# .. toggle_creation_date: 2026-02-03
27+
# .. toggle_target_removal_date: None
28+
# .. toggle_warning: When the flag is ON, Email Notifications feature will be disabled.
2929
# .. toggle_tickets: INF-1259
30-
ENABLE_EMAIL_NOTIFICATIONS = WaffleFlag(f'{WAFFLE_NAMESPACE}.enable_email_notifications', __name__)
30+
DISABLE_EMAIL_NOTIFICATIONS = WaffleFlag(f'{WAFFLE_NAMESPACE}.disable_email_notifications', __name__)
3131

3232
# .. toggle_name: notifications.enable_push_notifications
3333
# .. toggle_implementation: CourseWaffleFlag

openedx/core/djangoapps/notifications/email/tasks.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@
3232
get_language_preference_for_users,
3333
get_start_end_date,
3434
get_text_for_notification_type,
35-
is_email_notification_flag_enabled,
3635
)
3736
from ..base_notification import COURSE_NOTIFICATION_APPS
38-
from ..config.waffle import ENABLE_EMAIL_NOTIFICATIONS
37+
from ..config.waffle import DISABLE_EMAIL_NOTIFICATIONS
3938

4039
User = get_user_model()
4140
logger = get_task_logger(__name__)
@@ -76,16 +75,16 @@ def send_digest_email_to_user(
7675
start_date: Datetime object
7776
end_date: Datetime object
7877
"""
78+
if DISABLE_EMAIL_NOTIFICATIONS.is_enabled():
79+
return
7980

8081
if cadence_type not in [EmailCadence.IMMEDIATELY, EmailCadence.DAILY, EmailCadence.WEEKLY]:
8182
raise ValueError('Invalid cadence_type')
8283
logger.info(f'<Email Cadence> Sending email to user {user.username} ==Temp Log==')
8384
if not user.has_usable_password():
8485
logger.info(f'<Email Cadence> User is disabled {user.username} ==Temp Log==')
8586
return
86-
if not is_email_notification_flag_enabled(user):
87-
logger.info(f'<Email Cadence> Flag disabled for {user.username} ==Temp Log==')
88-
return
87+
8988
notifications = Notification.objects.filter(user=user, email=True,
9089
created__gte=start_date, created__lte=end_date)
9190
if not notifications:
@@ -147,19 +146,21 @@ def send_immediate_cadence_email(email_notification_mapping, course_key):
147146
2. Second notification → Schedule buffer job (15 min)
148147
3. Third+ notifications → Just mark as scheduled (no new job)
149148
"""
149+
if DISABLE_EMAIL_NOTIFICATIONS.is_enabled():
150+
return
151+
150152
if not email_notification_mapping:
151153
return
152154
user_list = email_notification_mapping.keys()
153155
users = list(User.objects.filter(id__in=user_list))
154156
language_prefs = get_language_preference_for_users(user_list)
155157
course_name = get_course_info(course_key).get("name", course_key)
158+
156159
for user in users:
157160
if not user.has_usable_password():
158161
logger.info(f'<Immediate Email> User is disabled {user.username}')
159162
continue
160-
if not is_email_notification_flag_enabled(user):
161-
logger.info(f'<Immediate Email> Flag disabled for {user.username}')
162-
continue
163+
163164
notification = email_notification_mapping.get(user.id, None)
164165
if not notification:
165166
logger.info(f'<Immediate Email> No notification for {user.username}')
@@ -394,7 +395,7 @@ def send_buffered_digest(
394395
"""
395396
try:
396397
# Re-check feature flags
397-
if not ENABLE_EMAIL_NOTIFICATIONS.is_enabled():
398+
if DISABLE_EMAIL_NOTIFICATIONS.is_enabled():
398399
logger.info('Email notifications disabled, cancelling digest')
399400
return
400401

0 commit comments

Comments
 (0)