Handle display of local and nonlocal messages correctly in text client
authorArt Cancro <ajc@citadel.org>
Mon, 14 Dec 2020 05:53:48 +0000 (00:53 -0500)
committerArt Cancro <ajc@citadel.org>
Mon, 14 Dec 2020 05:53:48 +0000 (00:53 -0500)
textclient/citadel_ipc.c
textclient/messages.c
textclient/textclient.h

index 5f3656e..f9ebf8a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1987-2019 by the citadel.org team
+ * Copyright (c) 1987-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.
@@ -622,6 +622,7 @@ int CtdlIPCGetSingleMessage(CtdlIPC * ipc, long msgnum, int headers, int as_mime
 
        strcpy(encoding, "");
        strcpy(mret[0]->content_type, "");
+       mret[0]->is_local = 0;
        sprintf(aaa, "MSG%d %ld|%d", as_mime, msgnum, headers);
        ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, &bbb, &bbb_len, cret);
        if (ret / 100 == 1) {
@@ -651,6 +652,8 @@ int CtdlIPCGetSingleMessage(CtdlIPC * ipc, long msgnum, int headers, int as_mime
                                        safestrncpy(mret[0]->references, &aaa[5], SIZ);
                                else if (!strncasecmp(aaa, "time=", 5))
                                        mret[0]->time = atol(&aaa[5]);
+                               else if (!strncasecmp(aaa, "locl", 4))
+                                       mret[0]->is_local = 1;
 
                                /* Multipart/alternative prefix & suffix strings help
                                 * us to determine which part we want to download.
index 7fd9502..447c392 100644 (file)
@@ -410,8 +410,6 @@ int read_message(CtdlIPC *ipc,
        char ch;
        int linelen;
        int final_line_is_blank = 0;
-       int is_local = 0;
-
        has_images = 0;
 
        sigcaught = 0;
@@ -445,18 +443,6 @@ int read_message(CtdlIPC *ipc,
                color(BRIGHT_CYAN);
        }
 
-       /* Determine if the message originated here on the local system.  If it did we will suppress printing of email addresses */
-       is_local = 0;
-       char *at = !IsEmptyStr(message->email) ? strchr(message->email,'@') : NULL;
-       if (at) {
-               if (!strcasecmp(++at, ipc->ServInfo.fqdn)) {
-                       is_local = 1;
-               }
-       }
-       else {
-               is_local = 1;           // no address means it couldn't have originated anywhere else
-       }
-
        /* View headers only */
        if (pagin == 2) {
                scr_printf("nhdr=%s\nfrom=%s\ntype=%d\nmsgn=%s\n",
@@ -513,7 +499,7 @@ int read_message(CtdlIPC *ipc,
                strftime(now, sizeof now, "%F %R", &thetime);
                if (dest) {
                        fprintf(dest, "%s from %s ", now, message->author);
-                       if (!is_local) {
+                       if (!message->is_local) {
                                fprintf(dest, "<%s> ", message->email);
                        }
                }
@@ -524,7 +510,7 @@ int read_message(CtdlIPC *ipc,
                        scr_printf("from ");
                        color(BRIGHT_CYAN);
                        scr_printf("%s ", message->author);
-                       if (!is_local) {
+                       if (!message->is_local) {
                                color(DIM_WHITE);
                                scr_printf("<");
                                color(BRIGHT_BLUE);
index a945db1..4a3fc29 100644 (file)
@@ -335,6 +335,7 @@ struct ctdlipcmessage {
        char mime_chosen[SIZ];          /* Chosen MIME part to output */
        char content_type[SIZ];         /* How would you like that? */
        char references[SIZ];           /* Thread references */
+       int is_local;                   /* Nonzero if the message originated on the local system */
 };