msgbase.c: upgrade CtdlSetSeen() to the new CtdlGetMsgList() API
authorArt Cancro <ajc@citadel.org>
Wed, 16 Aug 2023 18:14:58 +0000 (09:14 -0900)
committerArt Cancro <ajc@citadel.org>
Wed, 16 Aug 2023 18:14:58 +0000 (09:14 -0900)
citadel/server/msgbase.c

index 9b4f2535f73b404bca384fd5178be5c526ed57b3..d6dc230f8c4d7dfe6a5a628ee6961b6701637afb 100644 (file)
@@ -404,7 +404,6 @@ void CtdlGetSeen(char *buf, int which_set) {
 void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
                int target_setting, int which_set,
                struct ctdluser *which_user, struct ctdlroom *which_room) {
-       struct cdbdata *cdbfr;
        int i, k;
        int is_seen = 0;
        int was_seen = 0;
@@ -445,17 +444,14 @@ void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
        CtdlGetRelationship(&vbuf, which_user, which_room);
 
        // Load the message list
-       cdbfr = cdb_fetch(CDB_MSGLISTS, &which_room->QRnumber, sizeof(long));
-       if (cdbfr != NULL) {
-               msglist = (long *) cdbfr->ptr;
-               cdbfr->ptr = NULL;      // CtdlSetSeen() now owns this memory (this needs attention if we move to LMDB)
-               num_msgs = cdbfr->len / sizeof(long);
-               cdb_free(cdbfr);
-       }
-       else {
-               return; // No messages at all?  No further action.
+       num_msgs = CtdlFetchMsgList(which_room->QRnumber, &msglist);
+       if (num_msgs <= 0) {
+               if (msglist != NULL) {
+                       free(msglist);
+               }
+               return;
        }
-
+       
        is_set = malloc(num_msgs * sizeof(char));
        memset(is_set, 0, (num_msgs * sizeof(char)) );
 
@@ -471,18 +467,6 @@ void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
                vset = NewStrBuf();
        }
 
-
-#if 0  // This is a special diagnostic section.  Do not allow it to run during normal operation.
-       syslog(LOG_DEBUG, "There are %d messages in the room.\n", num_msgs);
-       for (i=0; i<num_msgs; ++i) {
-               if ((i > 0) && (msglist[i] <= msglist[i-1])) abort();
-       }
-       syslog(LOG_DEBUG, "We are twiddling %d of them.\n", num_target_msgnums);
-       for (k=0; k<num_target_msgnums; ++k) {
-               if ((k > 0) && (target_msgnums[k] <= target_msgnums[k-1])) abort();
-       }
-#endif
-
        // Translate the existing sequence set into an array of booleans
        setstr = NewStrBuf();
        lostr = NewStrBuf();