Beispiel #1
0
def update_chat_title(controller: Controller, update: Dict[str, Any]) -> None:
    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)
Beispiel #2
0
def update_chat_order(controller: Controller, update: Dict[str, Any]) -> None:
    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)
Beispiel #3
0
def update_chat_is_marked_as_unread(controller: Controller,
                                    update: Dict[str, Any]) -> None:
    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)
Beispiel #4
0
def update_chat_read_outbox(controller: Controller, update: Dict[str,
                                                                 Any]) -> None:
    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)
Beispiel #5
0
def update_chat_draft_message(controller: Controller,
                              update: Dict[str, Any]) -> None:
    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)
Beispiel #6
0
def update_chat_position(controller: Controller, update: Dict[str,
                                                              Any]) -> None:
    current_chat_id = controller.model.current_chat_id
    chat_id = update["chat_id"]
    info = {}
    info["order"] = update["position"]["order"]
    if "is_pinned" in update:
        info["is_pinned"] = update["is_pinned"]
    if controller.model.chats.update_chat(chat_id, **info):
        controller.refresh_current_chat(current_chat_id)
Beispiel #7
0
def update_chat_is_pinned(controller: Controller, update: Dict[str,
                                                               Any]) -> None:
    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)
Beispiel #8
0
def update_chat_last_message(controller: Controller,
                             update: Dict[str, Any]) -> None:
    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)
Beispiel #9
0
def update_chat_last_message(controller: Controller,
                             update: Dict[str, Any]) -> None:
    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

    info = {}
    info["last_message"] = last_message
    if len(update["positions"]) > 0:
        info["order"] = update["positions"][0]["order"]

    current_chat_id = controller.model.current_chat_id
    if controller.model.chats.update_chat(chat_id, **info):
        controller.refresh_current_chat(current_chat_id)