def get_messages_by_email(token = None,email=None): if token != None and email!=None and list_token_id.has_key(token): result = database_helper.get_messages_by_email(email) if result == 'wrong email': return return_json(404,False,result) else: return return_json(200,True,'User message retrieved',result) else: return return_json(403,False,'user not connected')
def get_user_messages_by_token(): input_data = request.get_json() token = input_data['token'] email = database_helper.get_email_by_token(token) if email is not None: messages = database_helper.get_messages_by_email(email) # if messages is not None: return json.dumps({"success": True, "message": "User messages retrieved.", "data": messages}) # else: # return json.dumps({"success": False, "message": "No message."}) else: return json.dumps({"success": False, "message": "You are not signed in."})
def get_user_messages_by_token(): token = request.form['token'] email = database_helper.get_email_by_token(token) # Check if the user is loggedin if (email is None): return jsonify(success = False, message = "You are not logged in.") else: user = database_helper.get_user_by_email(email[0]) if (user is None): return jsonify(success = False, message = "No such user.") else: messages = database_helper.get_messages_by_email(email[0]) return jsonify(success = True, message = "User messages retrieved.", data = messages)
def get_user_messages_by_email(token, email_friend): try: result = database_helper.get_messages_by_email(token, email_friend) return jsonify({ "success": True, "message": 'Could return user messages', "data": result }) except: return jsonify({ "success": False, "message": 'Could not return user messages' })
def user_get_messages_token(): data = request.get_json() if 'Authorization' in request.headers: a_token = request.headers.get('Authorization') email = database_helper.token_to_email(a_token) print(email) if (not database_helper.user_logged_in(a_token)): return create_response(False, 'You are not logged in') elif (not database_helper.user_exists(email)): return create_response(False, "No such user") else: data = database_helper.get_messages_by_email(a_token, email) if (data is not False): return create_response(True, "User messages retrieved", data) return create_response(False, "Something went wrong")
def get_user_messages_by_email(_): response = dh.get_messages_by_email(request.args['email']) if response: return response return error_status(400, 'User not found')