GOTO no longer counts newly arrived mail in the inbox. BIFF now does this.
authorArt Cancro <ajc@citadel.org>
Wed, 23 Nov 2022 21:40:18 +0000 (16:40 -0500)
committerArt Cancro <ajc@citadel.org>
Wed, 23 Nov 2022 21:40:18 +0000 (16:40 -0500)
citadel/server/modules/ctdlproto/serv_user.c
citadel/server/room_ops.c
citadel/server/user_ops.c
textclient/citadel.c
textclient/citadel_ipc.c
textclient/textclient.h
webcit/roomops.c
webcit/roomops.h

index 3ee1e79bcbd9a8849626b540acf554f0905cbce2..aa560ee4d3b1382e2f579c38e6fbf4d41ed2cfff 100644 (file)
@@ -774,6 +774,11 @@ void cmd_lout(char *argbuf) {
 }
 
 
+void cmd_biff(char *argbuf) {                          // has new mail arrived?
+       cprintf("%d %d\n", CIT_OK, NewMailCount());
+}
+
+
 // Initialization function, called from modules_init.c
 char *ctdl_module_init_serv_user(void) {
        if (!threading) {
@@ -804,6 +809,7 @@ char *ctdl_module_init_serv_user(void) {
                CtdlRegisterProtoHook(cmd_renu, "RENU", "Rename a user");
                CtdlRegisterProtoHook(cmd_newu, "NEWU", "Log in as a new user");
                CtdlRegisterProtoHook(cmd_isme, "ISME", "Determine whether an email address belongs to a user");
+               CtdlRegisterProtoHook(cmd_biff, "BIFF", "Count new messages that have arrived in the inbox");
        }
        /* return our Subversion id for the Log */
        return "user";
index 53090b66c53ad0d88d4b2a0198aa91c98c4e6653..f9abe87785db6a740bbab734f08083c9859efff3 100644 (file)
@@ -33,12 +33,7 @@ int CtdlDoIHavePermissionToReadMessagesInThisRoom(void) {
 // Check to see whether we have permission to post a message in the current
 // room.  Returns a *CITADEL ERROR CODE* and puts a message in errmsgbuf, or
 // returns 0 on success.
-int CtdlDoIHavePermissionToPostInThisRoom(
-       char *errmsgbuf, 
-       size_t n, 
-       PostType PostPublic,
-       int is_reply
-) {
+int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf, size_t n, PostType PostPublic, int is_reply) {
        int ra;
 
        if (!(CC->logged_in) && (PostPublic == POST_LOGGED_IN)) {
@@ -620,9 +615,7 @@ int CtdlIsNonEditable(struct ctdlroom *qrbuf) {
 // Make the specified room the current room for this session.  No validation
 // or access control is done here -- the caller should make sure that the
 // specified room exists and is ok to access.
-void CtdlUserGoto(char *where, int display_result, int transiently,
-               int *retmsgs, int *retnew, long *retoldest, long *retnewest)
-{
+void CtdlUserGoto(char *where, int display_result, int transiently, int *retmsgs, int *retnew, long *retoldest, long *retnewest) {
        int a;
        int new_messages = 0;
        int old_messages = 0;
@@ -632,7 +625,6 @@ void CtdlUserGoto(char *where, int display_result, int transiently,
        int info = 0;
        int rmailflag;
        int raideflag;
-       int newmailcount = 0;
        visit vbuf;
        char truncated_roomname[ROOMNAMELEN];
         struct cdbdata *cdbfr;
@@ -680,9 +672,6 @@ void CtdlUserGoto(char *where, int display_result, int transiently,
        }
        end_critical_section(S_USERS);
 
-       // Check for new mail
-       newmailcount = NewMailCount();
-
        // Set info to 1 if the room banner is new since our last visit.
        // Some clients only want to display it when it changes.
        if (CC->room.msgnum_info > vbuf.v_lastseen) {
@@ -776,7 +765,7 @@ void CtdlUserGoto(char *where, int display_result, int transiently,
                        (long)vbuf.v_lastseen,
                        (int)rmailflag,
                        (int)raideflag,
-                       (int)newmailcount,
+                       0,                                      // new mail is no longer counted here
                        (int)CC->room.QRfloor,
                        (int)vbuf.v_view,
                        (int)CC->room.QRdefaultview,
index 62b11981cc625ac5b25df5c3d460ab2eed8a8d7e..d907074a4f88fb8367bbc3af755cc8a596f48ad1 100644 (file)
@@ -1118,7 +1118,8 @@ void ForEachUser(void (*CallBack) (char *, void *out_data), void *in_data) {
 }
 
 
-// Count the number of new mail messages the user has
+// Return the number of new messages that have arrived in the user's inbox while they were logged in.
+// Resets to zero when called.
 int NewMailCount() {
        int num_newmsgs = 0;
        num_newmsgs = CC->newmail;
index 6559ef8ebae4c56ebd822f505fff191e3e6386f6..c5133b40038d16743ce85c667ffe45df2b95b2b0 100644 (file)
@@ -262,7 +262,6 @@ char *pop_march(int desired_floor, struct march *_march) {
 void dotgoto(CtdlIPC * ipc, char *towhere, int display_name, int fromungoto) {
        char aaa[SIZ], bbb[SIZ];
        static long ls = 0L;
-       int newmailcount = 0;
        int partial_match, best_match;
        char from_floor;
        int ugpos = uglistsize;
@@ -405,8 +404,7 @@ void dotgoto(CtdlIPC * ipc, char *towhere, int display_name, int fromungoto) {
        if (room->RRinfoupdated > 0)
                readinfo(ipc);
 
-       /* check for newly arrived mail if we can */
-       newmailcount = room->RRnewmail;
+       /* check for newly arrived mail if we can   FIXME use BIFF command for this
        if (newmailcount > 0) {
                color(BRIGHT_RED);
                if (newmailcount == 1) {
@@ -422,12 +420,14 @@ void dotgoto(CtdlIPC * ipc, char *towhere, int display_name, int fromungoto) {
                                scr_printf("*** failed to check for mail calling %s Reason %d.\n", rc_gotmail_cmd, rv);
                }
        }
+       */
+
        free(room);
 
        if (screenwidth > 5)
                snprintf(&status_line[1], screenwidth - 1, "%s  |  %s  |  %s  |  %s  |  %d new mail  |",
                         (secure ? "Encrypted" : "Unencrypted"),
-                        ipc->ServInfo.humannode, ipc->ServInfo.site_location, room_name, newmailcount);
+                        ipc->ServInfo.humannode, ipc->ServInfo.site_location, room_name, 0);           // FIXME use BIFF
 }
 
 
index f4a5695b8ac6bc4950b0ea9b88d08176401aadfe..007f8410f254f1e79e9efd7edf2b58746175de60 100644 (file)
@@ -488,11 +488,11 @@ int CtdlIPCGotoRoom(CtdlIPC * ipc, const char *room, const char *passwd, struct
                rret[0]->RRlastread = extract_long(cret, 6);
                rret[0]->RRismailbox = extract_int(cret, 7);
                rret[0]->RRaide = extract_int(cret, 8);
-               rret[0]->RRnewmail = extract_long(cret, 9);
+               // position 9 is no longer used
                rret[0]->RRfloor = extract_int(cret, 10);
                rret[0]->RRcurrentview = extract_int(cret, 11);
                rret[0]->RRdefaultview = extract_int(cret, 12);
-               /* position 13 is a trash folder flag ... irrelevant in this client */
+               // position 13 is a trash folder flag ... irrelevant in this client
                rret[0]->RRflags2 = extract_int(cret, 14);
        }
        else {
index 6ad0e002f0d2313a09bddf69d5ac20d569771560..c8658c3fc3d08bb9825bf95724650dbe144a8ef8 100644 (file)
@@ -284,7 +284,6 @@ struct ctdlipcroom {
        long RRlastread;                /* Highest message user has read */
        char RRismailbox;               /* Is this room a mailbox room? */
        char RRaide;                    /* User can do aide commands in room */
-       long RRnewmail;                 /* Number of new mail messages */
        char RRfloor;                   /* Which floor this room is on */
        char RRcurrentview;             /* The user's current view for this room */
        char RRdefaultview;             /* The default view for this room */
index 059eadf8071d9739f961b505eb570263fea2d6b0..9d8699c066dc0b6a768bd950ff03ac031d4e7926 100644 (file)
@@ -273,7 +273,7 @@ void ParseGoto(folder *room, StrBuf *Line) {
                room->RAFlags |= UA_ADMINALLOWED;
        }
 
-       room->UsersNewMAilboxMessages = StrBufExtractNext_long(Line, &Pos, '|');
+       StrBufExtractNext_long(Line, &Pos, '|');                        // position 9 is unused
        room->floorid = StrBufExtractNext_int(Line, &Pos, '|');
        room->view = StrBufExtractNext_long(Line, &Pos, '|');
        room->defview = StrBufExtractNext_long(Line, &Pos, '|');
index fd1f60e4ae62686a1bf9606569bc96722cf73097..c29a10189f787f0750fa9def921044e698035660 100644 (file)
@@ -104,7 +104,6 @@ typedef struct _folder {
        long LastMessageRead;
        long HighestRead;
        int ShowInfo;
-       int UsersNewMAilboxMessages; /* should we notify the user about new messages? */
        int IsTrash;
 /* Only available if certain other commands ran */
        int XHaveRoomPic;