Skip to content

Commit

Permalink
feat: waffle based switch to ses for goal reminder email
Browse files Browse the repository at this point in the history
  • Loading branch information
sohailfatima committed Oct 8, 2024
1 parent a2bd8a7 commit 456019a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from openedx.core.djangoapps.user_api.preferences.api import get_user_preference
from openedx.core.lib.celery.task_utils import emulate_http_request
from openedx.features.course_duration_limits.access import get_user_course_expiration_date
from openedx.features.course_experience import ENABLE_COURSE_GOALS
from openedx.features.course_experience import ENABLE_COURSE_GOALS, ENABLE_SES_FOR_GOALREMINDER
from openedx.features.course_experience.url_helpers import get_learning_mfe_home_url

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -86,13 +86,24 @@ def send_ace_message(goal):
'programs_url': getattr(settings, 'ACE_EMAIL_PROGRAMS_URL', None),
})

options = {'transactional': True}

is_ses_enabled = ENABLE_SES_FOR_GOALREMINDER.is_enabled(goal.course_key)

if is_ses_enabled:
options = {
'transactional': True,
'from_address': settings.LMS_COMM_DEFAULT_FROM_EMAIL,
'override_default_channel': is_ses_enabled,
}

msg = Message(
name="goalreminder",
app_label="course_goals",
recipient=Recipient(user.id, user.email),
language=language,
context=message_context,
options={'transactional': True},
options=options,
)

with emulate_http_request(site, user):
Expand Down
3 changes: 3 additions & 0 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5541,3 +5541,6 @@ def _should_send_learning_badge_events(settings):
# .. for now it wil impact country listing in auth flow and user profile.
# .. eg ['US', 'CA']
DISABLED_COUNTRIES = []


LMS_COMM_DEFAULT_FROM_EMAIL = "[email protected]"
10 changes: 10 additions & 0 deletions openedx/features/course_experience/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@
# .. toggle_warning: This temporary feature toggle does not have a target removal date.
ENABLE_COURSE_GOALS = CourseWaffleFlag(f'{WAFFLE_FLAG_NAMESPACE}.enable_course_goals', __name__) # lint-amnesty, pylint: disable=toggle-missing-annotation

# .. toggle_name: course_experience.enable_ses_for_goalreminder
# .. toggle_implementation: CourseWaffleFlag
# .. toggle_default: False
# .. toggle_description: Used to determine whether or not to use AWS SES to send goal reminder emails for the course.
# .. toggle_use_cases: opt_in, temporary
# .. toggle_creation_date: 2024-10-06
# .. toggle_target_removal_date: None
# .. toggle_warning: This temporary feature toggle does not have a target removal date.
ENABLE_SES_FOR_GOALREMINDER = CourseWaffleFlag(f'{WAFFLE_FLAG_NAMESPACE}.enable_ses_for_goalreminder', __name__) # lint-amnesty, pylint: disable=toggle-missing-annotation

# Waffle flag to enable anonymous access to a course
SEO_WAFFLE_FLAG_NAMESPACE = 'seo'
COURSE_ENABLE_UNENROLLED_ACCESS_FLAG = CourseWaffleFlag( # lint-amnesty, pylint: disable=toggle-missing-annotation
Expand Down

0 comments on commit 456019a

Please sign in to comment.