-
Notifications
You must be signed in to change notification settings - Fork 350
[ENG-9664] Fix node subscriptions API filtering #11405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,17 +21,24 @@ def subscribe_creator(resource): | |
| NotificationSubscription.objects.get_or_create( | ||
| user=user, | ||
| notification_type=NotificationType.Type.USER_FILE_UPDATED.instance, | ||
| object_id=user.id, | ||
| content_type=ContentType.objects.get_for_model(user), | ||
| _is_digest=True, | ||
| message_frequency='instantly', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing |
||
| ) | ||
| except NotificationSubscription.MultipleObjectsReturned: | ||
| pass | ||
| try: | ||
| NotificationSubscription.objects.get_or_create( | ||
| user=user, | ||
| notification_type=NotificationType.Type.NODE_FILE_UPDATED.instance, | ||
| object_id=resource.id, | ||
| content_type=ContentType.objects.get_for_model(resource), | ||
| _is_digest=True, | ||
| message_frequency='instantly', | ||
| ) | ||
| except NotificationSubscription.MultipleObjectsReturned: | ||
| pass | ||
| NotificationSubscription.objects.get_or_create( | ||
| user=user, | ||
| notification_type=NotificationType.Type.FILE_UPDATED.instance, | ||
| object_id=resource.id, | ||
| content_type=ContentType.objects.get_for_model(resource), | ||
| _is_digest=True, | ||
| ) | ||
|
|
||
| @contributor_added.connect | ||
| def subscribe_contributor(resource, contributor, auth=None, *args, **kwargs): | ||
|
|
@@ -54,7 +61,7 @@ def subscribe_contributor(resource, contributor, auth=None, *args, **kwargs): | |
| ), | ||
| NotificationSubscription( | ||
| user=contributor, | ||
| notification_type=NotificationType.Type.FILE_UPDATED.instance, | ||
| notification_type=NotificationType.Type.NODE_FILE_UPDATED.instance, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ultimately this was what was cause the issues, |
||
| object_id=resource.id, | ||
| content_type=ContentType.objects.get_for_model(resource), | ||
| _is_digest=True, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,7 +105,6 @@ def test_migrate_provider_subscription(self, users, provider, provider2): | |
| assert subs.filter(object_id=obj.id, content_type=content_type).exists() | ||
|
|
||
| def test_migrate_node_subscription(self, users, user, node): | ||
| self.create_legacy_sub('file_updated', users, user=user, node=node) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line is now not needed because subscription is now being correctly sent by the signal. |
||
| migrate_legacy_notification_subscriptions() | ||
| nt = NotificationType.objects.get(name=NotificationType.Type.NODE_FILE_UPDATED) | ||
| assert nt.object_content_type == ContentType.objects.get_for_model(Node) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we were adding the wrong type of notification before.