From cccc01dc3c5b9f774156b199bc1fe11f6aa9d319 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Sat, 2 Feb 2013 13:33:01 +0100 Subject: [PATCH] NETSPOOL: combine collecting of email recipients into one function; participates also. --- citadel/modules/network/serv_netmail.c | 43 +++++++++++++------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/citadel/modules/network/serv_netmail.c b/citadel/modules/network/serv_netmail.c index 5e0676b84..d9cd51093 100644 --- a/citadel/modules/network/serv_netmail.c +++ b/citadel/modules/network/serv_netmail.c @@ -88,6 +88,7 @@ void aggregate_recipients(StrBuf **recps, RoomNetCfg Which, OneRoomNetCfg *OneRN RoomNetCfgLine *nptr; struct CitContext *CCC = CC; + *recps = NULL; /* * Figure out how big a buffer we need to allocate */ @@ -95,6 +96,10 @@ void aggregate_recipients(StrBuf **recps, RoomNetCfg Which, OneRoomNetCfg *OneRN recps_len = recps_len + StrLength(nptr->Value[0]) + 2; } + /* Nothing todo... */ + if (recps_len == 0) + return; + *recps = NewStrBufPlain(NULL, recps_len); if (*recps == NULL) { @@ -426,7 +431,6 @@ void network_process_participate(SpoolControl *sc, struct CtdlMessage *omsg, lon int i; int ok_to_participate = 0; StrBuf *Buf = NULL; - RoomNetCfgLine *nptr; struct recptypes *valid; /* @@ -459,7 +463,11 @@ void network_process_participate(SpoolControl *sc, struct CtdlMessage *omsg, lon ok_to_participate = 1; } } - if (ok_to_participate) { + if (ok_to_participate) + { + StrBuf *recps = NULL; + char *precps; + if (msg->cm_fields['F'] != NULL) { free(msg->cm_fields['F']); } @@ -478,26 +486,17 @@ void network_process_participate(SpoolControl *sc, struct CtdlMessage *omsg, lon msg->cm_fields['F'][i] = '_'; } } - - /* - * Figure out how big a buffer we need to alloc - */ - for (nptr = sc->RNCfg->NetConfigs[participate]; - nptr != NULL; - nptr = nptr->next) - { - if (msg->cm_fields['R'] != NULL) { - free(msg->cm_fields['R']); - } - msg->cm_fields['R'] = - strdup(ChrPtr(nptr->Value[0])); - - valid = validate_recipients(msg->cm_fields['R'], - NULL, 0); - - CtdlSubmitMsg(msg, valid, "", 0); - free_recipients(valid); - } + + aggregate_recipients(&recps, participate, sc->RNCfg); + precps = SmashStrBuf(&recps); + valid = validate_recipients(precps, NULL, 0); + + if (msg->cm_fields['R'] != NULL) { + free(msg->cm_fields['R']); + }/* TODO: check whether 'R' is set appropriate later. */ + + CtdlSubmitMsg(msg, valid, "", 0); + free_recipients(valid); } FreeStrBuf(&Buf); CtdlFreeMessage(msg); -- 2.30.2