Пример #1
0
    def post(self):
        success = self.initController(
            "MessageController.post()",
            ["message", "channel", "nick", "version"])
        if not success:
            return self.response

        (cont, serverMessage) = getIrssiServerMessage(self.data)
        if not cont:
            self.response.out.write(serverMessage)
            return self.response

        try:
            message = dao.add_message(self.irssi_user, self.data["message"],
                                      self.data['channel'], self.data['nick'])
            dao.update_irssi_user_from_message(self.irssi_user,
                                               int(self.data['version']))
            gcmhelper.send_gcm_to_user_deferred(self.irssi_user,
                                                message.to_gcm_json())
        except:
            logging.warn("Error while creating new message, exception %s",
                         traceback.format_exc())
            self.response.status = '400 Bad Request'
            return self.response

        self.response.out.write(serverMessage)
Пример #2
0
    def post(self):
        success = self.initController("MessageController.post()", ["message", "channel", "nick", "version"])
        if not success:
            return self.response

        (cont, serverMessage) = getIrssiServerMessage(self.data)
        if not cont:
            self.response.out.write(serverMessage)
            return self.response

        try:
            message = dao.add_message(self.irssi_user, self.data["message"], self.data['channel'], self.data['nick'])
            dao.update_irssi_user_from_message(self.irssi_user, int(self.data['version']))
            gcmhelper.send_gcm_to_user_deferred(self.irssi_user, message.to_gcm_json())
        except:
            logging.warn("Error while creating new message, exception %s", traceback.format_exc())
            self.response.status = '400 Bad Request'
            return self.response

        self.response.out.write(serverMessage)