From: Art Cancro Date: Sun, 13 Dec 2020 23:16:08 +0000 (-0500) Subject: Changed the display logic for message author. New conditional COND:MAIL:LOCAL which... X-Git-Tag: v939~195 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=fcf307e182caecb456f8eb86b292143db529d8d8 Changed the display logic for message author. New conditional COND:MAIL:LOCAL which activates if we believe a message originated locally. This currently only detects c_fqdn and we need to modify it to handle all local domains. If a message originated locally then we display the user name by itself with a link to their profile. If a message originated somewhere else we display the user name and email address. --- diff --git a/webcit/messages.h b/webcit/messages.h index 32a172a7b..872063170 100644 --- a/webcit/messages.h +++ b/webcit/messages.h @@ -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, diff --git a/webcit/msg_renderers.c b/webcit/msg_renderers.c index 4be851de3..7cb990271 100644 --- a/webcit/msg_renderers.c +++ b/webcit/msg_renderers.c @@ -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); diff --git a/webcit/serv_func.c b/webcit/serv_func.c index 66afe5e12..9f9f89c8c 100644 --- a/webcit/serv_func.c +++ b/webcit/serv_func.c @@ -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"); diff --git a/webcit/static/t/view_blog/comment.html b/webcit/static/t/view_blog/comment.html index dbfad290b..387ed6969 100644 --- a/webcit/static/t/view_blog/comment.html +++ b/webcit/static/t/view_blog/comment.html @@ -2,12 +2,8 @@
- - ">"" <> - - - "> - + "> + <>  says:  diff --git a/webcit/static/t/view_blog/post.html b/webcit/static/t/view_blog/post.html index 2c6161c18..3053b1601 100644 --- a/webcit/static/t/view_blog/post.html +++ b/webcit/static/t/view_blog/post.html @@ -15,16 +15,8 @@
Posted by - - "> - "" <> - - - - "> - - - + "> + <> on diff --git a/webcit/static/t/view_message.html b/webcit/static/t/view_message.html index 7e0af79a7..458d17490 100644 --- a/webcit/static/t/view_message.html +++ b/webcit/static/t/view_message.html @@ -6,8 +6,8 @@ - ">"" <> - "> + "> + <> **** diff --git a/webcit/static/t/view_message/print.html b/webcit/static/t/view_message/print.html index 1cb721174..ae051e264 100644 --- a/webcit/static/t/view_message/print.html +++ b/webcit/static/t/view_message/print.html @@ -7,8 +7,8 @@ - - + "> + <> ***
diff --git a/webcit/static/t/view_message/replyquote.html b/webcit/static/t/view_message/replyquote.html index 0685aba71..58cda01cb 100644 --- a/webcit/static/t/view_message/replyquote.html +++ b/webcit/static/t/view_message/replyquote.html @@ -1,8 +1,8 @@
-"" <> - +"> + <> ***