def do_widget_post_save_actions(message: MutableMapping[str, Any]) -> None: ''' This is experimental code that only works with the webapp for now. ''' if not settings.ALLOW_SUB_MESSAGES: return content = message['message'].content sender_id = message['message'].sender_id message_id = message['message'].id widget_type = None extra_data = None widget_type, extra_data = get_widget_data(content) widget_content = message.get('widget_content') if widget_content is not None: # Note that we validate this data in check_message, # so we can trust it here. widget_type = widget_content['widget_type'] extra_data = widget_content['extra_data'] if widget_type: content = dict( widget_type=widget_type, extra_data=extra_data ) submessage = SubMessage( sender_id=sender_id, message_id=message_id, msg_type='widget', content=json.dumps(content), ) submessage.save() message['submessages'] = SubMessage.get_raw_db_rows([message_id])
def do_widget_post_save_actions(send_request: SendMessageRequest) -> None: """ This code works with the web app; mobile and other clients should also start supporting this soon. """ message_content = send_request.message.content sender_id = send_request.message.sender_id message_id = send_request.message.id widget_type = None extra_data = None widget_type, extra_data = get_widget_data(message_content) widget_content = send_request.widget_content if widget_content is not None: # Note that we validate this data in check_message, # so we can trust it here. widget_type = widget_content["widget_type"] extra_data = widget_content["extra_data"] if widget_type: content = dict( widget_type=widget_type, extra_data=extra_data, ) submessage = SubMessage( sender_id=sender_id, message_id=message_id, msg_type="widget", content=json.dumps(content), ) submessage.save() send_request.submessages = SubMessage.get_raw_db_rows([message_id])
def do_widget_post_save_actions(message: MutableMapping[str, Any]) -> None: ''' This is experimental code that only works with the webapp for now. ''' if not settings.ALLOW_SUB_MESSAGES: return content = message['message'].content sender_id = message['message'].sender_id message_id = message['message'].id widget_type = None extra_data = None if content in ['/poll', '/tictactoe']: widget_type = content[1:] if widget_type: content = dict( widget_type=widget_type, extra_data=extra_data ) submessage = SubMessage( sender_id=sender_id, message_id=message_id, msg_type='widget', content=json.dumps(content), ) submessage.save() message['submessages'] = SubMessage.get_raw_db_rows([message_id])
def do_widget_post_save_actions(message: MutableMapping[str, Any]) -> None: ''' This is experimental code that only works with the webapp for now. ''' if not settings.ALLOW_SUB_MESSAGES: return content = message['message'].content sender_id = message['message'].sender_id message_id = message['message'].id widget_type = None extra_data = None widget_type, extra_data = get_widget_data(content) widget_content = message.get('widget_content') if widget_content is not None: # Note that we validate this data in check_message, # so we can trust it here. widget_type = widget_content['widget_type'] extra_data = widget_content['extra_data'] if widget_type: content = dict( widget_type=widget_type, extra_data=extra_data ) submessage = SubMessage( sender_id=sender_id, message_id=message_id, msg_type='widget', content=json.dumps(content), ) submessage.save() message['submessages'] = SubMessage.get_raw_db_rows([message_id])
def do_widget_post_save_actions(message: MutableMapping[str, Any]) -> None: ''' This code works with the webapp; mobile and other clients should also start supporting this soon. ''' content = message['message'].content sender_id = message['message'].sender_id message_id = message['message'].id widget_type = None extra_data = None widget_type, extra_data = get_widget_data(content) widget_content = message.get('widget_content') if widget_content is not None: # Note that we validate this data in check_message, # so we can trust it here. widget_type = widget_content['widget_type'] extra_data = widget_content['extra_data'] if widget_type: content = dict(widget_type=widget_type, extra_data=extra_data) submessage = SubMessage( sender_id=sender_id, message_id=message_id, msg_type='widget', content=json.dumps(content), ) submessage.save() message['submessages'] = SubMessage.get_raw_db_rows([message_id])
def do_widget_post_save_actions(message: MutableMapping[str, Any]) -> None: ''' This is experimental code that only works with the webapp for now. ''' if not settings.ALLOW_SUB_MESSAGES: return content = message['message'].content sender_id = message['message'].sender_id message_id = message['message'].id widget_type = None extra_data = None if content in ['/poll', '/tictactoe']: widget_type = content[1:] if widget_type: content = dict(widget_type=widget_type, extra_data=extra_data) submessage = SubMessage( sender_id=sender_id, message_id=message_id, msg_type='widget', content=json.dumps(content), ) submessage.save() message['submessages'] = SubMessage.get_raw_db_rows([message_id])
def do_widget_post_save_actions(message: MutableMapping[str, Any]) -> None: ''' This code works with the webapp; mobile and other clients should also start supporting this soon. ''' content = message['message'].content sender_id = message['message'].sender_id message_id = message['message'].id widget_type = None extra_data = None widget_type, extra_data = get_widget_data(content) widget_content = message.get('widget_content') if widget_content is not None: # Note that we validate this data in check_message, # so we can trust it here. widget_type = widget_content['widget_type'] extra_data = widget_content['extra_data'] if widget_type: content = dict( widget_type=widget_type, extra_data=extra_data ) submessage = SubMessage( sender_id=sender_id, message_id=message_id, msg_type='widget', content=json.dumps(content), ) submessage.save() message['submessages'] = SubMessage.get_raw_db_rows([message_id])