def move_subscription(remove_users, source_event, source_node, new_event, new_node):
    if source_node == new_node:
        return
    old_sub = NotificationSubscription.load(to_subscription_key(source_node._id, source_event))
    if not old_sub:
        return
    elif old_sub:
        old_sub.update_fields(_id=to_subscription_key(new_node._id, new_event), event_name=new_event,
                              owner=new_node)
    new_sub = old_sub
    # Remove users that don't have permission on the new node.
    for notification_type in constants.NOTIFICATION_TYPES:
        if new_sub:
            for user_id in remove_users[notification_type]:
                if user_id in getattr(new_sub, notification_type, []):
                    user = User.load(user_id)
                    new_sub.remove_user_from_subscription(user)
Moves subscription from old_node to new_node
dataset/ETHPy150Open CenterForOpenScience/osf.io/website/notifications/utils.py/move_subscription