def subscribe_user_to_notifications(node, user):
 NotificationSubscription = apps.get_model('osf.NotificationSubscription')
 if node.is_collection:
  raise InvalidSubscriptionError('Collections are invalid targets for subscriptions')
 if node.is_deleted:
  raise InvalidSubscriptionError('Deleted Nodes are invalid targets for subscriptions')
 events = constants.NODE_SUBSCRIPTIONS_AVAILABLE
 notification_type = 'email_transactional'
 target_id = node._id
 if user.is_registered:
  for event in events:
   event_id = to_subscription_key(target_id, event)
   global_event_id = to_subscription_key(user._id, ('global_' + event))
   global_subscription = NotificationSubscription.load(global_event_id)
   subscription = NotificationSubscription.load(event_id)
   if (not (node and node.parent_node and (not subscription) and (node.creator == user))):
    if (not subscription):
     subscription = NotificationSubscription(_id=event_id, owner=node, event_name=event)
     subscription.save()
    if global_subscription:
     global_notification_type = get_global_notification_type(global_subscription, user)
     subscription.add_user_to_subscription(user, global_notification_type)
    else:
     subscription.add_user_to_subscription(user, notification_type)
    subscription.save()

def subscribe_user_to_notifications ( node , user ) : NotificationSubscription = apps . get_model ( 'osf.NotificationSubscription' ) if node . is_collection : raise InvalidSubscriptionError ( 'Collections are invalid targets for subscriptions' ) if node . is_deleted : raise InvalidSubscriptionError ( 'Deleted Nodes are invalid targets for subscriptions' ) events = constants . NODE_SUBSCRIPTIONS_AVAILABLE notification_type = 'email_transactional' target_id = node . _id if user . is_registered : for event in events : event_id = to_subscription_key ( target_id , event ) global_event_id = to_subscription_key ( user . _id , ( 'global_' + event ) ) global_subscription = NotificationSubscription . load ( global_event_id ) subscription = NotificationSubscription . load ( event_id ) if ( not ( node and node . parent_node and ( not subscription ) and ( node . creator == user ) ) ) : if ( not subscription ) : subscription = NotificationSubscription ( _id = event_id , owner = node , event_name = event ) subscription . save ( ) if global_subscription : global_notification_type = get_global_notification_type ( global_subscription , user ) subscription . add_user_to_subscription ( user , global_notification_type ) else : subscription . add_user_to_subscription ( user , notification_type ) subscription . save ( )
update the notification settings for the creator or contributors .