Changed the display logic for message author. New conditional COND:MAIL:LOCAL which...
authorArt Cancro <ajc@citadel.org>
Sun, 13 Dec 2020 23:16:08 +0000 (18:16 -0500)
committerArt Cancro <ajc@citadel.org>
Sun, 13 Dec 2020 23:16:08 +0000 (18:16 -0500)
webcit/messages.h
webcit/msg_renderers.c
webcit/serv_func.c
webcit/static/t/view_blog/comment.html
webcit/static/t/view_blog/post.html
webcit/static/t/view_message.html
webcit/static/t/view_message/print.html
webcit/static/t/view_message/replyquote.html

index 32a172a7bfa97a17669c3dbd8d7860faae16fb67..872063170affd92ae37b48e0644ee3620f8701d2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996-2013 by the citadel.org team
+ * Copyright (c) 1996-2020 by the citadel.org team
  *
  * This program is open source software.  You can redistribute it and/or
  * modify it under the terms of the GNU General Public License, version 3.
@@ -42,36 +42,34 @@ void DestroyMime(void *vMime);
 #define MSGFLAG_READ (1<<0)
 
 typedef struct _message_summary {
-       long msgnum;            /* the message number on the citadel server */
+       long msgnum;                            // the message number on the citadel server
        int Flags;
-
-       time_t date;            /* its creation date */
+       time_t date;                            // its creation date
        int nhdr;
        int format_type;
        StrBuf *euid;
-       StrBuf *from;           /* the author */
-       StrBuf *to;             /* the recipient */
-       StrBuf *subj;           /* the title / subject */
+       StrBuf *from;                           // display name of message author
+       StrBuf *to;                             // the recipient
+       StrBuf *subj;                           // title / subject
        StrBuf *reply_inreplyto;
-       long    reply_inreplyto_hash;
+       long reply_inreplyto_hash;
        StrBuf *reply_references;
-       long    reply_references_hash;
+       long reply_references_hash;
        StrBuf *ReplyTo;
        StrBuf *cccc;
        StrBuf *AllRcpt;
        StrBuf *Room;
-       StrBuf *Rfca;
+       StrBuf *Rfca;                           // UPN or email address of message author
        StrBuf *EnvTo;
        const StrBuf *PartNum;
-       HashList *Attachments;  /* list of attachments */
+       HashList *Attachments;                  // list of attachments
        HashList *Submessages;
        HashList *AttachLinks;
        HashList *AllAttach;
        int hasattachments;
-
-       /* The mime part of the message */
-       wc_mime_attachment *MsgBody;
+       wc_mime_attachment *MsgBody;            // the MIME part of the message
 } message_summary;
+
 void DestroyMessageSummary(void *vMsg);
 
 /* Maps to msgkeys[] in msgbase.c: */
@@ -102,38 +100,35 @@ typedef enum _eMessageField {
        ePevious,
        eSubFolder,
        eLastHeader
-}eMessageField;
+} eMessageField;
 
 extern const char* fieldMnemonics[];
 
 int GetFieldFromMnemonic(eMessageField *f, const char* c);
-
 int EvaluateMsgHdr(const char *HeaderName, long HdrNLen, message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset);
 int EvaluateMsgHdrEnum(eMessageField f, message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset);
 
 
-
-static inline message_summary* GetMessagePtrAt(int n, HashList *Summ)
-{
+static inline message_summary* GetMessagePtrAt(int n, HashList *Summ) {
        const char *Key;
        long HKLen;
        void *vMsg;
 
-       if (Summ == NULL)
+       if (Summ == NULL) {
                return NULL;
+       }
        GetHashAt(Summ, n, &HKLen, &Key, &vMsg);
        return (message_summary*) vMsg;
 }
 
-typedef void (*ExamineMsgHeaderFunc)(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset);
 
+typedef void (*ExamineMsgHeaderFunc)(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset);
 void evaluate_mime_part(StrBuf *Target, WCTemplputParams *TP);
 
-
 typedef enum _eCustomRoomRenderer {
        eUseDefault = VIEW_JOURNAL + 100, 
        eReadEUIDS
-}eCustomRoomRenderer;
+} eCustomRoomRenderer;
 
 enum {
        do_search,
index 4be851de3c68e5d7b385ba2877450bd4cb80dbf0..7cb990271d2140f0ef5428a44d94ff9b94f8457b 100644 (file)
@@ -362,17 +362,38 @@ void tmplput_MAIL_SUMM_SUBJECT(StrBuf *Target, WCTemplputParams *TP)
        }
        StrBufAppendTemplate(Target, TP, Msg->subj, 0);
 }
-int Conditional_MAIL_SUMM_SUBJECT(StrBuf *Target, WCTemplputParams *TP)
-{
+
+/*
+ * Conditional returns true if the message has a Subject and it is nonzero in length
+ */
+int Conditional_MAIL_SUMM_SUBJECT(StrBuf *Target, WCTemplputParams *TP) {
        message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+       return StrLength(Msg->subj) > 0;
+}
 
 
-       return StrLength(Msg->subj) > 0;
+/*
+ * Conditional returns true if the message originated on the local system
+ */
+int Conditional_MAIL_LOCAL(StrBuf *Target, WCTemplputParams *TP) {
+       message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+
+       char *at = strchr(ChrPtr(Msg->Rfca), '@');
+       if (at == NULL) {
+               return 1;                                               // If there is no "@" in the address, it's got to be local.
+       }
+       ++at;
+
+       if (!strcasecmp(at, ChrPtr(WC->serv_info->serv_fqdn))) {        // is this from our local domain?
+               return 1;                                               // if yes, then the message originated locally.
+       }
+       else {
+               return 0;                                               // otherwise it probably didn't.
+       }
 }
 
 
-void examine_msgn(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
-{
+void examine_msgn(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {
        wcsession *WCC = WC;
        long Offset = 0;
        const char *pOffset;
@@ -1362,8 +1383,8 @@ const char* fieldMnemonics[] = {
 };
 HashList *msgKeyLookup = NULL;
 
-int GetFieldFromMnemonic(eMessageField *f, const char* c)
-{
+
+int GetFieldFromMnemonic(eMessageField *f, const char *c) {
        void *v = NULL;
        if (GetHash(msgKeyLookup, c, 4, &v)) {
                *f = (eMessageField) v;
@@ -1372,8 +1393,8 @@ int GetFieldFromMnemonic(eMessageField *f, const char* c)
        return 0;
 }
 
-void FillMsgKeyLookupTable(void)
-{
+
+void FillMsgKeyLookupTable(void) {
        long i = 0;
 
        msgKeyLookup = NewHash (1, FourHash);
@@ -1387,7 +1408,6 @@ void FillMsgKeyLookupTable(void)
 }
 
 
-
 void 
 InitModule_MSGRENDERERS
 (void)
@@ -1415,9 +1435,9 @@ InitModule_MSGRENDERERS
                         CTX_MAILSUM);
 
        RegisterNamespace("SUMM:COUNT", 0, 0, tmplput_SUMM_COUNT, NULL, CTX_NONE);
+
        /* iterate over all known mails in WC->summ */
-       RegisterIterator("MAIL:SUMM:MSGS", 0, NULL, iterate_get_mailsumm_All,
-                        NULL,NULL, CTX_MAILSUM, CTX_NONE, IT_NOFLAG);
+       RegisterIterator("MAIL:SUMM:MSGS", 0, NULL, iterate_get_mailsumm_All, NULL,NULL, CTX_MAILSUM, CTX_NONE, IT_NOFLAG);
 
        RegisterNamespace("MAIL:SUMM:EUID", 0, 1, tmplput_MAIL_SUMM_EUID, NULL, CTX_MAILSUM);
        RegisterNamespace("MAIL:SUMM:DATEBRIEF", 0, 0, tmplput_MAIL_SUMM_DATE_BRIEF, NULL, CTX_MAILSUM);
@@ -1446,22 +1466,19 @@ InitModule_MSGRENDERERS
        RegisterConditional("COND:MAIL:SUMM:UNREAD", 0, Conditional_MAIL_SUMM_UNREAD, CTX_MAILSUM);
        RegisterConditional("COND:MAIL:SUMM:SUBJECT", 0, Conditional_MAIL_SUMM_SUBJECT, CTX_MAILSUM);
        RegisterConditional("COND:MAIL:ANON", 0, Conditional_ANONYMOUS_MESSAGE, CTX_MAILSUM);
-       RegisterConditional("COND:MAIL:TO", 0, Conditional_MAIL_SUMM_TO, CTX_MAILSUM);  
-       RegisterConditional("COND:MAIL:SUBJ", 0, Conditional_MAIL_SUMM_SUBJ, CTX_MAILSUM);      
+       RegisterConditional("COND:MAIL:TO", 0, Conditional_MAIL_SUMM_TO, CTX_MAILSUM);
+       RegisterConditional("COND:MAIL:SUBJ", 0, Conditional_MAIL_SUMM_SUBJ, CTX_MAILSUM);
+       RegisterConditional("COND:MAIL:LOCAL", 0, Conditional_MAIL_LOCAL, CTX_MAILSUM);
 
        /* do we have mimetypes to iterate over? */
        RegisterConditional("COND:MAIL:MIME:ATTACH", 0, Conditional_MAIL_MIME_ALL, CTX_MAILSUM);
        RegisterConditional("COND:MAIL:MIME:ATTACH:SUBMESSAGES", 0, Conditional_MAIL_MIME_SUBMESSAGES, CTX_MAILSUM);
        RegisterConditional("COND:MAIL:MIME:ATTACH:LINKS", 0, Conditional_MAIL_MIME_ATTACHLINKS, CTX_MAILSUM);
        RegisterConditional("COND:MAIL:MIME:ATTACH:ATT", 0, Conditional_MAIL_MIME_ATTACH, CTX_MAILSUM);
-       RegisterIterator("MAIL:MIME:ATTACH", 0, NULL, iterate_get_mime_All, 
-                        NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
-       RegisterIterator("MAIL:MIME:ATTACH:SUBMESSAGES", 0, NULL, iterate_get_mime_Submessages, 
-                        NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
-       RegisterIterator("MAIL:MIME:ATTACH:LINKS", 0, NULL, iterate_get_mime_AttachLinks, 
-                        NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
-       RegisterIterator("MAIL:MIME:ATTACH:ATT", 0, NULL, iterate_get_mime_Attachments, 
-                        NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
+       RegisterIterator("MAIL:MIME:ATTACH", 0, NULL, iterate_get_mime_All, NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
+       RegisterIterator("MAIL:MIME:ATTACH:SUBMESSAGES", 0, NULL, iterate_get_mime_Submessages, NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
+       RegisterIterator("MAIL:MIME:ATTACH:LINKS", 0, NULL, iterate_get_mime_AttachLinks, NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
+       RegisterIterator("MAIL:MIME:ATTACH:ATT", 0, NULL, iterate_get_mime_Attachments, NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM, IT_NOFLAG);
 
        /* Parts of a mime attachent */
        RegisterNamespace("MAIL:MIME:NAME", 0, 2, tmplput_MIME_Name, NULL, CTX_MIME_ATACH);
@@ -1473,13 +1490,12 @@ InitModule_MSGRENDERERS
        RegisterNamespace("MAIL:MIME:CHARSET", 0, 2, tmplput_MIME_Charset, NULL, CTX_MIME_ATACH);
        RegisterNamespace("MAIL:MIME:LENGTH", 0, 2, tmplput_MIME_Length, NULL, CTX_MIME_ATACH);
        RegisterNamespace("MAIL:MIME:DATA", 0, 2, tmplput_MIME_Data, NULL, CTX_MIME_ATACH);
+
        /* load the actual attachment into WC->attachments; no output!!! */
        RegisterNamespace("MAIL:MIME:LOADDATA", 0, 0, tmplput_MIME_LoadData, NULL, CTX_MIME_ATACH);
 
        /* iterate the WC->attachments; use the above tokens for their contents */
-       RegisterIterator("MSG:ATTACHNAMES", 0, NULL, iterate_get_registered_Attachments, 
-                        NULL, NULL, CTX_MIME_ATACH, CTX_NONE, IT_NOFLAG);
-
+       RegisterIterator("MSG:ATTACHNAMES", 0, NULL, iterate_get_registered_Attachments, NULL, NULL, CTX_MIME_ATACH, CTX_NONE, IT_NOFLAG);
        RegisterNamespace("MSG:NATTACH", 0, 0, get_registered_Attachments_Count,  NULL, CTX_NONE);
 
        /* mime renderers translate an attachment into webcit viewable html text */
@@ -1512,7 +1528,8 @@ InitModule_MSGRENDERERS
        RegisterMsgHdr(HKEY("time"), examine_time, 0);
        RegisterMsgHdr(HKEY("part"), examine_mime_part, 0);
        RegisterMsgHdr(HKEY("text"), examine_text, 1);
-       /* these are the content-type headers we get infront of a message; put it into the same hash since it doesn't clash. */
+
+       /* these are the content-type headers we get in front of a message; put it into the same hash since it doesn't clash. */
        RegisterMsgHdr(HKEY("X-Citadel-MSG4-Partnum"), examine_msg4_partnum, 0);
        RegisterMsgHdr(HKEY("Content-type"), examine_content_type, 0);
        RegisterMsgHdr(HKEY("Content-length"), examine_content_lengh, 0);
index 66afe5e12e87dd818c95a461d4371fa6f9ec6fc8..9f9f89c8cfce0edb927cf46206c15e77653efd20 100644 (file)
@@ -246,10 +246,10 @@ int GetConnected (void)
                                  "In order to run this version of WebCit "
                                  "you must also have Citadel %d.%02d or"
                                  " newer.\n\n\n"),
-                               WCC->serv_info->serv_rev_level / 100,
-                               WCC->serv_info->serv_rev_level % 100,
-                               MINIMUM_CIT_VERSION / 100,
-                               MINIMUM_CIT_VERSION % 100
+                               WCC->serv_info->serv_rev_level,
+                               0,
+                               MINIMUM_CIT_VERSION,
+                               0
                                );
                        hprintf("HTTP/1.1 200 OK\r\n");
                        hprintf("Content-type: text/plain; charset=utf-8\r\n");
index dbfad290b17d3fcc906ddccfd0619ffbe9ab8ca4..387ed69694c13f4575e4d280c3fa3bc65f31c378 100644 (file)
@@ -2,12 +2,8 @@
        <div class="blog_comment_header">
                <span class="blog_commenter_name">
                <??("COND:MAIL:ANON",1)>
-                       <?!("COND:MAIL:SUMM:RFCA", 2)>
-                               <a href="do_template?template=user_show?who=<?MAIL:SUMM:FROM("Q")>">"<?MAIL:SUMM:FROM("X")>" &lt;<?MAIL:SUMM:RFCA>&gt;</a>
-                       <?!("X", 2)>
-                       <??("COND:MAIL:SUMM:RFCA", 3)>
-                               <a href="do_template?template=user_show?who=<?MAIL:SUMM:FROM("Q")>"><?MAIL:SUMM:FROM("X")></a> 
-                       <??("X", 3)>
+                       <?!("COND:MAIL:LOCAL", 2)><a href="do_template?template=user_show?who=<?MAIL:SUMM:FROM("Q")>"><?MAIL:SUMM:FROM("X")></a><?!("X", 2)>
+                       <??("COND:MAIL:LOCAL", 2)><?MAIL:SUMM:FROM("X")> &lt;<?MAIL:SUMM:RFCA>&gt;</a><?!("X", 2)>
                <??("X", 1)>
                &nbsp;says:&nbsp;</span>
                <span class="blog_comment_date"><?MAIL:SUMM:DATEFULL></span>
index 2c6161c180dfd64acadb80f29cbca5d4f4c839fc..3053b160100ad374ee3cd4294720ef78165137a1 100644 (file)
        </div>
        <div class="blog_post_header">
                <span>Posted by <??("COND:MAIL:ANON",1)>
-                       <?!("COND:MAIL:SUMM:RFCA", 2)>
-                       <a href="showuser?who=<?MAIL:SUMM:FROM("Q")>">
-                               "<?MAIL:SUMM:FROM("X")>" &lt;<?MAIL:SUMM:RFCA>&gt;
-                       </a>
-                       <?!("X", 2)>
-                       <??("COND:MAIL:SUMM:RFCA", 3)>
-                       <a href="showuser?who=<?MAIL:SUMM:FROM("Q")>">
-                               <?MAIL:SUMM:FROM("X")>
-                       </a> 
-                       <??("X", 3)>
+                       <?!("COND:MAIL:LOCAL", 2)><a href="do_template?template=user_show?who=<?MAIL:SUMM:FROM("Q")>"><?MAIL:SUMM:FROM("X")></a><?!("X", 2)>
+                       <??("COND:MAIL:LOCAL", 2)><?MAIL:SUMM:FROM("X")> &lt;<?MAIL:SUMM:RFCA>&gt;</a><?!("X", 2)>
                <??("X", 1)></span>
                <span>on <?MAIL:SUMM:DATEFULL></span>
                <?!("COND:ROOM:EDITACCESS", 16)>
index 7e0af79a757189fea7ac45cad74122fdc73d7e62..458d17490a36077f45bc7af9bde0e744a13eaa23 100644 (file)
@@ -6,8 +6,8 @@
  <span><?MAIL:SUMM:DATEFULL></span>
  <?_("from ")>
  <??("COND:MAIL:ANON",1)>
-   <?!("COND:MAIL:SUMM:RFCA", 2)><a href="do_template?template=user_show?who=<?MAIL:SUMM:FROM("Q")>">"<?MAIL:SUMM:FROM("X")>" &lt;<?MAIL:SUMM:RFCA>&gt;</a><?!("X", 2)>
-   <??("COND:MAIL:SUMM:RFCA", 3)><a href="do_template?template=user_show?who=<?MAIL:SUMM:FROM("Q")>"><?MAIL:SUMM:FROM("X")></a><??("X", 3)>
+   <?!("COND:MAIL:LOCAL", 2)><a href="do_template?template=user_show?who=<?MAIL:SUMM:FROM("Q")>"><?MAIL:SUMM:FROM("X")></a><?!("X", 2)>
+   <??("COND:MAIL:LOCAL", 2)><?MAIL:SUMM:FROM("X")> &lt;<?MAIL:SUMM:RFCA>&gt;</a><?!("X", 2)>
  <??("X", 1)>
  <?!("COND:MAIL:ANON", 4)>****<??("X", 4)>
  <?!("COND:MAIL:TO", 5)><?_("to")> <?MAIL:SUMM:TO("X")><?!("X", 5)>
index 1cb721174162f205580386c6e878e59557c09377..ae051e2640ba34a96828d3efcdcd8e251514cca3 100644 (file)
@@ -7,8 +7,8 @@
  <span><?MAIL:SUMM:DATEFULL></span>
  <?_("from ")>
  <??("COND:MAIL:ANON",1)>
-<?!("COND:MAIL:SUMM:RFCA", 2)><?!("X", 2)>
-<??("COND:MAIL:SUMM:RFCA", 3)><??("X", 3)>
+       <?!("COND:MAIL:LOCAL", 2)><a href="do_template?template=user_show?who=<?MAIL:SUMM:FROM("Q")>"><?MAIL:SUMM:FROM("X")></a><?!("X", 2)>
+       <??("COND:MAIL:LOCAL", 2)><?MAIL:SUMM:FROM("X")> &lt;<?MAIL:SUMM:RFCA>&gt;</a><?!("X", 2)>
 <??("X", 1)>
  <?!("COND:MAIL:ANON", 4)>***<??("X", 4)>
  <?!("COND:MAIL:TO", 5)><?_("to")> <?MAIL:SUMM:TO("X")><?!("X", 5)><br>
index 0685aba7109e85fe4caca5a347b1ded009f2479f..58cda01cb15891c78d00eae5c6761733eb2bcce5 100644 (file)
@@ -1,8 +1,8 @@
 <blockquote> <div class="message_header"> <span><?MAIL:SUMM:DATEFULL></span> 
 <??("COND:MAIL:ANON",1)>
 <span><?_("from ")>
-<?!("COND:MAIL:SUMM:RFCA", 2)>"<?MAIL:SUMM:FROM("X")>" &lt;<?MAIL:SUMM:RFCA>&gt;<?!("X", 2)>
-<??("COND:MAIL:SUMM:RFCA", 3)><?MAIL:SUMM:FROM("X")><??("X", 3)>
+<?!("COND:MAIL:LOCAL", 2)><a href="do_template?template=user_show?who=<?MAIL:SUMM:FROM("Q")>"><?MAIL:SUMM:FROM("X")></a><?!("X", 2)>
+<??("COND:MAIL:LOCAL", 2)><?MAIL:SUMM:FROM("X")> &lt;<?MAIL:SUMM:RFCA>&gt;</a><?!("X", 2)>
 </span>
 <??("X", 1)><?!("COND:MAIL:ANON",5)><span><?_("from ")>***</span><??("X", 5)>
 <?!("COND:MAIL:SUBJ",6)><span class="message_subject"><?_("Subject:")> <?MAIL:SUMM:SUBJECT></span><?!("X", 6)>