]> code.citadel.org Git - citadel.git/commitdiff
/ctdl/r/<room_name>/info.txt now fetches the room info banner
authorArt Cancro <ajc@citadel.org>
Thu, 27 Jan 2022 23:41:18 +0000 (18:41 -0500)
committerArt Cancro <ajc@citadel.org>
Thu, 27 Jan 2022 23:41:18 +0000 (18:41 -0500)
webcit-ng/README.txt
webcit-ng/api.txt
webcit-ng/room_functions.c

index 3d8f60355987f48336be2b4b93492cc4a5eac352..56b320021995f83c8160968f57b0f0d07465f6d0 100644 (file)
@@ -4,8 +4,7 @@ This is WebCit-NG, a complete refactoring of the WebCit server that will
 focus on "REST first" and build around that.  The code will be well
 layered with as little spaghetti as possible.
 
 focus on "REST first" and build around that.  The code will be well
 layered with as little spaghetti as possible.
 
-Please don't mess with this yet.  I'm only pushing it upstream so it gets
-backed up.
+Please don't mess with this yet.  I'm only pushing it upstream so it gets backed up.
 
 
 DESIGN GOALS:
 
 
 DESIGN GOALS:
@@ -16,6 +15,7 @@ DESIGN GOALS:
 *      Require NO cleanup.   Killing the process lets the OS reclaim all resources.
 
 *      As much as possible, resources should be freed by just coming back down the stack.
 *      Require NO cleanup.   Killing the process lets the OS reclaim all resources.
 
 *      As much as possible, resources should be freed by just coming back down the stack.
+       Avoid global variables and thread-local variables as much as possible.
 
 *      Readability of the code is more important than shaving off a few CPU cycles.
 
 
 *      Readability of the code is more important than shaving off a few CPU cycles.
 
index e2cab0b5ed667491a46b864663c6ffcbb4603d00..ca344ff521c5e3594622ff42d5d86835ef59122d 100644 (file)
@@ -13,6 +13,7 @@ GET           /ctdl/r/ROOMNAME/MSGNUM         Retrieve the content of an individual message
                                                (Should we output RFC822 fields as HTTP headers?  Decide soon...)
 PUT            /ctdl/r/ROOMNAME/xxx            DAV operation to insert a new message into a room
                                                (The returned ETag will be the new message number)
                                                (Should we output RFC822 fields as HTTP headers?  Decide soon...)
 PUT            /ctdl/r/ROOMNAME/xxx            DAV operation to insert a new message into a room
                                                (The returned ETag will be the new message number)
+GET            /ctdl/r/ROOMNAME/info.txt       Returns the room info banner for this room
 GET            /ctdl/r/ROOMNAME/MSGNUM/json    Retrieve an individual message in a room, encapsulated in JSON
 GET            /ctdl/c/info                    Returns a JSON representation of the output of an INFO server command
 POST           /ctdl/a/login                   Send it a your credentials and it will log you in
 GET            /ctdl/r/ROOMNAME/MSGNUM/json    Retrieve an individual message in a room, encapsulated in JSON
 GET            /ctdl/c/info                    Returns a JSON representation of the output of an INFO server command
 POST           /ctdl/a/login                   Send it a your credentials and it will log you in
index 26f35ef5eafabe56c33d973a597f3dcec1aeae53..14fc60413bc0a43aa10768f39f441bb608c9fa15 100644 (file)
@@ -106,6 +106,30 @@ void json_msglist(struct http_transaction *h, struct ctdlsession *c, char *which
 }
 
 
 }
 
 
+// Client is requesting the room info banner
+void read_room_info_banner(struct http_transaction *h, struct ctdlsession *c) {
+       char buf[1024];
+
+       ctdl_printf(c, "RINF");
+       ctdl_readline(c, buf, sizeof(buf));
+       if (buf[0] == '1') {
+               StrBuf *info = NewStrBuf();
+               while (ctdl_readline(c, buf, sizeof(buf)), (strcmp(buf, "000"))){
+                       StrBufAppendPrintf(info, "%s\n", buf);
+               }
+               add_response_header(h, strdup("Content-type"), strdup("text/plain"));
+               h->response_code = 200;
+               h->response_string = strdup("OK");
+               h->response_body_length = StrLength(info);
+               h->response_body = SmashStrBuf(&info);
+               return;
+       }
+       else {
+               do_404(h);
+       }
+}
+
+
 // Client requested an object in a room.
 void object_in_room(struct http_transaction *h, struct ctdlsession *c) {
        char buf[1024];
 // Client requested an object in a room.
 void object_in_room(struct http_transaction *h, struct ctdlsession *c) {
        char buf[1024];
@@ -114,32 +138,28 @@ void object_in_room(struct http_transaction *h, struct ctdlsession *c) {
 
        extract_token(buf, h->url, 4, '/', sizeof buf);
 
 
        extract_token(buf, h->url, 4, '/', sizeof buf);
 
-       if (!strncasecmp(buf, "msgs.", 5)) {    // Client is requesting a list of message numbers
+       if (!strncasecmp(buf, "msgs.", 5)) {            // Client is requesting a list of message numbers
                unescape_input(&buf[5]);
                json_msglist(h, c, &buf[5]);
                return;
        }
                unescape_input(&buf[5]);
                json_msglist(h, c, &buf[5]);
                return;
        }
-#if 0
-       if (!strncasecmp(buf, "threads", 5)) {  // Client is requesting a threaded view (still kind of fuzzy here)
-               threaded_view(h, c, &buf[5]);
-               return;
-       }
 
 
-       if (!strncasecmp(buf, "flat", 5)) {     // Client is requesting a flat view (still kind of fuzzy here)
-               flat_view(h, c, &buf[5]);
+       if (!strcasecmp(buf, "info.txt")) {             // Client is requesting the room info banner
+               read_room_info_banner(h, c);
                return;
        }
                return;
        }
-#endif
+
+       // If we get to this point, the client is requesting a specific object *in* the room.
 
        if ((c->room_default_view == VIEW_CALENDAR)     // room types where objects are referenced by EUID
 
        if ((c->room_default_view == VIEW_CALENDAR)     // room types where objects are referenced by EUID
-           || (c->room_default_view == VIEW_TASKS)
-           || (c->room_default_view == VIEW_ADDRESSBOOK)
-           ) {
+          || (c->room_default_view == VIEW_TASKS)
+          || (c->room_default_view == VIEW_ADDRESSBOOK)
+          ) {
                safestrncpy(unescaped_euid, buf, sizeof unescaped_euid);
                unescape_input(unescaped_euid);
                msgnum = locate_message_by_uid(c, unescaped_euid);
        }
                safestrncpy(unescaped_euid, buf, sizeof unescaped_euid);
                unescape_input(unescaped_euid);
                msgnum = locate_message_by_uid(c, unescaped_euid);
        }
-       else {
+       else {                                          // otherwise the object is being referenced by message number
                msgnum = atol(buf);
        }
 
                msgnum = atol(buf);
        }
 
@@ -474,6 +494,7 @@ void room_list(struct http_transaction *h, struct ctdlsession *c) {
 
                JsonObjectAppend(jr, NewJsonNumber(HKEY("current_view"), extract_int(buf, 6)));
                JsonObjectAppend(jr, NewJsonNumber(HKEY("default_view"), extract_int(buf, 7)));
 
                JsonObjectAppend(jr, NewJsonNumber(HKEY("current_view"), extract_int(buf, 6)));
                JsonObjectAppend(jr, NewJsonNumber(HKEY("default_view"), extract_int(buf, 7)));
+               JsonObjectAppend(jr, NewJsonNumber(HKEY("mtime"), extract_int(buf, 8)));
 
                JsonArrayAppend(j, jr); // add the room to the array
        }
 
                JsonArrayAppend(j, jr); // add the room to the array
        }
@@ -532,8 +553,7 @@ void ctdl_r(struct http_transaction *h, struct ctdlsession *c) {
        }
        // At this point our Citadel client session is "in" the specified room.
 
        }
        // At this point our Citadel client session is "in" the specified room.
 
-       if (num_tokens(h->url, '/') == 4)       //      /ctdl/r/roomname
-       {
+       if (num_tokens(h->url, '/') == 4) {     //      /ctdl/r/roomname
                the_room_itself(h, c);
                return;
        }
                the_room_itself(h, c);
                return;
        }