/*
* Manipulate the "seen msgs" string (or other message set strings)
*/
-void CtdlSetSeen(long target_msgnum, int target_setting, 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, j;
+ int i, j, k;
int is_seen = 0;
int was_seen = 0;
long lo = (-1L);
char setstr[SIZ], lostr[SIZ], histr[SIZ];
size_t tmp;
- lprintf(CTDL_DEBUG, "CtdlSetSeen(%ld, %d, %d)\n",
- target_msgnum, target_setting, which_set);
+ lprintf(CTDL_DEBUG, "CtdlSetSeen(%d msgs starting with %ld, %d, %d)\n",
+ num_target_msgnums, target_msgnums[0],
+ target_setting, which_set);
/* Learn about the user and room in question */
CtdlGetRelationship(&vbuf,
hi = (-1L);
for (i=0; i<num_msgs; ++i) {
- is_seen = 0;
- if (msglist[i] == target_msgnum) {
- is_seen = target_setting;
- }
- else {
- is_seen = is_set[i];
+ is_seen = is_set[i]; /* Default to existing setting */
+
+ for (k=0; k<num_target_msgnums; ++k) {
+ if (msglist[i] == target_msgnums[k]) {
+ is_seen = target_setting;
+ }
}
if (is_seen) {
msgid = extract_long(cmdbuf, 0);
extract_token(desired_section, cmdbuf, 1, '|', sizeof desired_section);
- safestrncpy(CC->download_desired_section, desired_section, sizeof CC->download_desired_section);
+ safestrncpy(CC->download_desired_section, desired_section,
+ sizeof CC->download_desired_section);
CtdlOutputMsg(msgid, MT_DOWNLOAD, 0, 1, 1);
}
long highest_msg = 0L;
struct CtdlMessage *msg = NULL;
- lprintf(CTDL_DEBUG, "CtdlSaveMsgPointerInRoom(roomname=%s, msgid=%ld, do_repl_check=%d)\n",
- roomname, msgid, do_repl_check);
+ /*lprintf(CTDL_DEBUG,
+ "CtdlSaveMsgPointerInRoom(room=%s, msgid=%ld, repl=%d)\n",
+ roomname, msgid, do_repl_check);*/
strcpy(hold_rm, CC->room.QRname);
/* Perform replication checks if necessary */
if ( (do_repl_check) && (msg != NULL) ) {
-
if (getroom(&CC->room,
((roomname != NULL) ? roomname : CC->room.QRname) )
!= 0) {
lprintf(CTDL_ERR, "No such room <%s>\n", roomname);
- if ( (msg != NULL) && (msg != supplied_msg) ) CtdlFreeMessage(msg);
+ if ( (msg != NULL) && (msg != supplied_msg) ) {
+ CtdlFreeMessage(msg);
+ }
return(ERROR + ROOM_NOT_FOUND);
}
((roomname != NULL) ? roomname : CC->room.QRname) )
!= 0) {
lprintf(CTDL_ERR, "No such room <%s>\n", roomname);
- if ( (msg != NULL) && (msg != supplied_msg) ) CtdlFreeMessage(msg);
+ if ( (msg != NULL) && (msg != supplied_msg) ) {
+ CtdlFreeMessage(msg);
+ }
return(ERROR + ROOM_NOT_FOUND);
}
num_msgs = 0;
} else {
msglist = malloc(cdbfr->len);
- if (msglist == NULL)
+ if (msglist == NULL) {
lprintf(CTDL_ALERT, "ERROR malloc msglist!\n");
+ }
num_msgs = cdbfr->len / sizeof(long);
memcpy(msglist, cdbfr->ptr, cdbfr->len);
cdb_free(cdbfr);
if (msglist[i] == msgid) {
lputroom(&CC->room); /* unlock the room */
getroom(&CC->room, hold_rm);
- if ( (msg != NULL) && (msg != supplied_msg) ) CtdlFreeMessage(msg);
+ if ( (msg != NULL) && (msg != supplied_msg) ) {
+ CtdlFreeMessage(msg);
+ }
free(msglist);
return(ERROR + ALREADY_EXISTS);
}
/* If the message has an Exclusive ID, index that... */
if (msg != NULL) {
if (msg->cm_fields['E'] != NULL) {
- index_message_by_euid(msg->cm_fields['E'], &CC->room, msgid);
+ index_message_by_euid(msg->cm_fields['E'],
+ &CC->room, msgid);
}
}
AdjRefCount(msgid, +1);
/* Return success. */
- if ( (msg != NULL) && (msg != supplied_msg) ) CtdlFreeMessage(msg);
+ if ( (msg != NULL) && (msg != supplied_msg) ) {
+ CtdlFreeMessage(msg);
+ }
return (0);
}
void ReplicationChecks(struct CtdlMessage *msg) {
long old_msgnum = (-1L);
+ if (DoesThisRoomNeedEuidIndexing(&CC->room) == 0) return;
+
+ lprintf(CTDL_DEBUG, "Performing replication checks in <%s>\n",
+ CC->room.QRname);
+
/* No exclusive id? Don't do anything. */
if (msg == NULL) return;
if (msg->cm_fields['E'] == NULL) return;
if (strlen(msg->cm_fields['E']) == 0) return;
- lprintf(CTDL_DEBUG, "Exclusive ID: <%s> for room <%s>\n",
- msg->cm_fields['E'], CC->room.QRname);
+ /*lprintf(CTDL_DEBUG, "Exclusive ID: <%s> for room <%s>\n",
+ msg->cm_fields['E'], CC->room.QRname);*/
old_msgnum = locate_message_by_euid(msg->cm_fields['E'], &CC->room);
if (old_msgnum > 0L) {
* giving it one, right now.
*/
if (msg->cm_fields['T'] == NULL) {
- lprintf(CTDL_DEBUG, "Generating timestamp\n");
snprintf(generated_timestamp, sizeof generated_timestamp, "%ld", (long)time(NULL));
msg->cm_fields['T'] = strdup(generated_timestamp);
}
/* If this message has no path, we generate one.
*/
if (msg->cm_fields['P'] == NULL) {
- lprintf(CTDL_DEBUG, "Generating path\n");
if (msg->cm_fields['A'] != NULL) {
msg->cm_fields['P'] = strdup(msg->cm_fields['A']);
for (a=0; a<strlen(msg->cm_fields['P']); ++a) {
}
/* Learn about what's inside, because it's what's inside that counts */
- lprintf(CTDL_DEBUG, "Learning what's inside\n");
if (msg->cm_fields['M'] == NULL) {
lprintf(CTDL_ERR, "ERROR: attempt to save message with NULL body\n");
return(-2);
}
/* Goto the correct room */
- lprintf(CTDL_DEBUG, "Selected room %s\n",
- (recps) ? CC->room.QRname : SENTITEMS);
+ lprintf(CTDL_DEBUG, "Selected room %s\n", (recps) ? CC->room.QRname : SENTITEMS);
strcpy(hold_rm, CC->room.QRname);
strcpy(actual_rm, CC->room.QRname);
if (recps != NULL) {
}
/* If the user is a twit, move to the twit room for posting */
- lprintf(CTDL_DEBUG, "Handling twit stuff: %s\n",
- (CC->user.axlevel == 2) ? config.c_twitroom : "OK");
if (TWITDETECT) {
if (CC->user.axlevel == 2) {
strcpy(hold_rm, actual_rm);
strcpy(actual_rm, config.c_twitroom);
+ lprintf(CTDL_DEBUG, "Diverting to twit room\n");
}
}
lprintf(CTDL_DEBUG, "Performing before-save hooks\n");
if (PerformMessageHooks(msg, EVT_BEFORESAVE) > 0) return(-3);
- /* If this message has an Exclusive ID, perform replication checks */
- lprintf(CTDL_DEBUG, "Performing replication checks\n");
- ReplicationChecks(msg);
+ /*
+ * If this message has an Exclusive ID, and the room is replication
+ * checking enabled, then do replication checks.
+ */
+ if (DoesThisRoomNeedEuidIndexing(&CC->room)) {
+ ReplicationChecks(msg);
+ }
/* Save it to disk */
lprintf(CTDL_DEBUG, "Saving to disk\n");