From d1c43a6b9f20d1ba2d8581a90fcc1ea825b9bec8 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 16 Aug 2023 09:14:58 -0900 Subject: [PATCH] msgbase.c: upgrade CtdlSetSeen() to the new CtdlGetMsgList() API --- citadel/server/msgbase.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/citadel/server/msgbase.c b/citadel/server/msgbase.c index 9b4f2535f..d6dc230f8 100644 --- a/citadel/server/msgbase.c +++ b/citadel/server/msgbase.c @@ -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 0) && (msglist[i] <= msglist[i-1])) abort(); - } - syslog(LOG_DEBUG, "We are twiddling %d of them.\n", num_target_msgnums); - for (k=0; 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(); -- 2.39.2