* Added the EUID command to search for a message by EUID
authorArt Cancro <ajc@citadel.org>
Thu, 6 Oct 2005 19:16:31 +0000 (19:16 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 6 Oct 2005 19:16:31 +0000 (19:16 +0000)
citadel/ChangeLog
citadel/citserver.c
citadel/euidindex.c
citadel/euidindex.h
citadel/techdoc/protocol.txt

index 2d814344206abbf749eb19bd9e1139f4a584e256..383dbe8c3bcd64d41a9e6cd04d85075f6a7a8264 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 655.24  2005/10/06 19:16:31  ajc
+* Added the EUID command to search for a message by EUID
+
 Revision 655.23  2005/10/06 17:14:41  ajc
 * newinstall.sh: prefer curl over wget
 
@@ -7208,4 +7211,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index a42fd088239ee9c97d094d7e57ac176c59552365..4e8e90143f3a456498832df8ea8710cddfb7935b 100644 (file)
@@ -58,6 +58,7 @@
 #include "policy.h"
 #include "control.h"
 #include "tools.h"
+#include "euidindex.h"
 
 #ifndef HAVE_SNPRINTF
 #include "snprintf.h"
@@ -1038,6 +1039,10 @@ void do_command_loop(void) {
                cmd_rdir();
        }
 
+       else if (!strncasecmp(cmdbuf,"EUID",4)) {
+               cmd_euid(&cmdbuf[5]);
+       }
+
        else if (!strncasecmp(cmdbuf,"MSG0",4)) {
                cmd_msg0(&cmdbuf[5]);
        }
index ef2cb27801ede963d47bd65bd31fc9948771be60..cada83ac7591476a300c2c23feba6cefec0d2948 100644 (file)
@@ -181,3 +181,25 @@ void rebuild_euid_index(void) {
        ForEachRoom(rebuild_euid_index_for_room, NULL); /* enumerate the room names */
        rebuild_euid_index_for_room(NULL, NULL);        /* now do indexing on them */
 }
+
+
+
+/*
+ * Server command to fetch a message number given an euid.
+ */
+void cmd_euid(char *cmdbuf) {
+       char euid[256];
+       long msgnum;
+
+       if (CtdlAccessCheck(ac_logged_in)) return;
+
+       extract_token(euid, cmdbuf, 0, '|', sizeof euid);
+       msgnum = locate_message_by_euid(euid, &CC->room);
+
+       if (msgnum > 0L) {
+               cprintf("%d %ld\n", CIT_OK, msgnum);
+       }
+       else {
+               cprintf("%d not found\n", ERROR + MESSAGE_NOT_FOUND);
+       }
+}
index d50ce16b00ab4dd45069f6a557da4064b28c7dcb..0072d525eb47c96fff662cf95c4d2e9695b954cc 100644 (file)
@@ -8,3 +8,5 @@
 long locate_message_by_euid(char *euid, struct ctdlroom *qrbuf);
 void index_message_by_euid(char *euid, struct ctdlroom *qrbuf, long msgnum);
 void rebuild_euid_index(void);
+void cmd_euid(char *cmdbuf);
+
index 9b6c11bcb0a032037944952244dcc3ea6b0c1b6c..cc17b6388e31aea2030deb3e4e25e60cd7d18559 100644 (file)
@@ -2215,6 +2215,25 @@ only in rooms to which the user does not have access.
  
  Again, keep in mind that this is a temporary implementation and is not
 guaranteed to continue to exist in this form.
+
+
+EUID   (get message number using an EUID)}
+
+ Returns the message number, if present, of the message in the current room
+which is indexed using the supplied EUID (exclusive message ID).  There can be
+only one message in a room with any given EUID; if another message arrives
+with the same EUID, the existing one is replaced.  This makes it possible to
+reference things like calendar items using an immutable URL that does not
+change even when the message number changes due to an update.
+
+ The format of this command is:  EUID <euid>
+
+ If successful, EUID returns OK followed by a message number.  The message is
+*not* guaranteed to exist, because EUID indices are not immediately removed
+when a message is deleted.
+ If no message exists in the current room with the supplied EUID, the command
+returns ERROR+MESSAGE_NOT_FOUND.
+