Mailinglist client: don't add roomname to subject if its already there
authorWilfried Goesgens <dothebart@citadel.org>
Thu, 31 Mar 2011 21:11:14 +0000 (23:11 +0200)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 17:21:39 +0000 (17:21 +0000)
citadel/modules/network/serv_network.c

index 4518740bf1ac9d00754940659cfbe3070abb6f5b..a5492eb69ed74b1eed4537d6fc4c8fba6b06c3c9 100644 (file)
@@ -712,17 +712,26 @@ void network_spool_msg(long msgnum, void *userdata) {
                                msg->cm_fields['U'] = strdup("(no subject)");
                        }
                        
-                       len  = strlen(msg->cm_fields['U']);
-                       rlen = strlen(CC->room.QRname);
-                       pCh  = strstr(msg->cm_fields['U'], CC->room.QRname);
+                       len = strlen(msg->cm_fields['U']);
+                       pCh = strstr(msg->cm_fields['U'], CC->room.QRname);
                        if ((pCh == NULL) ||
-                           (*(pCh + rlen) != ']') ||
+                           (*(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. */
+
                                rlen += len + 4;
                                pBuff = malloc (rlen * sizeof(char));