Worked out the syntax for requesting a calendar range
authorArt Cancro <ajc@citadel.org>
Fri, 22 Dec 2023 23:58:46 +0000 (18:58 -0500)
committerArt Cancro <ajc@citadel.org>
Fri, 22 Dec 2023 23:58:46 +0000 (18:58 -0500)
webcit-ng/api.txt
webcit-ng/server/calendar_functions.c
webcit-ng/server/room_functions.c

index 8660c8f2ca7d20f17fc0a243d90e3247993fb963..cf0652af0bca1a2220bb501b0814c9da7f236207 100644 (file)
@@ -16,6 +16,12 @@ GET             /ctdl/r/<roomname>/stat            JSON dictionary of the server
 GET             /ctdl/r/<roomname>/<msgnum>        Retrieve the content of an individual message
 GET             /ctdl/r/<roomname>/<msgnum>/json   Retrieve an individual message in a room, encapsulated in JSON
 GET             /ctdl/r/<roomname>/<msgnum>/<part> Retrieve a MIME component of a message, specified by partnum
+
+GET             /ctdl/r/<roomname>/calendar:<from>:<to>
+                                                   Retrieve calendar items in the current room.
+                                                   "from" and "to" comprise a range expressed in unix timestamps.
+                                                   You can omit either or both timestamps but not the colons.
+
 DELETE          /ctdl/r/<roomname>/<msgnum>        Delete a message from a room
 MOVE            /ctdl/r/<roomname>/<msgnum>        Move a message to another room (requires Destination)
 
index 73305d7336dd4467db74bba8f48102a4cd589f25..7d88996ed1e16271c6528297b1b8b794fcf948ad 100644 (file)
 // Client is requesting a message list
 void calendar_msglist(struct http_transaction *h, struct ctdlsession *c, char *range) {
 
+       // Determine the date/time range requested by the client
+       time_t lo = atol(range);
+       char *colon = strchr(range, ':');
+       time_t hi = colon ? atol(++colon) : LONG_MAX;
+
+       // Rule out impossible ranges
+       if (hi < lo) {
+               do_404(h);
+               return;
+       }
+
        // Begin by requesting all messages in the room
        int i = 0;
        Array *msglist = get_msglist(c, "ALL");
@@ -23,6 +34,13 @@ void calendar_msglist(struct http_transaction *h, struct ctdlsession *c, char *r
                long m;
                memcpy(&m, array_get_element_at(msglist, i), sizeof(long));
                syslog(LOG_DEBUG, "FIXME %ld", m);
+
+               // now we have to:
+               // 1. fetch the message from citadel server
+               // 2. parse the ical
+               // 3. figure out range
+               // we should steal code from webcit-classic for this
+
        }
        array_free(msglist);
 
index 24195e7733b3e3fd83e6cd0ef3e60517fe0939b5..12b5df5985a68bf1ef37fdea0df38ef31a6b70a3 100644 (file)
@@ -226,7 +226,7 @@ void object_in_room(struct http_transaction *h, struct ctdlsession *c) {
                return;
        }
 
-       if (!strncasecmp(buf, "calendar.", 9)) {        // Client is requesting a calendar range
+       if (!strncasecmp(buf, "calendar:", 9)) {        // Client is requesting a calendar range
                unescape_input(&buf[9]);
                calendar_msglist(h, c, &buf[9]);
                return;