As sugested by Robotamer: append the view parameter to the link.
authorWilfried Goesgens <dothebart@citadel.org>
Mon, 9 Feb 2015 13:00:35 +0000 (14:00 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Mon, 9 Feb 2015 13:00:35 +0000 (14:00 +0100)
webcit/msg_renderers.c

index 408bc97d44f7a88bb9eaa2bb76e9af3ce2e40dd8..516041eab49b9fdc0df399dd3b9e1e39bc0bacaa 100644 (file)
@@ -926,12 +926,20 @@ void tmplput_MAIL_SUMM_N(StrBuf *Target, WCTemplputParams *TP)
 void tmplput_MAIL_SUMM_PERMALINK(StrBuf *Target, WCTemplputParams *TP)
 {
        message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
-       char perma_link[1024];
-
-       strcpy(perma_link, "/readfwd?go=");
-       urlesc(&perma_link[12], sizeof(perma_link) - 12, (char *)ChrPtr(WC->CurRoom.name) );
-       sprintf(&perma_link[strlen(perma_link)], "?start_reading_at=%ld#%ld", Msg->msgnum, Msg->msgnum);
-       StrBufAppendPrintf(Target, "%s", perma_link);
+       StrBuf *perma_link;
+       const StrBuf *View;
+
+       perma_link = NewStrBufPlain(HKEY("/readfwd?go="));
+       StrBufUrlescAppend(perma_link, WC->CurRoom.name, NULL);
+       View = SBSTR("view");
+       if (View != NULL) {
+               StrBufAppendBufPlain(perma_link, HKEY("?view="), 0);
+               StrBufAppendBuf(perma_link, View, 0);
+       }
+       StrBufAppendBufPlain(perma_link, HKEY("?start_reading_at="), 0);
+       StrBufAppendPrintf(perma_link, "%ld#%ld", Msg->msgnum, Msg->msgnum);
+       StrBufAppendBuf(Target, perma_link, 0);
+       FreeStrBuf(&perma_link);
 }