#include "__imapmove.h" #include "Exception.h" #include "__imap.h" #include namespace jet { __imapmove::__imapmove(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); std::string folder = resolveKeyword("folder").str(); if (folder.empty()) folder = "INBOX"; if (!keywordDefined("uid")) throw coreutils::Exception("imapmove tag must have uid defined.", __FILE__, __LINE__, 400); uint32_t uid = (uint32_t)strtoul(resolveKeyword("uid").str().c_str(), nullptr, 10); if (!keywordDefined("destfolder")) throw coreutils::Exception("imapmove tag must have destfolder defined.", __FILE__, __LINE__, 400); std::string destFolder = resolveKeyword("destfolder").str(); out = global.getImapSession(sessionId)->moveMessage(folder, uid, destFolder); } }