From 761d6c3c8a476a2ed327db5cf115c19d66d081b7 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 12 Feb 2022 18:34:36 -0500 Subject: [PATCH] Client side of SLRP is done --- webcit-ng/api.txt | 13 +++++++++++-- webcit-ng/room_functions.c | 12 ++++++++++++ webcit-ng/static/js/main.js | 4 ++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/webcit-ng/api.txt b/webcit-ng/api.txt index ca344ff52..a8761daf6 100644 --- a/webcit-ng/api.txt +++ b/webcit-ng/api.txt @@ -7,13 +7,22 @@ GET /ctdl/r/ returns a JSON-encoded list of accessible rooms OPTIONS /ctdl/r/ROOMNAME/ returns just what you'd expect PROPFIND /ctdl/r/ROOMNAME/ Show a bunch of crap GET /ctdl/r/ROOMNAME/ Returns information about the room (name, view, etc.) in JSON format +GET /ctdl/r/ROOMNAME/info.txt Returns the room info banner for this room GET /ctdl/r/ROOMNAME/msgs.all JSON array of message list in room GET /ctdl/r/ROOMNAME/msgs.new JSON array of message list in room (new messages) 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) -GET /ctdl/r/ROOMNAME/info.txt Returns the room info banner for this room + Accepted parameters: + wefw List of message references + subj Message subject + The returned ETag will be the new message number. + +GET /ctdl/r/ROOMNAME/slrp Set the "Last Read Pointer" for the room + Accepted parameters: + last The number of the most recently seen message + 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 diff --git a/webcit-ng/room_functions.c b/webcit-ng/room_functions.c index da325f32a..c0c67569f 100644 --- a/webcit-ng/room_functions.c +++ b/webcit-ng/room_functions.c @@ -129,6 +129,13 @@ void read_room_info_banner(struct http_transaction *h, struct ctdlsession *c) { } +// Client is setting the "Last Read Pointer" (marking all messages as "seen" up to this message) +void set_last_read_pointer(struct http_transaction *h, struct ctdlsession *c) { + syslog(LOG_DEBUG, "FIXME: set last read pointer"); + do_404(h); // FIXME do this +} + + // Client requested an object in a room. void object_in_room(struct http_transaction *h, struct ctdlsession *c) { char buf[1024]; @@ -148,6 +155,11 @@ void object_in_room(struct http_transaction *h, struct ctdlsession *c) { return; } + if (!strcasecmp(buf, "slrp")) { // Set the Last Read Pointer + set_last_read_pointer(h, c); + return; + } + // 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 diff --git a/webcit-ng/static/js/main.js b/webcit-ng/static/js/main.js index 039a1e64b..ba8dfb025 100644 --- a/webcit-ng/static/js/main.js +++ b/webcit-ng/static/js/main.js @@ -109,6 +109,10 @@ function gotonext(which_oper) { if (which_oper == 2) { // Goto needs to mark messages as seen console.log("FIXME set lrp to " + last_seen); + set_last_read_pointer = async() => { + response = await fetch("/ctdl/r/" + escapeHTMLURI(current_room) + "/slrp?last=" + last_seen); + } + set_last_read_pointer(); } if ((which_oper == 1) || (which_oper == 2)) { // Skip or Goto both take us to the "next" room -- 2.39.2