From: Wilfried Goesgens Date: Thu, 31 Mar 2011 21:11:14 +0000 (+0200) Subject: Mailinglist client: don't add roomname to subject if its already there X-Git-Tag: v7.86~5 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=6a0444949a51f9886ef69e12408953e203b37df4 Mailinglist client: don't add roomname to subject if its already there --- diff --git a/citadel/modules/network/serv_network.c b/citadel/modules/network/serv_network.c index 643e85554..376e3fda3 100644 --- a/citadel/modules/network/serv_network.c +++ b/citadel/modules/network/serv_network.c @@ -684,6 +684,9 @@ void network_spool_msg(long msgnum, void *userdata) { */ msg = CtdlFetchMessage(msgnum, 1); if (msg != NULL) { + int len, rlen; + char *pCh; + if (msg->cm_fields['V'] == NULL){ /* local message, no enVelope */ StrBuf *Buf; @@ -713,9 +716,26 @@ void network_spool_msg(long msgnum, void *userdata) { if (msg->cm_fields['U'] == NULL) { msg->cm_fields['U'] = strdup("(no subject)"); } - snprintf(buf, sizeof buf, "[%s] %s", CC->room.QRname, msg->cm_fields['U']); - free(msg->cm_fields['U']); - msg->cm_fields['U'] = strdup(buf); + + len = strlen(msg->cm_fields['U']); + pCh = strstr(msg->cm_fields['U'], CC->room.QRname); + if ((pCh == NULL) || + (*(pCh + len) != ']') || + (pCh == msg->cm_fields['U']) || + (*(pCh - 1) != '[') + ) + { + char *pBuff; + + rlen = strlen(CC->room.QRname); + rlen += len + 4; + pBuff = malloc (rlen * sizeof(char)); + + snprintf(pBuff, rlen, "[%s] %s", CC->room.QRname, msg->cm_fields['U']); + free(msg->cm_fields['U']); + msg->cm_fields['U'] = pBuff; + } + /* else we won't modify the buffer, since the roomname is already here. */ /* Set the recipient of the list message to the * email address of the room itself.