Fix event names

This commit is contained in:
Patrick Jentsch 2022-07-08 15:52:15 +02:00
parent 4e5957eea2
commit 018f9e752c

View File

@ -7,7 +7,7 @@ from flask_socketio import join_room, leave_room
@socketio.on('GET /users/<user_id>') @socketio.on('GET /users/<user_id>')
@socketio_login_required @socketio_login_required
def subscribe_user(user_hashid): def get_user(user_hashid):
user_id = hashids.decode(user_hashid) user_id = hashids.decode(user_hashid)
user = User.query.get(user_id) user = User.query.get(user_id)
if user is None: if user is None:
@ -27,15 +27,13 @@ def subscribe_user(user_hashid):
return {'code': 404, 'msg': 'Not found'} return {'code': 404, 'msg': 'Not found'}
if not (user == current_user or current_user.is_administrator): if not (user == current_user or current_user.is_administrator):
return {'code': 403, 'msg': 'Forbidden'} return {'code': 403, 'msg': 'Forbidden'}
# dict_user = user.to_dict(backrefs=True, relationships=True)
join_room(f'/users/{user.hashid}') join_room(f'/users/{user.hashid}')
# return {'code': 200, 'msg': 'OK', 'payload': dict_user}
return {'code': 200, 'msg': 'OK'} return {'code': 200, 'msg': 'OK'}
@socketio.on('UNSUBSCRIBE /users/<user_id>') @socketio.on('UNSUBSCRIBE /users/<user_id>')
@socketio_login_required @socketio_login_required
def subscribe_user(user_hashid): def unsubscribe_user(user_hashid):
user_id = hashids.decode(user_hashid) user_id = hashids.decode(user_hashid)
user = User.query.get(user_id) user = User.query.get(user_id)
if user is None: if user is None: