def put(request): msg_id = request.d.msg_id o_user = request.user ret = Message.get_msg_by_id(msg_id) if ret.error is not Error.OK: return error_response(ret) o_msg = ret.body if not isinstance(o_msg, Message): return error_response(Error.STRANGE) if o_msg.to_user != o_user: return error_response(Error.MESSAGE_NOT_BELONG) o_msg.read_msg() return response()
def rt_ss(request): """ /api/user/ss PUT: change_ss, 修改VPN信息 """ options = { # Method.GET: "获取我的信息", # Method.POST: "创建用户", Method.PUT: "修改VPN信息", } if request.method == Method.OPTIONS: return response(body=options, allow=True) if request.method == Method.PUT: return change_ss(request) return error_response(Error.ERROR_METHOD)
def rt_user(request): """ /api/user/ GET: get_my_info, 获取我的信息 POST: create_user, 创建用户 # PUT: modify_user, 修改用户信息 """ options = { Method.GET: "获取我的信息", # Method.POST: "创建用户", # Method.PUT: "修改用户信息", } if request.method == Method.OPTIONS: return response(body=options, allow=True) if request.method == Method.GET: return get_my_info(request) return error_response(Error.ERROR_METHOD)
def post(request): """ POST /api/image/ 七牛上传用户头像回调函数 """ deprint('ImageView-post') ret = QN_PUBLIC_MANAGER.qiniu_auth_callback(request) if ret.error is not Error.OK: return error_response(ret) key = request.d.key ret = Image.create(key) if ret.error is not Error.OK: return error_response(ret) o_image = ret.body if not isinstance(o_image, Image): return error_response(Error.STRANGE) return response(body=o_image.to_dict())
def post(request): phrase = request.d.phrase tags = request.d.tags tags = str(tags) start = Config.get_config_by_key('start').body if tags == 'BACK': start.value = str(int(start.value) - 1) elif tags == 'DELETE': start.value = str(int(start.value) + 1) else: ret = Phrase.create(phrase, tags) if ret.error is not Error.OK: return error_response(ret) start.value = str(int(start.value) + 1) start.save() return response()
def oauth_qtb_callback(request): code = request.d.code ret = get_qtb_user_token(code) if ret.error is not Error.OK: return error_response(ret) body = ret.body token = body['token'] qt_user_app_id = body['user_app_id'] ret = User.create(qt_user_app_id, token) if ret.error is not Error.OK: return error_response(ret) o_user = ret.body if not isinstance(o_user, User): return error_response(Error.STRANGE) ret = o_user.update() if ret.error is not Error.OK: return error_response(ret) return response(body=get_token_info(o_user))
def put(request): encrypted_data = request.d.encrypted_data iv = request.d.iv session_key = request.session_key ret = Weixin.decrypt(encrypted_data, iv, session_key) if ret.error is not Error.OK: return error_response(ret) data = ret.body o_user = request.user if not isinstance(o_user, User): return error_response(Error.STRANGE) avatar = data['avatarUrl'] nickname = data['nickName'] ret = o_user.update(avatar, nickname) if ret.error is not Error.OK: return error_response(ret) return response(o_user.to_dict())
def change_ss(request): """ PUT /api/user/ss 修改VPN信息 """ action = request.d.action o_user = request.user if not isinstance(o_user, User): return error_response(Error.STRANGE) print(action) if action == 'on': ret = o_user.do_ss_on() elif action == 'off': ret = o_user.do_ss_off() else: ret = o_user.do_ss_reset() if ret.error is not Error.OK: return error_response(ret) return response(body=o_user.to_dict())
def get(request): return response(body=Error.get_error_dict())
def get(request): start = int(Config.get_config_by_key('start').body.value) phrase = phrases[start] return response(phrase)
def post(request): tag = request.d.tag ret = Tag.create(tag) if ret.error is not Error.OK: return ret return response(Tag.get_tag_dict())
def get(request): return response(Tag.get_tag_dict())