async def METHOD_NAME(scratch_org, type_, payload=None, error=None):
    if not payload:
        payload = {
            "org": str(scratch_org.id),
            "plan": str(scratch_org.plan.id),
        }
        if error:
            # unwrap the error in the case that there's only one,
            # which is the most common case:
            try:
                prepared_message = error.content
                if isinstance(prepared_message, list) and len(prepared_message) == 1:
                    prepared_message = prepared_message[0]
                if isinstance(prepared_message, dict):
                    prepared_message = prepared_message.get("message", prepared_message)
                prepared_message = str(prepared_message)
            except AttributeError:
                prepared_message = str(error)
            payload["message"] = prepared_message
    message = {
        "type": type_,
        "payload": payload,
    }
    group_name = CHANNELS_GROUP_NAME.format(model="scratchorg", id=scratch_org.id)
    sent_message = {"type": "notify", "group": group_name, "content": message}
    await push_message(group_name, sent_message)