def handle_message_command(message): """Handles message broadcast requests.""" LOG.info('Received message command: message=%r', message) try: decodedmex = base64.b64decode(message) except TypeError: LOG.error('Received message is not valid base64: %r', message) else: text = decodedmex.decode('utf8') #FIXME maybe get author ID from message? user = "******" with session_scope() as session: user = query.get_user(session, user) if not user: LOG.error("Non-existent user %r, not logging message.", user) return message = query.log_message(session, user, text) broadcast(message.jsondict()) notifier.send_message(text)
def post(self): text = self.get_argument('msgtext') username = self.get_current_user() LOG.info("%r sent message %r from web", username, text) with session_scope() as session: user = query.get_user(session, username) message = query.log_message(session, user, text) LOG.info("Broadcasting to clients") broadcast(message.jsondict()) LOG.info("Notifying Fonera") notifier.send_message(text) self.render( 'templates/message.html', message='Messaggio inviato correttamente!', text=text )
def post(self): text = self.get_argument('msgtext') username = self.get_current_user() text = xhtml_escape(text) LOG.info("{} sent message {!r} from web".format(username, text)) with session_scope() as session: user = query.get_user(session, username) message = query.log_message(session, user, text) LOG.info("Broadcasting to clients") broadcast(message.jsondict()) LOG.info("Notifying Fonera") notifier.send_message(text) self.render('templates/message.html', message='Messaggio inviato correttamente!', text=text)
def handle_message_command(message): """Handles message broadcast requests.""" LOG.info('Received message command: message={!r}'.format(message)) try: decodedmex = base64.b64decode(message) except TypeError: LOG.error('Received message is not valid base64: {!r}'.format(message)) else: text = decodedmex.decode('utf8') #FIXME maybe get author ID from message? user = "******" with session_scope() as session: user = query.get_user(session, user) if not user: LOG.error( "Non-existent user {}, not logging message.".format(user)) return message = query.log_message(session, user, text) broadcast(message.jsondict()) notifier.send_message(text)