示例#1
0
def update_summary(incident: Incident, user_id: str, message: str):
    # Easy case. No summary currently and one has been provided
    if message and not incident.summary:
        incident.summary = message
        incident.save()
        return True, f"{SUMMARY_UPDATED_TITLE}{message}"

    # Either no new summary has been provided, or one already exists
    msg = block_kit.Message()

    msg.add_block(
        block_kit.Section(
            block_id="update",
            text=block_kit.Text(
                f"{CURRENT_TITLE}{incident.summary or NO_SUMMARY_TEXT}"),
            accessory=block_kit.Button(CHANGE_BUTTON_TEXT,
                                       UPDATE_CURRENT_SUMMARY_ACTION,
                                       value=incident.pk),
        ))

    # if the user has supplied a message, provide the option for them to set it without
    # retyping in the dialog
    if message:
        msg.add_block(block_kit.Divider())
        msg.add_block(
            block_kit.Section(
                block_id=PROPOSED_MESSAGE_BLOCK_ID,
                text=block_kit.Text(f"{PROPOSED_TITLE}{message}"),
                accessory=block_kit.Button(ACCEPT_PROPOSED_TEXT,
                                           SET_NEW_SUMMARY_ACTION,
                                           value=incident.pk),
            ))

    comms_channel = CommsChannel.objects.get(incident=incident)
    msg.send(comms_channel.channel_id)
    return True, None
示例#2
0
def update_summary(incident: Incident, user_id: str, message: str):
    incident.summary = message
    incident.save()
    return True, None