Skip to content

Commit ad6943a

Browse files
authored
Merge pull request #11457 from Ostap-Zherebetskyi/fix/notification_settings
[ENG-9758] fix NotificationSubscription _id property
2 parents c18642d + 27b43be commit ad6943a

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

osf/models/notification_subscription.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,27 @@ def _id(self):
120120
"""
121121
Legacy subscription id for API compatibility.
122122
"""
123-
match self.notification_type.name:
124-
case NotificationType.Type.PROVIDER_NEW_PENDING_SUBMISSIONS.value:
125-
return f'{self.subscribed_object._id}_new_pending_submissions'
126-
case NotificationType.Type.USER_FILE_UPDATED.value:
127-
return f'{self.user._id}_file_updated'
128-
case NotificationType.Type.NODE_FILE_UPDATED.value:
129-
return f'{self.subscribed_object._id}_file_updated'
130-
case _:
131-
raise NotImplementedError()
123+
_global_file_updated = [
124+
NotificationType.Type.USER_FILE_UPDATED.value,
125+
NotificationType.Type.FILE_ADDED.value,
126+
NotificationType.Type.FILE_REMOVED.value,
127+
NotificationType.Type.ADDON_FILE_COPIED.value,
128+
NotificationType.Type.ADDON_FILE_RENAMED.value,
129+
NotificationType.Type.ADDON_FILE_MOVED.value,
130+
NotificationType.Type.ADDON_FILE_REMOVED.value,
131+
NotificationType.Type.FOLDER_CREATED.value,
132+
]
133+
_global_reviews = [
134+
NotificationType.Type.PROVIDER_NEW_PENDING_SUBMISSIONS.value,
135+
NotificationType.Type.PROVIDER_REVIEWS_SUBMISSION_CONFIRMATION.value,
136+
NotificationType.Type.PROVIDER_REVIEWS_RESUBMISSION_CONFIRMATION.value,
137+
NotificationType.Type.PROVIDER_NEW_PENDING_WITHDRAW_REQUESTS.value,
138+
NotificationType.Type.REVIEWS_SUBMISSION_STATUS.value,
139+
]
140+
if self.notification_type.name in _global_file_updated:
141+
return f'{self.user._id}_file_updated'
142+
elif self.notification_type.name in _global_reviews:
143+
return f'{self.user._id}_global_reviews'
144+
elif self.notification_type.name == NotificationType.Type.NODE_FILE_UPDATED.value:
145+
return f'{self.subscribed_object._id}_file_updated'
146+
raise NotImplementedError()

0 commit comments

Comments
 (0)