def put_message(): app.logger.debug("Attempting to add new message (" + describe(request) + \ ") to message store.") # Try adding the message with the given data result = chat.add_new_message(request.json) if not result['success']: # The message was not added app.logger.debug("Failed adding new message: " + str(result)) else: # Everything went as expected! app.logger.debug("Successfully added new message: " + str(result)) return jsonit(result)
def get_keys(username): user_id = model.get_user(username, ['_id']) if not user_id: result = { 'success': False, 'keys': [], 'errors': [{ 'type': 'FATAL', 'cause': 'Unable to find user with username (%s).' % \ username}]} else: result = { 'success': True, 'keys': [x for x in chat.get_user_keys(user_id['_id'])]} return jsonit(result)
def temp_test_message(): return jsonit({'messages': [x for x in model.db.messages.find()]})
def get_message(user_id): result = chat.get_messages(user_id) return jsonit(result)
def get_key(key_id): return jsonit(chat.get_key(key_id))
def put_user(): """Put user function registers the user in the request body and returns the response as JSON.""" result = chat.register_user(request.json) return jsonit(result)