Skip to content

Commit

Permalink
Filter out tracks that are deleted or unlisted for notification add t…
Browse files Browse the repository at this point in the history
…o playlist (#3421)
  • Loading branch information
jowlee authored Jul 11, 2022
1 parent af7447b commit 4be90ff
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions discovery-provider/src/queries/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,13 +905,18 @@ def notifications():
# Loop over notifications and populate their metadata
for notification in track_added_to_playlist_notifications:
track_id = notification[const.notification_metadata][const.track_id]
track_owner_id = track_owner_map[track_id]
if track_owner_id != notification[const.notification_initiator]:
# add tracks that don't belong to the playlist owner
notification[const.notification_metadata][
const.track_owner_id
] = track_owner_id
created_notifications.append(notification)
if track_id not in track_owner_map:
# Note: if track_id not in track_owner_map, it's because the track is either deleted, unlisted, or doesn't exist
# In that case, it should not trigger a notification
continue
else:
track_owner_id = track_owner_map[track_id]
if track_owner_id != notification[const.notification_initiator]:
# add tracks that don't belong to the playlist owner
notification[const.notification_metadata][
const.track_owner_id
] = track_owner_id
created_notifications.append(notification)

notifications_unsorted.extend(created_notifications)

Expand Down

0 comments on commit 4be90ff

Please sign in to comment.