/* $Cambridge: hermes/src/prayer/cmd/cmd_detach.c,v 1.3 2008/09/16 09:59:55 dpc22 Exp $ */
/************************************************
 *    Prayer - a Webmail Interface              *
 ************************************************/

/* Copyright (c) University of Cambridge 2000 - 2008 */
/* See the file NOTICE for conditions of use and distribution. */

#include "prayer_session.h"

void cmd_detach(struct session *session)
{
    struct request *request = session->request;
    struct draft *draft = session->draft;

    if (request->argc < 2) {
        session_redirect(session, request, "error");
        return;
    }

    draft_delete_attachment(draft, atoi(request->argv[1]));

    session_redirect(session, request, "attachments");
}
