- char *wwm = "9999999999.WikiWaybackMachine";
- CtdlCreateRoom(wwm, 5, "", 0, 1, 1, VIEW_BBS);
- msgnum = CtdlSubmitMsg(msg, NULL, wwm, 0); /* FIXME put somewhere else */
- CtdlFreeMessage(msg);
- cprintf("%d %ld\n", CIT_OK, msgnum);
- }
- else if (!strcasecmp(operation, "revert")) {
- cprintf("%d FIXME not finished yet, check the log to find out wtf\n", ERROR);
+ if (len <= 0) {
+ msgnum = (-1L);
+ }
+ else if (!strcasecmp(operation, "fetch")) {
+ CM_SetField(msg, eAuthor, HKEY("Citadel"));
+ CtdlCreateRoom(wwm, 5, "", 0, 1, 1, VIEW_BBS); /* Not an error if already exists */
+ msgnum = CtdlSubmitMsg(msg, NULL, wwm); /* Store the revision here */
+
+ /*
+ * WARNING: VILE SLEAZY HACK
+ * This will avoid the 'message xxx is not in this room' security error,
+ * but only if the client fetches the message we just generated immediately
+ * without first trying to perform other fetch operations.
+ */
+ if (CCC->cached_msglist != NULL) {
+ free(CCC->cached_msglist);
+ CCC->cached_msglist = NULL;
+ CCC->cached_num_msgs = 0;
+ }
+ CCC->cached_msglist = malloc(sizeof(long));
+ if (CCC->cached_msglist != NULL) {
+ CCC->cached_num_msgs = 1;
+ CCC->cached_msglist[0] = msgnum;
+ }
+
+ }
+ else if (!strcasecmp(operation, "revert")) {
+ CM_SetFieldLONG(msg, eTimestamp, time(NULL));
+ if (!IsEmptyStr(CCC->user.fullname)) {
+ CM_SetField(msg, eAuthor, CCC->user.fullname, strlen(CCC->user.fullname));
+ }
+
+ if (!IsEmptyStr(CCC->cs_inet_email)) {
+ CM_SetField(msg, erFc822Addr, CCC->cs_inet_email, strlen(CCC->cs_inet_email));
+ }
+
+ if (!IsEmptyStr(CCC->room.QRname)) {
+ CM_SetField(msg, eOriginalRoom, CCC->room.QRname, strlen(CCC->room.QRname));
+ }
+
+ if (!IsEmptyStr(pagename)) {
+ CM_SetField(msg, eExclusiveID, pagename, strlen(pagename));
+ }
+ msgnum = CtdlSubmitMsg(msg, NULL, ""); /* Replace the current revision */
+ }
+ else {
+ /* Theoretically it is impossible to get here, but throw an error anyway */
+ msgnum = (-1L);
+ }
+ CM_Free(msg);
+ if (msgnum >= 0L) {
+ cprintf("%d %ld\n", CIT_OK, msgnum); /* Give the client a msgnum */
+ }
+ else {
+ cprintf("%d Error %ld has occurred.\n", ERROR+INTERNAL_ERROR, msgnum);
+ }