X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fupgrade%2Fserv_upgrade.c;fp=citadel%2Fmodules%2Fupgrade%2Fserv_upgrade.c;h=b7167625b6bae2ad521b2386b84117c5282a27d7;hb=e830265f9a3238898ea25e8ed4782e50f2b7a775;hp=86e2947f440bf5e072a19756abc7a1569de49f2c;hpb=554b4865ddb1cd09b9311b13307b61abf4f1b22d;p=citadel.git diff --git a/citadel/modules/upgrade/serv_upgrade.c b/citadel/modules/upgrade/serv_upgrade.c index 86e2947f4..b7167625b 100644 --- a/citadel/modules/upgrade/serv_upgrade.c +++ b/citadel/modules/upgrade/serv_upgrade.c @@ -471,6 +471,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 +625,11 @@ void post_startup_upgrades(void) { if ((oldver > 000) && (oldver < 922)) { ProcessOldStyleAdjRefCountQueue(); } + + if ((oldver > 000) && (oldver < 930)) { + migrate_inbox_filter_msgnums(); + } + }