X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=textclient%2Fmessages.c;h=7fd9502df3831326b3c2afff2563fada38dc121b;hb=7427b76904be76426c2a84c9de80fa48a0e022c8;hp=67d656dbaef2a37e2284342abbe7a6855b911401;hpb=2ab397b00a1b34613748e3cf23503d4a9f7ada67;p=citadel.git diff --git a/textclient/messages.c b/textclient/messages.c index 67d656dba..7fd9502df 100644 --- a/textclient/messages.c +++ b/textclient/messages.c @@ -1,7 +1,7 @@ /* * Text client functions for reading and writing of messages * - * 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. @@ -390,10 +390,11 @@ void mini_2047_decode(char *s) /* * Read a message from the server */ -int read_message(CtdlIPC * ipc, long num, /* message number */ - int pagin, /* 0 = normal read, 1 = read with pagination, 2 = header */ - FILE * dest) -{ /* Destination file, NULL for screen */ +int read_message(CtdlIPC *ipc, + long num, /* message number */ + int pagin, /* 0 = normal read, 1 = read with pagination, 2 = header */ + FILE *dest /* Destination file, NULL for screen */ +) { char buf[SIZ]; char now[256]; int format_type = 0; @@ -409,6 +410,7 @@ int read_message(CtdlIPC * ipc, long num, /* message number */ char ch; int linelen; int final_line_is_blank = 0; + int is_local = 0; has_images = 0; @@ -432,7 +434,8 @@ int read_message(CtdlIPC * ipc, long num, /* message number */ if (dest) { fprintf(dest, "\n "); - } else { + } + else { scr_printf("\n"); if (pagin != 2) { scr_printf(" "); @@ -442,6 +445,18 @@ int read_message(CtdlIPC * ipc, long num, /* message number */ 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", @@ -452,8 +467,7 @@ int read_message(CtdlIPC * ipc, long num, /* message number */ if (!IsEmptyStr(message->email)) { scr_printf("rfca=%s\n", message->email); } - scr_printf("room=%s\ntime=%s", message->room, asctime(localtime(&message->time)) - ); + scr_printf("room=%s\ntime=%s", message->room, asctime(localtime(&message->time))); if (!IsEmptyStr(message->recipient)) { scr_printf("rcpt=%s\n", message->recipient); } @@ -488,26 +502,29 @@ int read_message(CtdlIPC * ipc, long num, /* message number */ if (nhdr == 1 && !is_room_aide) { if (dest) { fprintf(dest, " ****"); - } else { + } + else { scr_printf(" ****"); } - } else { + } + else { struct tm thetime; localtime_r(&message->time, &thetime); strftime(now, sizeof now, "%F %R", &thetime); if (dest) { fprintf(dest, "%s from %s ", now, message->author); - if (!IsEmptyStr(message->email)) { + if (!is_local) { fprintf(dest, "<%s> ", message->email); } - } else { + } + else { color(BRIGHT_CYAN); scr_printf("%s ", now); color(DIM_WHITE); scr_printf("from "); color(BRIGHT_CYAN); scr_printf("%s ", message->author); - if (!IsEmptyStr(message->email)) { + if (!is_local) { color(DIM_WHITE); scr_printf("<"); color(BRIGHT_BLUE); @@ -1050,7 +1067,21 @@ int entmsg(CtdlIPC * ipc, int is_reply, /* nonzero if this was a eply command int r; /* IPC response code */ int subject_required = 0; - if (!entmsg_ok) { + if (entmsg_ok == ENTMSG_OK_YES) { + /* no problem, go right ahead */ + } + else if (entmsg_ok == ENTMSG_OK_BLOG) { + if (!is_reply) { + scr_printf("WARNING: this is a BLOG room.\n"); + scr_printf("The 'nter Message' command will create a BLOG POST.\n"); + scr_printf("If you want to leave a comment or reply to a comment, use the 'eply' command.\n"); + scr_printf("Do you really want to create a new blog post? "); + if (!yesno()) { + return(1); + } + } + } + else { scr_printf("You may not enter messages in this type of room.\n"); return (1); }