From 6bb1bd7f5b355f4c4cd126e9360d78d47b7a4ec6 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Thu, 31 Mar 2011 23:11:14 +0200 Subject: [PATCH] Mailinglist client: don't add roomname to subject if its already there --- citadel/modules/network/serv_network.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/citadel/modules/network/serv_network.c b/citadel/modules/network/serv_network.c index 075b4578a..5c5625b5c 100644 --- a/citadel/modules/network/serv_network.c +++ b/citadel/modules/network/serv_network.c @@ -682,6 +682,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; @@ -711,9 +714,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. -- 2.39.2