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;
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)) );
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();