/* $Id: sort.c 1690 2005-03-18 12:48:34Z paul $ Copyright (C) 2004 Aaron Stone aaron at serendipity dot cx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Functions for running user defined sorting rules * on a message in the temporary store, usually * just delivering the message to the user's INBOX * ...unless they have fancy rules defined, that is :-) * */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include "db.h" #include "auth.h" #include "debug.h" #include "list.h" #include "pipe.h" #include "forward.h" #include "sort.h" #include "dbmail.h" #include "debug.h" #include #include #include #include #include #include "dbmd5.h" #include "misc.h" #include "dsn.h" #ifdef SIEVE #include "sortsieve.h" #endif dsn_class_t sort_and_deliver(u64_t msgidnr, u64_t msgsize, u64_t useridnr, const char *mailbox) { u64_t mboxidnr, newmsgidnr; if (mailbox == NULL) mailbox = "INBOX"; if (db_find_create_mailbox(mailbox, useridnr, &mboxidnr) != 0) { trace(TRACE_ERROR, "sort_and_deliver(): INBOX not found and could not be created."); return DSN_CLASS_FAIL; } else { switch (db_copymsg(msgidnr, mboxidnr, useridnr, &newmsgidnr)) { case -2: trace(TRACE_MESSAGE, "%s, %s: error copying message to user [%llu]," "maxmail exceeded", __FILE__, __func__, useridnr); return DSN_CLASS_QUOTA; case -1: trace(TRACE_ERROR, "%s, %s: error copying message to user [%llu]", __FILE__, __func__, useridnr); return DSN_CLASS_TEMP; default: trace(TRACE_MESSAGE, "%s, %s: message id=%llu, size=%llu is inserted", __FILE__, __func__, newmsgidnr, msgsize); return DSN_CLASS_OK; } } }