def METHOD_NAME(
    request,
    topic,
    author,
    text,
):
    post = Post()
    post.topic = topic
    post.author = author
    post.pubdate = datetime.now()
    if topic.last_message is not None:
        post.position = topic.last_message.position + 1
    else:
        post.position = 1
    if request:
        post.update_content(
            text,
            on_error=lambda m: messages.error(request, _("Erreur du serveur Markdown:\n{}").format("\n- ".join(m))),
        )
        post.ip_address = get_client_ip(request)
        post.hat = get_hat_from_request(request)
    else:
        post.update_content(text, on_error=lambda m: logging.getLogger(__name__).error("--".join(m)))
    post.save()
    topic.last_message = post
    topic.save()
    return topic