X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=citadel%2Fmodules%2Finboxrules%2Fserv_inboxrules.c;h=a54007f8a4b2e7488a616ab7c051f34cbd3d8d1c;hp=30feea856624410a99285e52999396070bf0acc4;hb=b6845a37c842070f70b8fbb98fb49c5e2cfc9644;hpb=3101d92471592f0f1ffaf19fcd7f779b02057ef7 diff --git a/citadel/modules/inboxrules/serv_inboxrules.c b/citadel/modules/inboxrules/serv_inboxrules.c index 30feea856..a54007f8a 100644 --- a/citadel/modules/inboxrules/serv_inboxrules.c +++ b/citadel/modules/inboxrules/serv_inboxrules.c @@ -841,12 +841,91 @@ BAIL: rewrite_ctdl_sieve_config(&u, (u.lastproc > orig_lastproc) ) ; } +#endif -#endif +/* + * 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) { + syslog(LOG_DEBUG, "NO RULEZ for %s", CC->user.fullname); + return; // this user has no inbox rules + } + syslog(LOG_DEBUG, "RULEZ for %s", CC->user.fullname); + } +} + + +/* + * 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); +} /* @@ -946,11 +1025,10 @@ CTDL_MODULE_INIT(sieve) { if (!threading) { - // ctdl_sieve_init(); CtdlRegisterProtoHook(cmd_gibr, "GIBR", "Get InBox Rules"); CtdlRegisterProtoHook(cmd_pibr, "PIBR", "Put InBox Rules"); - // CtdlRegisterSessionHook(perform_sieve_processing, EVT_HOUSE, PRIO_HOUSE + 10); - // CtdlRegisterCleanupHook(cleanup_sieve); + CtdlRegisterRoomHook(serv_inboxrules_roomhook); + CtdlRegisterSessionHook(perform_inbox_processing, EVT_HOUSE, PRIO_HOUSE + 10); } /* return our module name for the log */