Paul J Stevens wrote:
What patch? I'm not sure I actually saw that one. Stripping out execute_auto_ran would do the trick, right?
See attached patch. -Jon -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.
>From cff34685a26a080ef3f43e7c32c33dcc2839a595 Mon Sep 17 00:00:00 2001 From: Jonathan Feally <vult...@netvulture.com> Date: Mon, 1 Jun 2009 09:42:57 -0700 Subject: [PATCH] remove auto_reply and auto_notification completely --- dbmail.conf | 20 ---------- sql/mysql/2_3_5-2_3_6.mysql | 4 ++ sql/mysql/fix_foreign_keys.mysql | 14 ------- sql/sqlite/2_3_5-2_3_6.sqlite | 4 ++ src/dbmail-message.c | 74 -------------------------------------- src/dm_db.c | 49 +------------------------ src/dm_db.h | 23 ------------ test/check_dbmail_db.c | 23 ------------ 8 files changed, 9 insertions(+), 202 deletions(-) diff --git a/dbmail.conf b/dbmail.conf index 69417d4..7cffe89 100644 --- a/dbmail.conf +++ b/dbmail.conf @@ -351,25 +351,6 @@ SIEVE_NOTIFY = yes SIEVE_DEBUG = no # -# Use the auto_notify table to send email notifications. -# -AUTO_NOTIFY = no - -# -# Use the auto_reply table to send away messages. -# -AUTO_REPLY = no -# -# Defaults to "NEW MAIL NOTIFICATION" -# -#AUTO_NOTIFY_SUBJECT = - -# -# Defaults to POSTMASTER from the DBMAIL section. -# -#AUTO_NOTIFY_SENDER = - -# # If you set this to 'yes' dbmail will check for duplicate # messages in the relevant mailbox during delivery using # the Message-ID header @@ -378,4 +359,3 @@ suppress_duplicates = no # end of configuration file - diff --git a/sql/mysql/2_3_5-2_3_6.mysql b/sql/mysql/2_3_5-2_3_6.mysql index 771994c..ae9231b 100644 --- a/sql/mysql/2_3_5-2_3_6.mysql +++ b/sql/mysql/2_3_5-2_3_6.mysql @@ -20,6 +20,10 @@ DROP TABLE IF EXISTS dbmail_replytofield; DROP TABLE IF EXISTS dbmail_subjectfield; DROP TABLE IF EXISTS dbmail_tofield; +-- Drop auto tables +DROP TABLE IF EXISTS dbmail_auto_replies; +DROP TABLE IF EXISTS dbmail_auto_notifications; + -- Drop new cache tables because of move from legacy tables DROP TABLE IF EXISTS dbmail_header; DROP TABLE IF EXISTS dbmail_headername; diff --git a/sql/mysql/fix_foreign_keys.mysql b/sql/mysql/fix_foreign_keys.mysql index efdb133..ad42c62 100644 --- a/sql/mysql/fix_foreign_keys.mysql +++ b/sql/mysql/fix_foreign_keys.mysql @@ -87,20 +87,6 @@ alter table dbmail_messageblks add CONSTRAINT dbmail_messageblks_ibfk_1 FOREIGN KEY (`physmessage_id`) REFERENCES `dbmail_physmessage` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; -alter table dbmail_auto_notifications drop foreign key physmessage_id_fk; -alter table dbmail_auto_notifications drop foreign key dbmail_auto_notifications_ibfk_1; -alter table dbmail_auto_notifications drop foreign key dbmail_auto_notifications_ibfk_2; -alter table dbmail_auto_notifications add CONSTRAINT dbmail_messageblks_ibfk_1 - FOREIGN KEY (`physmessage_id`) REFERENCES `dbmail_physmessage` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; - - -alter table dbmail_auto_replies drop foreign key physmessage_id_fk; -alter table dbmail_auto_replies drop foreign key dbmail_auto_replies_ibfk_1; -alter table dbmail_auto_replies drop foreign key dbmail_auto_replies_ibfk_2; -alter table dbmail_auto_replies add CONSTRAINT dbmail_auto_replies_ibfk_1 - FOREIGN KEY (`user_idnr`) REFERENCES `dbmail_users` (`user_idnr`) ON DELETE CASCADE ON UPDATE CASCADE; - - alter table dbmail_sievescripts drop foreign key physmessage_id_fk; alter table dbmail_sievescripts drop foreign key dbmail_sievescripts_ibfk_1; alter table dbmail_sievescripts drop foreign key dbmail_sievescripts_ibfk_2; diff --git a/sql/sqlite/2_3_5-2_3_6.sqlite b/sql/sqlite/2_3_5-2_3_6.sqlite index 2017e58..bdf809f 100644 --- a/sql/sqlite/2_3_5-2_3_6.sqlite +++ b/sql/sqlite/2_3_5-2_3_6.sqlite @@ -22,6 +22,10 @@ DROP TABLE IF EXISTS dbmail_replytofield; DROP TABLE IF EXISTS dbmail_subjectfield; DROP TABLE IF EXISTS dbmail_tofield; +-- Drop auto tables +DROP TABLE IF EXISTS dbmail_auto_replies; +DROP TABLE IF EXISTS dbmail_auto_notifications; + DELETE FROM dbmail_referencesfield; --CREATE TRIGGER fk_insert_headervalue_headername_id diff --git a/src/dbmail-message.c b/src/dbmail-message.c index 513d4c8..42f4d83 100644 --- a/src/dbmail-message.c +++ b/src/dbmail-message.c @@ -2456,76 +2456,6 @@ static int send_reply(DbmailMessage *message, const char *body) return result; } - -/* Yeah, RAN. That's Reply And Notify ;-) */ -static int execute_auto_ran(DbmailMessage *message, u64_t useridnr) -{ - field_t val; - int do_auto_notify = 0, do_auto_reply = 0; - char *reply_body = NULL; - char *notify_address = NULL; - - /* message has been succesfully inserted, perform auto-notification & auto-reply */ - if (config_get_value("AUTO_NOTIFY", "DELIVERY", val) < 0) { - TRACE(TRACE_ERR, "error getting config value for AUTO_NOTIFY"); - return -1; - } - - if (strcasecmp(val, "yes") == 0) - do_auto_notify = 1; - - if (config_get_value("AUTO_REPLY", "DELIVERY", val) < 0) { - TRACE(TRACE_ERR, "error getting config value for AUTO_REPLY"); - return -1; - } - - if (strcasecmp(val, "yes") == 0) - do_auto_reply = 1; - - if (do_auto_notify != 0) { - TRACE(TRACE_DEBUG, "starting auto-notification procedure"); - - if (db_get_notify_address(useridnr, ¬ify_address) != 0) - TRACE(TRACE_ERR, "error fetching notification address"); - else { - if (notify_address == NULL) - TRACE(TRACE_DEBUG, "no notification address specified, skipping"); - else { - TRACE(TRACE_DEBUG, "sending notifcation to [%s]", notify_address); - if (send_notification(message, notify_address) < 0) { - TRACE(TRACE_ERR, "error in call to send_notification."); - g_free(notify_address); - return -1; - } - g_free(notify_address); - } - } - } - - if (do_auto_reply != 0) { - TRACE(TRACE_DEBUG, "starting auto-reply procedure"); - - if (db_get_reply_body(useridnr, &reply_body) != 0) - TRACE(TRACE_ERR, "error fetching reply body"); - else { - if (reply_body == NULL || reply_body[0] == '\0') - TRACE(TRACE_DEBUG, "no reply body specified, skipping"); - else { - if (send_reply(message, reply_body) < 0) { - TRACE(TRACE_ERR, "error in call to send_reply"); - g_free(reply_body); - return -1; - } - g_free(reply_body); - - } - } - } - - return 0; -} - - /* Here's the real *meat* of this source file! * * Function: insert_messages() @@ -2622,10 +2552,6 @@ int insert_messages(DbmailMessage *message, GList *dsnusers) break; } - /* Automatic reply and notification */ - if (execute_auto_ran(message, *useridnr) < 0) - TRACE(TRACE_ERR, "error in execute_auto_ran(), but continuing delivery normally."); - if (! g_list_next(userids)) break; userids = g_list_next(userids); diff --git a/src/dm_db.c b/src/dm_db.c index 02f6967..c51c817 100644 --- a/src/dm_db.c +++ b/src/dm_db.c @@ -114,12 +114,10 @@ void mailbox_match_free(struct mailbox_match *m) /** list of tables used in dbmail */ -#define DB_NTABLES 22 +#define DB_NTABLES 20 const char *DB_TABLENAMES[DB_NTABLES] = { "acl", "aliases", - "auto_notifications", - "auto_replies", "envelope", "header", "headername", @@ -989,51 +987,6 @@ int dm_quota_rebuild() return result; } -int db_get_notify_address(u64_t user_idnr, char **notify_address) -{ - C c; R r; volatile int t = DM_SUCCESS; - assert(notify_address != NULL); - *notify_address = NULL; - - c = db_con_get(); - TRY - r = db_query(c, "SELECT notify_address FROM %sauto_notifications WHERE user_idnr = %llu", - DBPFX,user_idnr); - if (db_result_next(r)) - *notify_address = g_strdup(db_result_get(r, 0)); - CATCH(SQLException) - LOG_SQLERROR; - t = DM_EQUERY; - FINALLY - db_con_close(c); - END_TRY; - - return t; -} - -int db_get_reply_body(u64_t user_idnr, char **reply_body) -{ - C c; R r; volatile int t = DM_SUCCESS; - *reply_body = NULL; - - c = db_con_get(); - TRY - r = db_query(c, "SELECT reply_body FROM %sauto_replies WHERE user_idnr = %llu " - "AND (start_date IS NULL OR start_date <= %s) " - "AND (stop_date IS NULL OR stop_date >= %s)", DBPFX, - user_idnr, db_get_sql(SQL_CURRENT_TIMESTAMP), db_get_sql(SQL_CURRENT_TIMESTAMP)); - if (db_result_next(r)) - *reply_body = g_strdup(db_result_get(r, 0)); - CATCH(SQLException) - LOG_SQLERROR; - t = DM_EQUERY; - FINALLY - db_con_close(c); - END_TRY; - - return t; -} - u64_t db_get_mailbox_from_message(u64_t message_idnr) { C c; R r; diff --git a/src/dm_db.h b/src/dm_db.h index 5cac0fd..6edea78 100644 --- a/src/dm_db.h +++ b/src/dm_db.h @@ -275,29 +275,6 @@ int dm_quota_rebuild(void); int dm_quota_rebuild_user(u64_t user_idnr); /** - * \brief get auto-notification address for a user - * \param user_idnr user id - * \param notify_address pointer to string that will hold the address - * \return - * - -2 on failure of allocating memory for string - * - -1 on database failure - * - 0 on success - * \attention caller should free deliver_to address - */ -int db_get_notify_address(u64_t user_idnr, char **notify_address); -/** - * \brief get reply body for auto-replies - * \param user_idnr user idnr - * \param body pointer to string that will hold reply body - * \return - * - -2 on failure of allocating memory for string - * - -1 on database failure - * - 0 on success - * \attention caller should free reply_body - */ -int db_get_reply_body(u64_t user_idnr, char **body); - -/** * \brief get user idnr of a message. * \param message_idnr idnr of message * \return diff --git a/test/check_dbmail_db.c b/test/check_dbmail_db.c index 187c38e..d41dfc4 100644 --- a/test/check_dbmail_db.c +++ b/test/check_dbmail_db.c @@ -382,29 +382,6 @@ END_TEST //int dm_quota_rebuild_user(u64_t user_idnr); /** - * \brief get auto-notification address for a user - * \param user_idnr user id - * \param notify_address pointer to string that will hold the address - * \return - * - -2 on failure of allocating memory for string - * - -1 on database failure - * - 0 on success - * \attention caller should free deliver_to address - */ -//int db_get_notify_address(u64_t user_idnr, char **notify_address); -/** - * \brief get reply body for auto-replies - * \param user_idnr user idnr - * \param body pointer to string that will hold reply body - * \return - * - -2 on failure of allocating memory for string - * - -1 on database failure - * - 0 on success - * \attention caller should free reply_body - */ -//int db_get_reply_body(u64_t user_idnr, char **body); - -/** * \brief get user idnr of a message. * \param message_idnr idnr of message * \return -- 1.6.1.3
_______________________________________________ Dbmail-dev mailing list Dbmail-dev@dbmail.org http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail-dev