X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fupgrade%2Fserv_upgrade.c;h=9e446c2ef50c45ec0192e55fe4b19712920b8b71;hb=7a9b0685e406cc83597171cc39d008c7e5459ca8;hp=86e2947f440bf5e072a19756abc7a1569de49f2c;hpb=f59e2e6772d87d323d065f09919ec0876bf2e0be;p=citadel.git diff --git a/citadel/modules/upgrade/serv_upgrade.c b/citadel/modules/upgrade/serv_upgrade.c index 86e2947f4..9e446c2ef 100644 --- a/citadel/modules/upgrade/serv_upgrade.c +++ b/citadel/modules/upgrade/serv_upgrade.c @@ -24,18 +24,7 @@ #include #include #include - -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - +#include #include #include #include @@ -471,6 +460,48 @@ void move_inet_addrs_from_vcards_to_user_records(void) } + + +/* + * We found the legacy sieve config in the user's config room. Store the message number in the user record. + */ +void mifm_found_config(long msgnum, void *userdata) { + struct ctdluser *us = (struct ctdluser *)userdata; + + us->msgnum_inboxrules = msgnum; + syslog(LOG_DEBUG, "user: <%s> inbox filter msgnum: <%ld>", us->fullname, us->msgnum_inboxrules); +} + + +/* + * Helper function for migrate_inbox_filter_msgnums() + */ +void mifm_backend(char *username, void *data) { + struct ctdluser us; + char roomname[ROOMNAMELEN]; + + if (CtdlGetUserLock(&us, username) == 0) { + /* Take a spin through the user's personal config room */ + syslog(LOG_DEBUG, "Processing <%s> (%ld)", us.fullname, us.usernum); + snprintf(roomname, sizeof roomname, "%010ld.%s", us.usernum, USERCONFIGROOM); + if (CtdlGetRoom(&CC->room, roomname) == 0) { + CtdlForEachMessage(MSGS_LAST, 1, NULL, SIEVECONFIG, NULL, mifm_found_config, (void *)&us ); + } + CtdlPutUserLock(&us); + } +} + + +/* + * Prior to version 930 we used a MIME type search to locate the user's inbox filter rules. + * This function locates those ruleset messages and simply stores the message number in the user record. + */ +void migrate_inbox_filter_msgnums(void) +{ + ForEachUser(mifm_backend, NULL); +} + + /* * Create a default administrator account so we can log in to a new installation */ @@ -583,6 +614,11 @@ void post_startup_upgrades(void) { if ((oldver > 000) && (oldver < 922)) { ProcessOldStyleAdjRefCountQueue(); } + + if ((oldver > 000) && (oldver < 930)) { + migrate_inbox_filter_msgnums(); + } + }