From: Art Cancro Date: Thu, 23 Jul 2020 17:39:11 +0000 (-0400) Subject: shift around the order of the functions because we're going to remove some duplicated... X-Git-Tag: v939~240 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=ffbc5a6b94f8275e97b787439c6be656df0c86de shift around the order of the functions because we're going to remove some duplicated effort --- diff --git a/citadel/modules/inboxrules/serv_inboxrules.c b/citadel/modules/inboxrules/serv_inboxrules.c index 0baf93200..44294ddb9 100644 --- a/citadel/modules/inboxrules/serv_inboxrules.c +++ b/citadel/modules/inboxrules/serv_inboxrules.c @@ -424,7 +424,6 @@ int ctdl_getheaders(sieve2_context_t *s, void *my) { } - /* * Perform sieve processing for one message (called by sieve_do_room() for each message) */ @@ -820,111 +819,6 @@ BAIL: -/* - * A user account is identified as requring inbox processing. - * Do it. - */ -void do_inbox_processing_for_user(long usernum) { - if (CtdlGetUserByNumber(&CC->user, usernum) == 0) { - TRACE; - if (CC->user.msgnum_inboxrules <= 0) { - return; // this user has no inbox rules - } - - struct CtdlMessage *msg; - char *conf; - long conflen; - - msg = CtdlFetchMessage(CC->user.msgnum_inboxrules, 1, 1); - if (msg == NULL) { - return; // config msgnum is set but that message does not exist - } - - CM_GetAsField(msg, eMesageText, &conf, &conflen); - CM_Free(msg); - - if (conf == NULL) { - return; // config message exists but body is null - } - - - syslog(LOG_DEBUG, "RULEZ for %s", CC->user.fullname); - syslog(LOG_DEBUG, "%s", conf); - - // do something now FIXME actually write this - - free(conf); - } -} - - -/* - * Here is an array of users (by number) who have received messages in their inbox and may require processing. -*/ -long *users_requiring_inbox_processing = NULL; -int num_urip = 0; -int num_urip_alloc = 0; - - -/* - * Perform inbox processing for all rooms which require it - */ -void perform_inbox_processing(void) { - if (num_urip == 0) { - return; // no action required - } - - for (int i=0; iQRname[11], MAILROOM)) { - long usernum = atol(room->QRname); - if (usernum > 0) { - - // first check to see if this user is already on the list - if (num_urip > 0) { - for (int i=0; i<=num_urip; ++i) { - if (users_requiring_inbox_processing[i] == usernum) { // already on the list! - return(0); - } - } - } - - // make room if we need to - if (num_urip_alloc == 0) { - num_urip_alloc = 100; - users_requiring_inbox_processing = malloc(sizeof(long) * num_urip_alloc); - } - else if (num_urip >= num_urip_alloc) { - num_urip_alloc += 100; - users_requiring_inbox_processing = realloc(users_requiring_inbox_processing, (sizeof(long) * num_urip_alloc)); - } - - // now add the user to the list - users_requiring_inbox_processing[num_urip++] = usernum; - } - } - - // No errors are possible from this function. - return(0); -} - - enum { field_from, field_tocc, @@ -1182,6 +1076,111 @@ struct inboxrules *deserialize_inbox_rules(char *serialized_rules) { } +/* + * A user account is identified as requring inbox processing. + * Do it. + */ +void do_inbox_processing_for_user(long usernum) { + if (CtdlGetUserByNumber(&CC->user, usernum) == 0) { + TRACE; + if (CC->user.msgnum_inboxrules <= 0) { + return; // this user has no inbox rules + } + + struct CtdlMessage *msg; + char *conf; + long conflen; + + msg = CtdlFetchMessage(CC->user.msgnum_inboxrules, 1, 1); + if (msg == NULL) { + return; // config msgnum is set but that message does not exist + } + + CM_GetAsField(msg, eMesageText, &conf, &conflen); + CM_Free(msg); + + if (conf == NULL) { + return; // config message exists but body is null + } + + syslog(LOG_DEBUG, "RULEZ for %s", CC->user.fullname); + syslog(LOG_DEBUG, "%s", conf); + + // do something now FIXME actually write this + + free(conf); + } +} + + +/* + * Here is an array of users (by number) who have received messages in their inbox and may require processing. +*/ +long *users_requiring_inbox_processing = NULL; +int num_urip = 0; +int num_urip_alloc = 0; + + +/* + * Perform inbox processing for all rooms which require it + */ +void perform_inbox_processing(void) { + if (num_urip == 0) { + return; // no action required + } + + for (int i=0; iQRname[11], MAILROOM)) { + long usernum = atol(room->QRname); + if (usernum > 0) { + + // first check to see if this user is already on the list + if (num_urip > 0) { + for (int i=0; i<=num_urip; ++i) { + if (users_requiring_inbox_processing[i] == usernum) { // already on the list! + return(0); + } + } + } + + // make room if we need to + if (num_urip_alloc == 0) { + num_urip_alloc = 100; + users_requiring_inbox_processing = malloc(sizeof(long) * num_urip_alloc); + } + else if (num_urip >= num_urip_alloc) { + num_urip_alloc += 100; + users_requiring_inbox_processing = realloc(users_requiring_inbox_processing, (sizeof(long) * num_urip_alloc)); + } + + // now add the user to the list + users_requiring_inbox_processing[num_urip++] = usernum; + } + } + + // No errors are possible from this function. + return(0); +} + + + /* * Get InBox Rules *