Initial implementation of the 'replying_to=' method for extracting Subject and Refere...
authorArt Cancro <ajc@uncensored.citadel.org>
Tue, 12 Jul 2011 04:34:54 +0000 (00:34 -0400)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 21:34:37 +0000 (21:34 +0000)
webcit/messages.c
webcit/static/t/view_message.html

index 6d83128d2107041ac388cf19d9e3c0ec4e2a9b48..049b1f10f7cb29adc23d2e46d9c2b8e3bfeb4681 100644 (file)
@@ -1347,6 +1347,62 @@ void display_enter(void)
                return;
        }
 
+
+       /*
+        * If the "replying_to" variable is set, it refers to a message
+        * number from which we must extract some header fields...
+        */
+       long replying_to = lbstr("replying_to");
+       if (replying_to > 0) {
+               char wefw[1024] = "";
+               char msgn[1024] = "";
+               serv_printf("MSG0 %ld|1", replying_to); 
+               serv_getln(buf, sizeof buf);
+               if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+
+                       if ( (!strncasecmp(buf, "subj=", 5)) && (strlen(buf) > 5) ) {
+                               StrBuf *subj = NewStrBuf();
+                               if (strncasecmp(&buf[5], "Re:", 3)) {
+                                       StrBufAppendBufPlain(subj, HKEY("Re: "), 0);
+                               }
+                               StrBufAppendBufPlain(subj, &buf[5], -1, 0);
+                               PutBstr(HKEY("subject"), subj);
+                       }
+
+                       else if (!strncasecmp(buf, "wefw=", 5)) {
+                               safestrncpy(wefw, &buf[5], sizeof wefw);
+
+                               /* Trim down excessively long lists of thread references.  We eliminate the
+                                * second one in the list so that the thread root remains intact.
+                                */
+                               int rrtok = num_tokens(wefw, '|');
+                               int rrlen = strlen(wefw);
+                               if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
+                                       remove_token(wefw, 1, '|');
+                               }
+                       }
+
+                       else if (!strncasecmp(buf, "msgn=", 5)) {
+                               safestrncpy(msgn, &buf[5], sizeof msgn);
+                       }
+
+               }
+
+               if (strlen(wefw) + strlen(msgn) > 0) {
+                       StrBuf *refs = NewStrBuf();
+                       if (!IsEmptyStr(wefw)) {
+                               StrBufAppendBufPlain(refs, wefw, -1, 0);
+                       }
+                       if ( (!IsEmptyStr(wefw)) && (!IsEmptyStr(msgn)) ) {
+                               StrBufAppendBufPlain(refs, HKEY("|"), 0);
+                       }
+                       if (!IsEmptyStr(msgn)) {
+                               StrBufAppendBufPlain(refs, msgn, -1, 0);
+                       }
+                       PutBstr(HKEY("references"), refs);
+               }
+       }
+
        /*
         * Otherwise proceed normally.
         * Do a custom room banner with no navbar...
index fd2491edbcff405492cda09fd7948db7c98551b0..82c32275cc7f4073224824c2217f74d69c50dec6 100644 (file)
@@ -15,8 +15,8 @@
  <p id="msg<?MAIL:SUMM:N>" class="msgbuttons">
  <a href="display_enter?edit=<?MAIL:SUMM:N>?recp=<?MAIL:SUMM:TO("U")>?cc=<?MAIL:SUMM:CCCC("U")>?subject=<?MAIL:SUMM:SUBJECT("U", 0, "", "")>?force_room=_MAIL_"><span>[</span><?_("Edit")><span>]</span></a> 
 <?!("COND:ROOM:TYPE_IS", 8, #"VIEW_BBS")>
-   <a href="javascript:GetLoggedInFirst(encodeURIComponent('display_enter?references=<?MAIL:SUMM:REFIDS("U")>%7C<?MAIL:SUMM:INREPLYTO("U")>?subject=<?MAIL:SUMM:SUBJECT("U", 0, "Re: ", "Re:")>'));"><span>[</span><?_("Reply")><span>]</span></a> 
-   <a href="javascript:GetLoggedInFirst(encodeURIComponent('display_enter?references=<?MAIL:SUMM:REFIDS("U")>%7C<?MAIL:SUMM:INREPLYTO("U")>?replyquote=<?MAIL:SUMM:N>?recp=%22<?MAIL:SUMM:FROM("U")>%22%3C<?MAIL:SUMM:RFCA("U")>%3E?subject=<?MAIL:SUMM:SUBJECT("U", 0, "Re: ", "Re:")>'));"><span>[</span><?_("ReplyQuoted")><span>]</span></a> 
+   <a href="javascript:GetLoggedInFirst(encodeURIComponent('display_enter?replying_to=<?MAIL:SUMM:N>'));"><span>[</span><?_("Reply")><span>]</span></a> 
+   <a href="javascript:GetLoggedInFirst(encodeURIComponent('display_enter?replying_to=<?MAIL:SUMM:N>?replyquote=<?MAIL:SUMM:N>'));"><span>[</span><?_("ReplyQuoted")><span>]</span></a> 
 <?!("X", 8)>
 <??("COND:ROOM:TYPE_IS", 9, #"VIEW_BBS")>
        <?!("COND:MAIL:SUMM:RFCA", 10)>