@@ -610,34 +610,37 @@ def create_waterbutler_log(payload, **kwargs):
610610 with transaction .atomic ():
611611 file_signals .file_updated .send (target = node , user = user , payload = payload )
612612
613- with transaction .atomic ():
614- match action :
615- case NotificationType .Type .FILE_ADDED :
616- notification = NotificationType .objects .get (name = NotificationType .Type .FILE_ADDED )
617- case NotificationType .Type .FILE_REMOVED :
618- notification = NotificationType .objects .get (name = NotificationType .Type .FILE_REMOVED )
619- case NotificationType .Type .FILE_UPDATED :
620- notification = NotificationType .objects .get (name = NotificationType .Type .FILE_UPDATED )
621- case NotificationType .Type .ADDON_FILE_RENAMED :
622- notification = NotificationType .objects .get (name = NotificationType .Type .ADDON_FILE_RENAMED )
623- case NotificationType .Type .ADDON_FILE_COPIED :
624- notification = NotificationType .objects .get (name = NotificationType .Type .ADDON_FILE_COPIED )
625- case NotificationType .Type .ADDON_FILE_REMOVED :
626- notification = NotificationType .objects .get (name = NotificationType .Type .ADDON_FILE_REMOVED )
627- case NotificationType .Type .ADDON_FILE_MOVED :
628- notification = NotificationType .objects .get (name = NotificationType .Type .ADDON_FILE_MOVED )
629- case _:
630- raise NotImplementedError (f'action { action } not implemented' )
631-
632- notification .emit (
633- user = user ,
634- event_context = {
635- 'profile_image_url' : user .profile_image_url (),
636- 'localized_timestamp' : str (timezone .now ()),
637- 'user_fullname' : user .fullname ,
638- 'url' : node .absolute_url ,
639- }
640- )
613+
614+ @file_signals .file_viewed .connect
615+ def emit_notification (self , target , user , payload ):
616+ action = payload ['action' ]
617+ match action :
618+ case NotificationType .Type .FILE_ADDED :
619+ notification = NotificationType .objects .get (name = NotificationType .Type .FILE_ADDED )
620+ case NotificationType .Type .FILE_REMOVED :
621+ notification = NotificationType .objects .get (name = NotificationType .Type .FILE_REMOVED )
622+ case NotificationType .Type .FILE_UPDATED :
623+ notification = NotificationType .objects .get (name = NotificationType .Type .FILE_UPDATED )
624+ case NotificationType .Type .ADDON_FILE_RENAMED :
625+ notification = NotificationType .objects .get (name = NotificationType .Type .ADDON_FILE_RENAMED )
626+ case NotificationType .Type .ADDON_FILE_COPIED :
627+ notification = NotificationType .objects .get (name = NotificationType .Type .ADDON_FILE_COPIED )
628+ case NotificationType .Type .ADDON_FILE_REMOVED :
629+ notification = NotificationType .objects .get (name = NotificationType .Type .ADDON_FILE_REMOVED )
630+ case NotificationType .Type .ADDON_FILE_MOVED :
631+ notification = NotificationType .objects .get (name = NotificationType .Type .ADDON_FILE_MOVED )
632+ case _:
633+ raise NotImplementedError (f'action { action } not implemented' )
634+
635+ notification .emit (
636+ user = user ,
637+ event_context = {
638+ 'profile_image_url' : user .profile_image_url (),
639+ 'localized_timestamp' : str (timezone .now ()),
640+ 'user_fullname' : user .fullname ,
641+ 'url' : target .absolute_url ,
642+ }
643+ )
641644
642645 return {'status' : 'success' }
643646
0 commit comments