/* $Cambridge: hermes/src/prayer/cmd/cmd_detach.c,v 1.2 2008/05/19 15:55:54 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");
}
