示例#1
0
def update_chat_title(controller: Controller, update: Dict[str, Any]):
    log.info("Proccessing updateChatTitle")
    chat_id = update["chat_id"]
    title = update["title"]

    current_chat_id = controller.model.current_chat_id
    if controller.model.chats.update_chat(chat_id, title=title):
        controller._refresh_current_chat(current_chat_id)
示例#2
0
def update_chat_order(controller: Controller, update: Dict[str, Any]):
    log.info("Proccessing updateChatOrder")
    current_chat_id = controller.model.current_chat_id
    chat_id = update["chat_id"]
    order = update["order"]

    if controller.model.chats.update_chat(chat_id, order=order):
        controller._refresh_current_chat(current_chat_id)
示例#3
0
def update_chat_is_marked_as_unread(controller: Controller, update: Dict[str,
                                                                         Any]):
    log.info("Proccessing updateChatIsMarkedAsUnread")
    chat_id = update["chat_id"]
    is_marked_as_unread = update["is_marked_as_unread"]

    current_chat_id = controller.model.current_chat_id
    if controller.model.chats.update_chat(
            chat_id, is_marked_as_unread=is_marked_as_unread):
        controller._refresh_current_chat(current_chat_id)
示例#4
0
def update_chat_draft_message(controller: Controller, update: Dict[str, Any]):
    log.info("Proccessing updateChatDraftMessage")
    chat_id = update["chat_id"]
    # FIXME: ignoring draft message itself for now because UI can't show it
    # draft_message = update["draft_message"]
    order = update["order"]

    current_chat_id = controller.model.current_chat_id
    if controller.model.chats.update_chat(chat_id, order=order):
        controller._refresh_current_chat(current_chat_id)
示例#5
0
def update_chat_read_outbox(controller: Controller, update: Dict[str, Any]):
    log.info("Proccessing updateChatReadOutbox")
    chat_id = update["chat_id"]
    last_read_outbox_message_id = update["last_read_outbox_message_id"]

    current_chat_id = controller.model.current_chat_id
    if controller.model.chats.update_chat(
            chat_id,
            last_read_outbox_message_id=last_read_outbox_message_id,
    ):
        controller._refresh_current_chat(current_chat_id)
示例#6
0
def update_chat_is_pinned(controller: Controller, update: Dict[str, Any]):
    log.info("Proccessing updateChatIsPinned")
    chat_id = update["chat_id"]
    is_pinned = update["is_pinned"]
    order = update["order"]

    current_chat_id = controller.model.current_chat_id
    if controller.model.chats.update_chat(chat_id,
                                          is_pinned=is_pinned,
                                          order=order):
        controller._refresh_current_chat(current_chat_id)
示例#7
0
def update_chat_last_message(controller: Controller, update: Dict[str, Any]):
    log.info("Proccessing updateChatLastMessage")
    chat_id = update["chat_id"]
    last_message = update.get("last_message")
    if not last_message:
        # according to documentation it can be null
        log.warning("last_message is null: %s", update)
        return
    order = update["order"]

    current_chat_id = controller.model.current_chat_id
    if controller.model.chats.update_chat(chat_id,
                                          last_message=last_message,
                                          order=order):
        controller._refresh_current_chat(current_chat_id)