Removed the MESSAGE_IN_ROOM sections in order to make way for a faster algorithm.
authorArt Cancro <ajc@citadel.org>
Wed, 26 Jan 2011 21:18:22 +0000 (16:18 -0500)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 12:49:13 +0000 (12:49 +0000)
citadel/msgbase.c

index 5ec0801d20038b45cd3f2b3ebc768081bb99452b..ec76c0aed117594c1d11a4bded9d489007fc41b5 100644 (file)
@@ -1125,49 +1125,6 @@ void mime_spew_section(char *name, char *filename, char *partnum, char *disp,
        }
 }
 
-#ifdef MESSAGE_IN_ROOM
-/*
- * Check if a message is in the current room.
- * This is used by CtdlFetchMessage to prevent random picking
- * of messages from users private rooms
- *
- * The message list should probably be cached against the CC->room
- */
-int CtdlMessageInRoom(long msgnum)
-{
-       visit vbuf;
-       struct cdbdata *cdbfr;
-
-       /* Learn about the user and room in question */
-       CtdlGetUser(&CC->user, CC->curr_user);
-       CtdlGetRelationship(&vbuf, &CC->user, &CC->room);
-
-       /* Load the message list */
-       cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long));
-       if (cdbfr != NULL) {
-               long *msglist = NULL;
-               int num_msgs = 0;
-               int i;
-               int r = 0;
-               
-               msglist = (long *) cdbfr->ptr;
-               num_msgs = cdbfr->len / sizeof(long);
-
-               /* search for message msgnum */
-               for (i=0; i<num_msgs; i++) {
-                       if (msglist[i] == msgnum) {
-                               r = 1;
-                               break;
-                       }       
-               }
-
-               cdb_free(cdbfr);
-               return r;
-       } else {
-               return 0;
-       }
-}
-#endif
 
 /*
  * Load a message from disk into memory.
@@ -1186,14 +1143,6 @@ struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body)
        cit_uint8_t field_header;
 
        syslog(LOG_DEBUG, "CtdlFetchMessage(%ld, %d)\n", msgnum, with_body);
-
-#ifdef MESSAGE_IN_ROOM
-       if (!CtdlMessageInRoom(msgnum)) {
-               syslog(LOG_DEBUG, "Message %ld not in current room\n", msgnum);
-               return NULL;
-       }
-#endif
-
        dmsgtext = cdb_fetch(CDB_MSGMAIN, &msgnum, sizeof(long));
        if (dmsgtext == NULL) {
                return NULL;
@@ -1633,15 +1582,6 @@ int CtdlOutputMsg(long msg_num,          /* message number (local) to fetch */
                return(r);
        }
 
-#ifdef MESSAGE_IN_ROOM
-       if (!CtdlMessageInRoom(msg_num)) {
-               syslog(LOG_DEBUG, "Message %ld not in current room\n", msg_num);
-               if (do_proto) cprintf("%d Can't locate msg %ld in room\n",
-                       ERROR + MESSAGE_NOT_FOUND, msg_num);
-               return(om_no_such_msg);
-       }
-#endif
-
        /*
         * Fetch the message from disk.  If we're in HEADERS_FAST mode,
         * request that we don't even bother loading the body into memory.