From 02dfed8773bf1411ee1f32242b62e74fc16588ec Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 4 Jun 2000 02:30:59 +0000 Subject: [PATCH] * CtdlForEachMessage() now returns the number of messages processed. It also accepts the MSGS_EQ mode, for targeting a specific message number (useful for determining whether the specified message actually exists in a room). * Completed the server side of the moderation system (serv_moderate.c module which implements the MMOD command) --- citadel/ChangeLog | 8 +++++++- citadel/msgbase.c | 12 ++++++++---- citadel/msgbase.h | 3 ++- citadel/serv_moderate.c | 19 +++++++++++++++++-- citadel/techdoc/session.txt | 12 ++++++++++++ 5 files changed, 46 insertions(+), 8 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index fd655c359..6cd3344dd 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,11 @@ $Log$ + Revision 572.4 2000/06/04 02:30:56 ajc + * CtdlForEachMessage() now returns the number of messages processed. It also + accepts the MSGS_EQ mode, for targeting a specific message number (useful for + determining whether the specified message actually exists in a room). + * Completed the server side of the moderation system (serv_moderate.c module + which implements the MMOD command) + Revision 572.3 2000/06/03 05:47:57 ajc * Replaced most of the very repetitive and very redundant access level checks in most commands with a single API call: CtdlAccessLevelCheck() @@ -1899,4 +1906,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 1b819f8e8..8b3fac01d 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -265,9 +265,9 @@ int CtdlMsgCmp(struct CtdlMessage *msg, struct CtdlMessage *template) { /* * API function to perform an operation for each qualifying message in the - * current room. + * current room. (Returns the number of messages processed.) */ -void CtdlForEachMessage(int mode, long ref, +int CtdlForEachMessage(int mode, long ref, int moderation_level, char *content_type, struct CtdlMessage *compare, @@ -279,6 +279,7 @@ void CtdlForEachMessage(int mode, long ref, struct cdbdata *cdbfr; long *msglist = NULL; int num_msgs = 0; + int num_processed = 0; long thismsg; struct SuppMsgInfo smi; struct CtdlMessage *msg; @@ -296,7 +297,7 @@ void CtdlForEachMessage(int mode, long ref, num_msgs = cdbfr->len / sizeof(long); cdb_free(cdbfr); } else { - return; /* No messages at all? No further action. */ + return 0; /* No messages at all? No further action. */ } @@ -358,12 +359,15 @@ void CtdlForEachMessage(int mode, long ref, || ((mode == MSGS_LAST) && (a >= (num_msgs - ref))) || ((mode == MSGS_FIRST) && (a < ref)) || ((mode == MSGS_GT) && (thismsg > ref)) + || ((mode == MSGS_EQ) && (thismsg == ref)) ) ) { - CallBack(thismsg); + if (CallBack) CallBack(thismsg); + ++num_processed; } } phree(msglist); /* Clean up */ + return num_processed; } diff --git a/citadel/msgbase.h b/citadel/msgbase.h index 90be1d3af..8daaaec72 100644 --- a/citadel/msgbase.h +++ b/citadel/msgbase.h @@ -8,6 +8,7 @@ #define MSGS_FIRST 3 #define MSGS_LAST 4 #define MSGS_GT 5 +#define MSGS_EQ 6 /* * Flags which may be passed to CtdlSaveMsgPointerInRoom() @@ -70,7 +71,7 @@ void PutSuppMsgInfo(struct SuppMsgInfo *); void AdjRefCount(long, int); void simple_listing(long); int CtdlMsgCmp(struct CtdlMessage *msg, struct CtdlMessage *template); -void CtdlForEachMessage(int mode, long ref, +int CtdlForEachMessage(int mode, long ref, int moderation_level, char *content_type, struct CtdlMessage *compare, diff --git a/citadel/serv_moderate.c b/citadel/serv_moderate.c index c9e08c7d2..efa9b97ac 100644 --- a/citadel/serv_moderate.c +++ b/citadel/serv_moderate.c @@ -41,6 +41,8 @@ void cmd_mmod(char *argbuf) { long msgnum; int newlevel; + struct SuppMsgInfo smi; + int is_message_in_room; /* user must be at least a Room Aide to moderate */ if (CtdlAccessCheck(ac_room_aide)) return; @@ -50,10 +52,23 @@ void cmd_mmod(char *argbuf) { if ( (newlevel < (-63)) || (newlevel > (+63)) ) { cprintf("%d %d is not a valid moderation level.\n", - newlevel, ERROR+ILLEGAL_VALUE); + ERROR+ILLEGAL_VALUE, newlevel); + return; } - cprintf("%d FIXME ... actually do this!!!!!!!!\n", OK); + is_message_in_room = CtdlForEachMessage(MSGS_EQ, msgnum, (-127), + NULL, NULL, NULL); + if (!is_message_in_room) { + cprintf("%d Message %ld is not in this room.\n", + ERROR+ILLEGAL_VALUE, msgnum); + return; + } + + GetSuppMsgInfo(&smi, msgnum); + smi.smi_mod = newlevel; + PutSuppMsgInfo(&smi); + + cprintf("%d Message %ld is moderated to %d\n", OK, msgnum, newlevel); } diff --git a/citadel/techdoc/session.txt b/citadel/techdoc/session.txt index a0354843e..fcecb3d82 100644 --- a/citadel/techdoc/session.txt +++ b/citadel/techdoc/session.txt @@ -1803,4 +1803,16 @@ Any value other than 0 or 1 will not change the flag, only report its state. The command returns ERROR if it fails; otherwise, it returns OK followed by a number representing the current state of the flag. + + MMOD (MODerate a Message) + + Set or change the moderation level of a message. The two parameters passed +to this command should be the message number and the desired moderation level. +Please refer to the "moderation.txt" document for a description of some +commonly used moderation levels. + If the command succeeds, OK is returned. If the specified message does not +exist in the current room, or if the specified moderation level is not within +acceptable limits, ERROR+ILLEGAL_VALUE is returned. This command requires at +least Room Aide access; if the calling user is not an Aide, or a Room Aide for +the current room, ERROR+HIGHER_ACCESS_REQUIRED is returned. -- 2.39.2