Skip to content

Conversation

@Johnetordoff
Copy link
Contributor

@Johnetordoff Johnetordoff commented Sep 19, 2025

Purpose

Fix subscription legacy compatibility issues with v2 API

Changes

  • Filter to Notification Types that are changable via v2 in v2
  • Clean-up view id patterns and syntax
  • fix tests that were skipping behavior by subscribing to correct object.

QA Notes

Please make verification statements inspired by your code and what your code touches.

  • Verify
  • Verify

What are the areas of risk?

Any concerns/considerations/questions that development raised?

Documentation

Side Effects

Ticket

https://openscience.atlassian.net/browse/ENG-9005


return NotificationSubscription.objects.filter(user=self.request.user).annotate(
return NotificationSubscription.objects.filter(
notification_type__in=[
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Main issue was we were pulling from types of subscription that weren't coded for legacy susbscriptions, this filters the types of new notification that are editable now. Only those 3 now that comments and mentions aren't subscription types.

event_name=Case(
When(
notification_type__name=NotificationType.Type.NODE_FILES_UPDATED.value,
notification_type=NotificationType.Type.USER_FILE_UPDATED.instance,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Improvement performance and Value( for correctness.

def notification(self, user):
return NotificationSubscriptionFactory(user=user)
return NotificationSubscriptionFactory(
notification_type=NotificationType.Type.USER_FILE_UPDATED.instance,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These tests weren't quite right because they didn't use the subscribed object attribute, only type and user.

return NotificationSubscriptionFactory(
notification_type=NotificationType.Type.NODE_FILES_UPDATED.instance,
subscribed_object=node,
notification_type=NotificationType.Type.NODE_FILE_UPDATED.instance,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

typo in FILE(S) and same as above.

@Johnetordoff Johnetordoff force-pushed the fix/update-v2-subscriptions branch from 43f53d6 to caca24c Compare September 19, 2025 20:03
match getattr(ct, 'model', None):
case 'preprintprovider' | 'collectionprovider' | 'registrationprovider':
# Providers: use subscribed_object._id (which is the provider short name, e.g. 'mindrxiv')
match self.notification_type.name:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just changed for clarity and correctness.

return obj.absolute_api_v2_url

def update(self, instance, validated_data):
instance.message_frequency = validated_data.get['frequency']
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Strange this wasn't effected by tests, but now it works in test_subscription_detail_patch

@property
def absolute_api_v2_url(self):
from api.base.utils import absolute_reverse
return absolute_reverse('institutions:institution-detail', kwargs={'institution_id': self._id, 'version': 'v2'})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is another thing that should have broken tests, but didn't.

@Johnetordoff Johnetordoff changed the title [WIP][ENG-9005] Fix/update v2 subscriptions [ENG-9005] Fix/update v2 subscriptions Sep 19, 2025
Copy link
Contributor

@opaduchak opaduchak left a comment

Choose a reason for hiding this comment

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

LGTM!

@Johnetordoff Johnetordoff merged commit 0b7fe79 into CenterForOpenScience:feature/notification-refactor-p2-s Oct 22, 2025
7 checks passed
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