def on_message(self, body, message): response = None if body["query"] == "all_messages": response = list_messages() elif body["query"] == "user_messages": response = list_user_messages(body["user_id"]) elif body["query"] == "search_messages": response = search_messages(body["search"]) elif body["query"] == "post_message": response = post_message(body["user_id"], body["message"]) if response is not None: response_prod = MessageResponseProducer(self.connection, messages_response_queue) response_prod.put_message( {"response": response, "message_id": body["message_id"]}, messages_response_exchange ) message.ack()
def on_message(self, body, message): response = None if body['query'] == 'all_messages': response = list_messages() elif body['query'] == 'user_messages': response = list_user_messages(body['user_id']) elif body['query'] == 'search_messages': response = search_messages(body['search']) elif body['query'] == 'post_message': response = post_message(body['user_id'], body['message']) if response is not None: response_prod = MessageResponseProducer(self.connection, messages_response_queue) response_prod.put_message( { 'response': response, 'message_id': body['message_id'] }, messages_response_exchange) message.ack()
def message_post(): m = post_message(request.form['user_id'], request.form['message']) return jsonify(**m)