Beispiel #1
0
    def post(self):
        message_obj = json.loads(self.request.body)
        from_client_id = message_obj['fromClientId']
        assert (self.session.user_id == int(from_client_id.split('|')[0]))
        room_id = message_obj['chatRoomId']
        message_obj['fromUsernameAsWritten'] = self.session.username_as_written

        try:
            chat_room_obj = chat_room_module.ChatRoomModel.get_by_id(room_id)
            if chat_room_obj:
                self.handle_message_room(chat_room_obj, from_client_id,
                                         message_obj)
            else:
                logging.error('Unknown room_id %d' % room_id)
                raise Exception('unknownRoomId')

            http_helpers.set_http_ok_json_response(self.response, {})

        except:
            status_string = 'Server error'
            http_status_code = 500
            logging_function = logging.error

            http_helpers.set_error_json_response_and_write_log(
                self.response, status_string, logging_function,
                http_status_code, self.request)
    def post(self):
        message_obj = json.loads(self.request.body)
        from_client_id = message_obj['fromClientId']
        assert(self.session.user_id == int(from_client_id.split('|')[0]))

        try:
            self.handle_message_client(from_client_id, message_obj)
            http_helpers.set_http_ok_json_response(self.response, {})

        except:
            status_string = 'Unknown server error'
            http_status_code = 500
            logging_function = logging.error

            http_helpers.set_error_json_response_and_write_log(self.response, status_string, logging_function,
                                                               http_status_code, self.request)
Beispiel #3
0
    def post(self):
        message_obj = json.loads(self.request.body)
        from_client_id = message_obj['fromClientId']
        assert (self.session.user_id == int(from_client_id.split('|')[0]))

        try:
            self.handle_message_client(from_client_id, message_obj)
            http_helpers.set_http_ok_json_response(self.response, {})

        except:
            status_string = 'Unknown server error'
            http_status_code = 500
            logging_function = logging.error

            http_helpers.set_error_json_response_and_write_log(
                self.response, status_string, logging_function,
                http_status_code, self.request)
    def post(self):
        message_obj = json.loads(self.request.body)
        from_client_id = message_obj['fromClientId']
        assert(self.session.user_id == int(from_client_id.split('|')[0]))
        room_id = message_obj['chatRoomId']
        message_obj['fromUsernameAsWritten'] = self.session.username_as_written

        try:
            chat_room_obj = chat_room_module.ChatRoomModel.get_by_id(room_id)
            if chat_room_obj:
                self.handle_message_room(chat_room_obj, from_client_id, message_obj)
            else:
                logging.error('Unknown room_id %d' % room_id)
                raise Exception('unknownRoomId')

            http_helpers.set_http_ok_json_response(self.response, {})

        except:
            status_string = 'Server error'
            http_status_code = 500
            logging_function = logging.error

            http_helpers.set_error_json_response_and_write_log(self.response, status_string, logging_function,
                                                               http_status_code, self.request)