3 // Copyright (c) 1996-2023 by the citadel.org team
5 // This program is open source software. Use, duplication, or
6 // disclosure are subject to the GNU General Public License v3.
11 // Return a "zero-terminated" array of message numbers in the current room.
12 // Caller owns the memory and must free it. Returns NULL if any problems.
13 long *get_msglist(struct ctdlsession *c, char *which_msgs) {
19 ctdl_printf(c, "MSGS %s", which_msgs);
20 ctdl_readline(c, buf, sizeof(buf));
23 if (num_msgs >= num_alloc) {
26 msglist = malloc(num_alloc * sizeof(long));
30 msglist = realloc(msglist, num_alloc * sizeof(long));
33 ctdl_readline(c, buf, sizeof(buf));
34 msglist[num_msgs++] = atol(buf);
35 } while (strcmp(buf, "000")); // this makes the last element a "0" terminator
41 // Supplied with a list of potential matches from an If-Match: or If-None-Match: header, and
42 // a message number (which we always use as the entity tag in Citadel), return nonzero if the
43 // message number matches any of the supplied tags in the string.
44 int match_etags(char *taglist, long msgnum) {
45 int num_tags = num_tokens(taglist, ',');
49 if (msgnum <= 0) { // no msgnum? no match.
53 for (i = 0; i < num_tags; ++i) {
54 extract_token(tag, taglist, i, ',', sizeof tag);
56 char *lq = (strchr(tag, '"'));
57 char *rq = (strrchr(tag, '"'));
58 if (lq < rq) { // has two double quotes
63 if (!strcmp(tag, "*")) { // wildcard match
66 long tagmsgnum = atol(tag);
67 if ((tagmsgnum > 0) && (tagmsgnum == msgnum)) { // match
72 return (0); // no match
76 // Client is requesting a STAT (name and modification time) of the current room
77 void json_stat(struct http_transaction *h, struct ctdlsession *c) {
81 ctdl_printf(c, "STAT");
82 ctdl_readline(c, buf, sizeof(buf));
84 JsonValue *j = NewJsonObject(HKEY("stat"));
85 extract_token(field, &buf[4], 0, '|', sizeof field);
86 JsonObjectAppend(j, NewJsonPlainString(HKEY("name"), field, -1));
87 JsonObjectAppend(j, NewJsonNumber(HKEY("room_mtime"), extract_long(&buf[4], 1)));
89 StrBuf *sj = NewStrBuf();
90 SerializeJson(sj, j, 1); // '1' == free the source array
91 add_response_header(h, strdup("Content-type"), strdup("application/json"));
92 h->response_code = 200;
93 h->response_string = strdup("OK");
94 h->response_body_length = StrLength(sj);
95 h->response_body = SmashStrBuf(&sj);
104 // Client is requesting a mailbox summary of the current room
105 void json_mailbox(struct http_transaction *h, struct ctdlsession *c) {
108 JsonValue *j = NewJsonArray(HKEY("msgs"));
110 ctdl_printf(c, "MSGS ALL|||9"); // "9" as the fourth parameter delivers a mailbox summary
111 ctdl_readline(c, buf, sizeof(buf));
113 while (ctdl_readline(c, buf, sizeof(buf)), (strcmp(buf, "000"))) {
114 utf8ify_rfc822_string(buf);
115 JsonValue *jmsg = NewJsonObject(HKEY("message"));
116 JsonObjectAppend(jmsg, NewJsonNumber(HKEY("msgnum"), extract_long(buf, 0)));
117 JsonObjectAppend(jmsg, NewJsonNumber(HKEY("time"), extract_long(buf, 1)));
118 extract_token(field, buf, 2, '|', sizeof field);
119 JsonObjectAppend(jmsg, NewJsonPlainString(HKEY("author"), field, -1));
120 extract_token(field, buf, 4, '|', sizeof field);
121 JsonObjectAppend(jmsg, NewJsonPlainString(HKEY("addr"), field, -1));
122 extract_token(field, buf, 5, '|', sizeof field);
123 JsonObjectAppend(jmsg, NewJsonPlainString(HKEY("subject"), field, -1));
124 JsonObjectAppend(jmsg, NewJsonNumber(HKEY("msgidhash"), extract_long(buf, 6)));
125 extract_token(field, buf, 7, '|', sizeof field);
126 JsonObjectAppend(jmsg, NewJsonPlainString(HKEY("references"), field, -1));
127 JsonArrayAppend(j, jmsg); // add the message to the array
131 StrBuf *sj = NewStrBuf();
132 SerializeJson(sj, j, 1); // '1' == free the source array
134 add_response_header(h, strdup("Content-type"), strdup("application/json"));
135 h->response_code = 200;
136 h->response_string = strdup("OK");
137 h->response_body_length = StrLength(sj);
138 h->response_body = SmashStrBuf(&sj);
143 // Client is requesting a message list
144 void json_msglist(struct http_transaction *h, struct ctdlsession *c, char *which) {
146 long *msglist = get_msglist(c, which);
147 JsonValue *j = NewJsonArray(HKEY("msgs"));
149 if (msglist != NULL) {
150 for (i = 0; msglist[i] > 0; ++i) {
151 JsonArrayAppend(j, NewJsonNumber(HKEY("m"), msglist[i]));
156 StrBuf *sj = NewStrBuf();
157 SerializeJson(sj, j, 1); // '1' == free the source array
159 add_response_header(h, strdup("Content-type"), strdup("application/json"));
160 h->response_code = 200;
161 h->response_string = strdup("OK");
162 h->response_body_length = StrLength(sj);
163 h->response_body = SmashStrBuf(&sj);
168 // Client is requesting the room info banner
169 void read_room_info_banner(struct http_transaction *h, struct ctdlsession *c) {
172 ctdl_printf(c, "RINF");
173 ctdl_readline(c, buf, sizeof(buf));
175 StrBuf *info = NewStrBuf();
176 while (ctdl_readline(c, buf, sizeof(buf)), (strcmp(buf, "000"))){
177 StrBufAppendPrintf(info, "%s\n", buf);
179 add_response_header(h, strdup("Content-type"), strdup("text/plain"));
180 h->response_code = 200;
181 h->response_string = strdup("OK");
182 h->response_body_length = StrLength(info);
183 h->response_body = SmashStrBuf(&info);
192 // Client is setting the "Last Read Pointer" (marking all messages as "seen" up to this message)
193 void set_last_read_pointer(struct http_transaction *h, struct ctdlsession *c) {
195 ctdl_printf(c, "SLRP %d", atoi(get_url_param(h, "last")));
196 ctdl_readline(c, cbuf, sizeof(cbuf));
197 if (cbuf[0] == '2') {
206 // Client requested an object in a room.
207 void object_in_room(struct http_transaction *h, struct ctdlsession *c) {
210 char unescaped_euid[1024];
212 extract_token(buf, h->url, 4, '/', sizeof buf);
214 if (!strcasecmp(buf, "mailbox")) { // Client is requesting a mailbox summary
219 if (!strcasecmp(buf, "stat")) { // Client is requesting a stat command (name and modification time)
224 if (!strncasecmp(buf, "msgs.", 5)) { // Client is requesting a list of message numbers
225 unescape_input(&buf[5]);
226 json_msglist(h, c, &buf[5]);
230 if (!strcasecmp(buf, "info.txt")) { // Client is requesting the room info banner
231 read_room_info_banner(h, c);
235 if (!strcasecmp(buf, "slrp")) { // Set the Last Read Pointer
236 set_last_read_pointer(h, c);
240 // If we get to this point, the client is requesting a specific object *in* the room.
242 if ((c->room_default_view == VIEW_CALENDAR) // room types where objects are referenced by EUID
243 || (c->room_default_view == VIEW_TASKS)
244 || (c->room_default_view == VIEW_ADDRESSBOOK)
246 safestrncpy(unescaped_euid, buf, sizeof unescaped_euid);
247 unescape_input(unescaped_euid);
248 msgnum = locate_message_by_uid(c, unescaped_euid);
250 else { // otherwise the object is being referenced by message number
254 // All methods except PUT require the message to already exist
255 if ((msgnum <= 0) && (strcasecmp(h->method, "PUT"))) {
259 // If we get to this point we have a valid message number in an accessible room.
260 syslog(LOG_DEBUG, "msgnum is %ld, method is %s", msgnum, h->method);
262 // A sixth component in the URL can be one of two things:
263 // (1) a MIME part specifier, in which case the client wants to download that component within the message
264 // (2) a content-type, in which ase the client wants us to try to render it a certain way
265 if (num_tokens(h->url, '/') == 6) {
266 extract_token(buf, h->url, 5, '/', sizeof buf);
267 if (!IsEmptyStr(buf)) {
268 if (!strcasecmp(buf, "json")) {
269 json_render_one_message(h, c, msgnum);
272 download_mime_component(h, c, msgnum, buf);
278 // Ok, we want a full message, but first let's check for the if[-none]-match headers.
279 char *if_match = header_val(h, "If-Match");
280 if ((if_match != NULL) && (!match_etags(if_match, msgnum))) {
285 char *if_none_match = header_val(h, "If-None-Match");
286 if ((if_none_match != NULL) && (match_etags(if_none_match, msgnum))) {
293 if (!strcasecmp(h->method, "DELETE")) {
294 dav_delete_message(h, c, msgnum);
296 else if (!strcasecmp(h->method, "GET")) {
297 dav_get_message(h, c, msgnum);
299 else if (!strcasecmp(h->method, "PUT")) {
300 dav_put_message(h, c, unescaped_euid, msgnum);
302 else if (!strcasecmp(h->method, "MOVE")) {
303 do_404(h); // FIXME write this
305 else if (!strcasecmp(h->method, "COPY")) {
306 do_404(h); // FIXME write this
309 do_404(h); // Got this far but the method made no sense? Bummer.
315 // Called by the_room_itself() when the HTTP method is REPORT
316 void report_the_room_itself(struct http_transaction *h, struct ctdlsession *c) {
317 if (c->room_default_view == VIEW_CALENDAR) {
318 caldav_report(h, c); // CalDAV REPORTs ... fmgwac
322 do_404(h); // future implementations like CardDAV will require code paths here
326 // Called by the_room_itself() when the HTTP method is OPTIONS
327 void options_the_room_itself(struct http_transaction *h, struct ctdlsession *c) {
328 h->response_code = 200;
329 h->response_string = strdup("OK");
330 if (c->room_default_view == VIEW_CALENDAR) {
331 add_response_header(h, strdup("DAV"), strdup("1, calendar-access")); // offer CalDAV
333 else if (c->room_default_view == VIEW_ADDRESSBOOK) {
334 add_response_header(h, strdup("DAV"), strdup("1, addressbook")); // offer CardDAV
337 add_response_header(h, strdup("DAV"), strdup("1")); // ordinary WebDAV for all other room types
339 add_response_header(h, strdup("Allow"), strdup("OPTIONS, PROPFIND, GET, PUT, REPORT, DELETE, MOVE, COPY"));
343 // Called by the_room_itself() when the HTTP method is PROPFIND
344 void propfind_the_room_itself(struct http_transaction *h, struct ctdlsession *c) {
347 int dav_depth = (header_val(h, "Depth") ? atoi(header_val(h, "Depth")) : INT_MAX);
348 syslog(LOG_DEBUG, "Client PROPFIND requested depth: %d", dav_depth);
349 StrBuf *Buf = NewStrBuf();
351 StrBufAppendPrintf(Buf, "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
352 "<D:multistatus " "xmlns:D=\"DAV:\" " "xmlns:C=\"urn:ietf:params:xml:ns:caldav\"" ">");
354 // Transmit the collection resource
355 StrBufAppendPrintf(Buf, "<D:response>");
356 StrBufAppendPrintf(Buf, "<D:href>");
357 StrBufXMLEscAppend(Buf, NULL, h->site_prefix, strlen(h->site_prefix), 0);
358 StrBufAppendPrintf(Buf, "/ctdl/r/");
359 StrBufXMLEscAppend(Buf, NULL, c->room, strlen(c->room), 0);
360 StrBufAppendPrintf(Buf, "</D:href>");
362 StrBufAppendPrintf(Buf, "<D:propstat>");
363 StrBufAppendPrintf(Buf, "<D:status>HTTP/1.1 200 OK</D:status>");
364 StrBufAppendPrintf(Buf, "<D:prop>");
365 StrBufAppendPrintf(Buf, "<D:displayname>");
366 StrBufXMLEscAppend(Buf, NULL, c->room, strlen(c->room), 0);
367 StrBufAppendPrintf(Buf, "</D:displayname>");
369 StrBufAppendPrintf(Buf, "<D:owner />"); // empty owner ought to be legal; see rfc3744 section 5.1
371 StrBufAppendPrintf(Buf, "<D:resourcetype><D:collection />");
372 switch (c->room_default_view) {
374 StrBufAppendPrintf(Buf, "<C:calendar />"); // RFC4791 section 4.2
377 StrBufAppendPrintf(Buf, "</D:resourcetype>");
379 int enumerate_by_euid = 0; // nonzero if messages will be retrieved by euid instead of msgnum
380 switch (c->room_default_view) {
381 case VIEW_CALENDAR: // RFC4791 section 5.2
382 StrBufAppendPrintf(Buf, "<C:supported-calendar-component-set><C:comp name=\"VEVENT\"/></C:supported-calendar-component-set>");
383 StrBufAppendPrintf(Buf, "<C:supported-calendar-data>");
384 StrBufAppendPrintf(Buf, "<C:calendar-data content-type=\"text/calendar\" version=\"2.0\"/>");
385 StrBufAppendPrintf(Buf, "</C:supported-calendar-data>");
386 enumerate_by_euid = 1;
388 case VIEW_TASKS: // RFC4791 section 5.2
389 StrBufAppendPrintf(Buf, "<C:supported-calendar-component-set><C:comp name=\"VTODO\"/></C:supported-calendar-component-set>");
390 StrBufAppendPrintf(Buf, "<C:supported-calendar-data>");
391 StrBufAppendPrintf(Buf, "<C:calendar-data content-type=\"text/calendar\" version=\"2.0\"/>");
392 StrBufAppendPrintf(Buf, "</C:supported-calendar-data>");
393 enumerate_by_euid = 1;
395 case VIEW_ADDRESSBOOK: // FIXME put some sort of CardDAV crapola here when we implement it
396 enumerate_by_euid = 1;
398 case VIEW_WIKI: // FIXME invent "WikiDAV" ? The versioning stuff in DAV could be useful.
399 enumerate_by_euid = 1;
403 // FIXME get the mtime
404 // StrBufAppendPrintf(Buf, "<D:getlastmodified>");
405 // escputs(datestring);
406 // StrBufAppendPrintf(Buf, "</D:getlastmodified>");
408 StrBufAppendPrintf(Buf, "</D:prop>");
409 StrBufAppendPrintf(Buf, "</D:propstat>");
410 StrBufAppendPrintf(Buf, "</D:response>\n");
412 // If a depth greater than zero was specified, transmit the collection listing
415 long *msglist = get_msglist(c, "ALL");
418 for (i = 0; (msglist[i] > 0); ++i) {
420 syslog(LOG_DEBUG, "PROPFIND enumerated %d messages", i);
421 e = NULL; // EUID gets stored here
425 ctdl_printf(c, "MSG0 %ld|3", msglist[i]);
426 ctdl_readline(c, cbuf, sizeof(cbuf));
428 while (ctdl_readline(c, cbuf, sizeof(cbuf)), strcmp(cbuf, "000")) {
429 if ((enumerate_by_euid) && (!strncasecmp(cbuf, "exti=", 5))) {
430 // e = strdup(&cbuf[5]);
431 int elen = (2 * strlen(&cbuf[5]));
433 urlesc(e, elen, &cbuf[5]);
435 if (!strncasecmp(cbuf, "time=", 5)) {
436 timestamp = atol(&cbuf[5]);
441 sprintf(e, "%ld", msglist[i]);
443 StrBufAppendPrintf(Buf, "<D:response>");
445 // Generate the 'href' tag for this message
446 StrBufAppendPrintf(Buf, "<D:href>");
447 StrBufXMLEscAppend(Buf, NULL, h->site_prefix, strlen(h->site_prefix), 0);
448 StrBufAppendPrintf(Buf, "/ctdl/r/");
449 StrBufXMLEscAppend(Buf, NULL, c->room, strlen(c->room), 0);
450 StrBufAppendPrintf(Buf, "/");
451 StrBufXMLEscAppend(Buf, NULL, e, strlen(e), 0);
452 StrBufAppendPrintf(Buf, "</D:href>");
453 StrBufAppendPrintf(Buf, "<D:propstat>");
454 StrBufAppendPrintf(Buf, "<D:status>HTTP/1.1 200 OK</D:status>");
455 StrBufAppendPrintf(Buf, "<D:prop>");
457 switch (c->room_default_view) {
459 StrBufAppendPrintf(Buf,
460 "<D:getcontenttype>text/calendar; component=vevent</D:getcontenttype>");
463 StrBufAppendPrintf(Buf,
464 "<D:getcontenttype>text/calendar; component=vtodo</D:getcontenttype>");
466 case VIEW_ADDRESSBOOK:
467 StrBufAppendPrintf(Buf, "<D:getcontenttype>text/x-vcard</D:getcontenttype>");
472 char *datestring = http_datestring(timestamp);
474 StrBufAppendPrintf(Buf, "<D:getlastmodified>");
475 StrBufXMLEscAppend(Buf, NULL, datestring, strlen(datestring), 0);
476 StrBufAppendPrintf(Buf, "</D:getlastmodified>");
479 if (enumerate_by_euid) { // FIXME ajc 2017oct30 should this be inside the timestamp conditional?
480 StrBufAppendPrintf(Buf, "<D:getetag>\"%ld\"</D:getetag>", msglist[i]);
483 StrBufAppendPrintf(Buf, "</D:prop></D:propstat></D:response>\n");
491 StrBufAppendPrintf(Buf, "</D:multistatus>\n");
493 add_response_header(h, strdup("Content-type"), strdup("text/xml"));
494 h->response_code = 207;
495 h->response_string = strdup("Multi-Status");
496 h->response_body_length = StrLength(Buf);
497 h->response_body = SmashStrBuf(&Buf);
500 // some good examples here
501 // http://blogs.nologin.es/rickyepoderi/index.php?/archives/14-Introducing-CalDAV-Part-I.html
504 // Called by the_room_itself() when the HTTP method is PROPFIND
505 void get_the_room_itself(struct http_transaction *h, struct ctdlsession *c) {
506 JsonValue *j = NewJsonObject(HKEY("gotoroom"));
508 JsonObjectAppend(j, NewJsonPlainString(HKEY("name"), c->room, -1));
509 JsonObjectAppend(j, NewJsonNumber(HKEY("current_view"), c->room_current_view));
510 JsonObjectAppend(j, NewJsonNumber(HKEY("default_view"), c->room_default_view));
511 JsonObjectAppend(j, NewJsonNumber(HKEY("is_room_aide"), c->is_room_aide));
512 JsonObjectAppend(j, NewJsonNumber(HKEY("can_delete_messages"), c->can_delete_messages));
513 JsonObjectAppend(j, NewJsonNumber(HKEY("new_messages"), c->new_messages));
514 JsonObjectAppend(j, NewJsonNumber(HKEY("total_messages"), c->total_messages));
515 JsonObjectAppend(j, NewJsonNumber(HKEY("last_seen"), c->last_seen));
516 JsonObjectAppend(j, NewJsonNumber(HKEY("room_mtime"), c->room_mtime));
518 StrBuf *sj = NewStrBuf();
519 SerializeJson(sj, j, 1); // '1' == free the source array
521 add_response_header(h, strdup("Content-type"), strdup("application/json"));
522 h->response_code = 200;
523 h->response_string = strdup("OK");
524 h->response_body_length = StrLength(sj);
525 h->response_body = SmashStrBuf(&sj);
530 // Handle REST/DAV requests for the room itself (such as /ctdl/r/roomname
531 // or /ctdl/r/roomname/ but *not* specific objects within the room)
532 void the_room_itself(struct http_transaction *h, struct ctdlsession *c) {
534 // OPTIONS method on the room itself usually is a DAV client assessing what's here.
535 if (!strcasecmp(h->method, "OPTIONS")) {
536 options_the_room_itself(h, c);
540 // PROPFIND method on the room itself could be looking for a directory
541 if (!strcasecmp(h->method, "PROPFIND")) {
542 propfind_the_room_itself(h, c);
546 // REPORT method on the room itself is probably the dreaded CalDAV tower-of-crapola
547 if (!strcasecmp(h->method, "REPORT")) {
548 report_the_room_itself(h, c);
552 // GET method on the room itself is an API call, possibly from our JavaScript front end
553 if (!strcasecmp(h->method, "get")) {
554 get_the_room_itself(h, c);
558 // we probably want a "go to this room" for interactive access
563 // Dispatcher for "/ctdl/r" and "/ctdl/r/" for the room list
564 void room_list(struct http_transaction *h, struct ctdlsession *c) {
568 ctdl_printf(c, "LKRA");
569 ctdl_readline(c, buf, sizeof(buf));
575 JsonValue *j = NewJsonArray(HKEY("lkra"));
576 while (ctdl_readline(c, buf, sizeof(buf)), strcmp(buf, "000")) {
578 // 0 |1 |2 |3 |4 |5 |6 |7 |8
579 // name|QRflags|QRfloor|QRorder|QRflags2|ra|current_view|default_view|mtime
580 JsonValue *jr = NewJsonObject(HKEY("room"));
582 extract_token(roomname, buf, 0, '|', sizeof roomname);
583 JsonObjectAppend(jr, NewJsonPlainString(HKEY("name"), roomname, -1));
585 JsonObjectAppend(jr, NewJsonNumber(HKEY("floor"), extract_int(buf, 2)));
586 JsonObjectAppend(jr, NewJsonNumber(HKEY("rorder"), extract_int(buf, 3)));
588 int ra = extract_int(buf, 5);
589 JsonObjectAppend(jr, NewJsonBool(HKEY("known"), (ra & UA_KNOWN)));
590 JsonObjectAppend(jr, NewJsonBool(HKEY("hasnewmsgs"), (ra & UA_HASNEWMSGS)));
592 JsonObjectAppend(jr, NewJsonNumber(HKEY("current_view"), extract_int(buf, 6)));
593 JsonObjectAppend(jr, NewJsonNumber(HKEY("default_view"), extract_int(buf, 7)));
594 JsonObjectAppend(jr, NewJsonNumber(HKEY("mtime"), extract_int(buf, 8)));
596 JsonArrayAppend(j, jr); // add the room to the array
599 StrBuf *sj = NewStrBuf();
600 SerializeJson(sj, j, 1); // '1' == free the source array
602 add_response_header(h, strdup("Content-type"), strdup("application/json"));
603 h->response_code = 200;
604 h->response_string = strdup("OK");
605 h->response_body_length = StrLength(sj);
606 h->response_body = SmashStrBuf(&sj);
610 // Dispatcher for paths starting with /ctdl/r/
611 void ctdl_r(struct http_transaction *h, struct ctdlsession *c) {
612 char requested_roomname[128];
615 long room_flags2 = 0;
617 // All room-related functions require being "in" the room specified. Are we in that room already?
618 extract_token(requested_roomname, h->url, 3, '/', sizeof requested_roomname);
619 unescape_input(requested_roomname);
621 if (IsEmptyStr(requested_roomname)) { // /ctdl/r/
625 // If not, try to go there.
626 if (strcasecmp(requested_roomname, c->room)) {
627 ctdl_printf(c, "GOTO %s", requested_roomname);
628 ctdl_readline(c, buf, sizeof(buf));
630 // buf[3] will indicate whether any instant messages are waiting
631 extract_token(c->room, &buf[4], 0, '|', sizeof c->room);
632 c->new_messages = extract_int(&buf[4], 1);
633 c->total_messages = extract_int(&buf[4], 2);
634 // 3 (int)info Info flag: set to nonzero if the user needs to read this room's info file
635 room_flags = extract_long(&buf[4], 3); // Various flags associated with this room.
636 // 5 (long)CC->room.QRhighest The highest message number present in this room
637 c->last_seen = extract_long(&buf[4], 6); // The highest message number the user has read in this room
638 // 7 (int)rmailflag Boolean flag: 1 if this is a Mail> room, 0 otherwise.
639 c->is_room_aide = extract_int(&buf[4], 8);
640 // 9 This position is no longer used
641 // 10 (int)CC->room.QRfloor The floor number this room resides on
642 c->room_current_view = extract_int(&buf[4], 11);
643 c->room_default_view = extract_int(&buf[4], 12);
644 // 13 (int)is_trash Boolean flag: 1 if this is the user's Trash folder, 0 otherwise.
645 room_flags2 = extract_long(&buf[4], 14); // More flags associated with this room.
646 c->room_mtime = extract_long(&buf[4], 15); // Timestamp of the last write activity in this room
648 // If any of these three conditions are met, let the client know it has permission to delete messages.
649 if ((c->is_room_aide) || (room_flags & QR_MAILBOX) || (room_flags2 & QR2_COLLABDEL)) {
650 c->can_delete_messages = 1;
653 c->can_delete_messages = 0;
661 // At this point our Citadel client session is "in" the specified room.
663 if (num_tokens(h->url, '/') == 4) { // /ctdl/r/roomname
664 the_room_itself(h, c);
668 extract_token(buf, h->url, 4, '/', sizeof buf);
669 if (num_tokens(h->url, '/') == 5) {
670 if (IsEmptyStr(buf)) {
671 the_room_itself(h, c); // /ctdl/r/roomname/ ( same as /ctdl/r/roomname )
674 object_in_room(h, c); // /ctdl/r/roomname/object
678 if (num_tokens(h->url, '/') == 6) {
679 object_in_room(h, c); // /ctdl/r/roomname/object/ or possibly /ctdl/r/roomname/object/component
682 // If we get to this point, the client specified a valid room but requested an action we don't know how to perform.