#include "__imapemptyfolder.h" #include "Exception.h" #include "__imap.h" namespace jet { __imapemptyfolder::__imapemptyfolder(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) { coreutils::MString sessionId = resolveKeyword("sessionid"); if (!global.imapSessionExists(sessionId)) throw coreutils::Exception("imap sessionid does not exist.", __FILE__, __LINE__, 502); // Unlike __imapdelete (one message - low blast radius even on a // wrong default), this permanently destroys an entire folder's // contents - no silent "defaults to INBOX" here. A missing/blank // folder attribute is refused outright rather than risked. if (!keywordDefined("folder")) throw coreutils::Exception("imapemptyfolder tag must have folder defined.", __FILE__, __LINE__, 400); std::string folder = resolveKeyword("folder").str(); if (folder.empty()) throw coreutils::Exception("imapemptyfolder tag must have folder defined.", __FILE__, __LINE__, 400); out = global.getImapSession(sessionId)->emptyFolder(folder); } }