Skip to content

refactor: deprecated v2 preferences api and its dependencies#38072

Open
AhtishamShahid wants to merge 2 commits intomasterfrom
ahtisham/remove-v2-pref-api
Open

refactor: deprecated v2 preferences api and its dependencies#38072
AhtishamShahid wants to merge 2 commits intomasterfrom
ahtisham/remove-v2-pref-api

Conversation

@AhtishamShahid
Copy link
Contributor

@AhtishamShahid AhtishamShahid commented Mar 3, 2026

Ticket : #37947

This pull request refactors and simplifies the notification preferences system in the openedx/core/djangoapps/notifications module. It removes the NotificationTypeManager and NotificationAppManager classes, consolidates logic for retrieving notification preferences, and updates related documentation and function usage. The main goal is to streamline how default notification preferences are accessed and managed, reducing complexity and improving maintainability.

Key changes include:

Refactoring and Simplification:

  • Remove v2/configurations notifications API
  • Removed the NotificationTypeManager and NotificationAppManager classes, along with their methods for managing notification types and preferences, in favor of a simpler, function-based approach.
  • Deleted the get_default_values_of_preference function and replaced its usage with the more general get_default_values_of_preferences function throughout the codebase.
    Documentation and Naming Updates:
  • Updated docstrings and comments to clarify that use_app_defaults replaces the previous concept of "core" notifications, improving terminology and developer understanding.
    Code Cleanup:
  • Removed the unused get_non_editable_channels function from the serializers, further reducing unnecessary code.
  • Cleaned up test imports by removing references to deleted classes.

Copilot AI review requested due to automatic review settings March 3, 2026 09:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the deprecated V2 notification preferences API and the NotificationTypeManager/NotificationAppManager abstractions, consolidating “default preferences” logic into simpler utility functions and aligning terminology around use_app_defaults / grouped notifications.

Changes:

  • Removed the V2 aggregated preferences view and URL route, and deleted its associated test coverage.
  • Replaced per-app default lookup (get_default_values_of_preference) with a unified get_default_values_of_preferences helper and updated call sites.
  • Updated comments/terminology around “core” notifications to use_app_defaults / grouped notifications.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
openedx/core/djangoapps/notifications/views.py Removes V2 API view and relies on V3 grouped-notification update flow.
openedx/core/djangoapps/notifications/urls.py Removes the V2 route and import wiring.
openedx/core/djangoapps/notifications/tests/test_views.py Removes V2 view tests and associated imports.
openedx/core/djangoapps/notifications/tasks.py Switches default web-config lookup to the new unified defaults helper.
openedx/core/djangoapps/notifications/serializers.py Removes unused helper and adjusts notification type validation logic.
openedx/core/djangoapps/notifications/base_notification.py Removes manager classes, introduces unified defaults helper usage, and updates terminology/comments.
Comments suppressed due to low confidence (1)

openedx/core/djangoapps/notifications/base_notification.py:401

  • get_notification_content calls get_default_values_of_preferences(), which rebuilds a merged dict for all notification types on every invocation. Since Notification.content uses this during listing/serialization, this can become a hot path. Consider caching the merged mapping (e.g., functools.lru_cache or a module-level computed constant) and using that here to avoid repeated per-notification recomputation.
    # Retrieve the notification type object from NotificationTypeManager.
    notification_type = get_default_values_of_preferences().get(notification_type, None)

    if notification_type:
        # Check if the notification is grouped.
        is_grouped = context.get('grouped', False)

        # Determine the correct template key based on whether it's grouped or not.
        template_key = "grouped_content_template" if is_grouped else "content_template"

        # Get the corresponding template from the notification type.
        template = notification_type.get(template_key, None)


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

fix: Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

fix: resolved linter issues
@AhtishamShahid AhtishamShahid force-pushed the ahtisham/remove-v2-pref-api branch from 7fff5e1 to c8712b1 Compare March 4, 2026 03:15
@AhtishamShahid
Copy link
Contributor Author

Hi @kbuchanan-2u
Just a heads-up that we will be deprecating the v2 Notification API (v2/configurations/). This change may impact mobile apps — please note that the corresponding webapp changes have already been completed.

Could you confirm whether 2U is using a fork of the edX platform? If so, this deprecation will not affect your implementation.

For full details, please refer to the deprecation ticket:
#37947

Let us know if you have any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants