]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_network.c
* Bugfixes and cosmetic changes to listsub system
[citadel.git] / citadel / serv_network.c
index 114eed6f1f12f361b4dd56bcb02f8566f643dfb9..5694055b8e16f386f7f847495e7e7cabbd4c3a4c 100644 (file)
  * Don't allow polls during network processing
  */
 
+/*
+ * Duration of time (in seconds) after which pending list subscribe/unsubscribe
+ * requests that have not been confirmed will be deleted.
+ */
+#define EXP    259200  /* three days */
+
 #include "sysdep.h"
 #include <stdlib.h>
 #include <unistd.h>
@@ -687,6 +693,8 @@ void network_spoolout_room(char *room_to_spool) {
        struct namelist *nptr;
        size_t miscsize = 0;
        size_t linesize = 0;
+       int skipthisline = 0;
+       int i;
 
        lprintf(7, "Spooling <%s>\n", room_to_spool);
        if (getroom(&CC->quickroom, room_to_spool) != 0) {
@@ -740,11 +748,29 @@ void network_spoolout_room(char *room_to_spool) {
                        sc.ignet_push_shares = nptr;
                }
                else {
-                       linesize = strlen(buf);
-                       sc.misc = realloc(sc.misc,
-                               (miscsize + linesize + 2) );
-                       sprintf(&sc.misc[miscsize], "%s\n", buf);
-                       miscsize = miscsize + linesize + 1;
+                       /* Preserve 'other' lines ... *unless* they happen to
+                        * be subscribe/unsubscribe pendings with expired
+                        * timestamps.
+                        */
+                       skipthisline = 0;
+                       if (!strncasecmp(buf, "subpending|", 11)) {
+                               if (time(NULL) - extract_long(buf, 4) > EXP) {
+                                       skipthisline = 1;
+                               }
+                       }
+                       if (!strncasecmp(buf, "unsubpending|", 13)) {
+                               if (time(NULL) - extract_long(buf, 3) > EXP) {
+                                       skipthisline = 1;
+                               }
+                       }
+
+                       if (skipthisline == 0) {
+                               linesize = strlen(buf);
+                               sc.misc = realloc(sc.misc,
+                                       (miscsize + linesize + 2) );
+                               sprintf(&sc.misc[miscsize], "%s\n", buf);
+                               miscsize = miscsize + linesize + 1;
+                       }
                }
 
 
@@ -762,13 +788,20 @@ void network_spoolout_room(char *room_to_spool) {
                network_spool_msg, &sc);
 
        /* If we wrote a digest, deliver it and then close it */
+       snprintf(buf, sizeof buf, "room_%s@%s",
+               CC->quickroom.QRname, config.c_fqdn);
+       for (i=0; i<strlen(buf); ++i) {
+               buf[i] = tolower(buf[i]);
+               if (isspace(buf[i])) buf[i] = '_';
+       }
        if (sc.digestfp != NULL) {
                fprintf(sc.digestfp,    " -----------------------------------"
                                        "------------------------------------"
                                        "-------\n"
                                        "You are subscribed to the '%s' "
-                                       "list.\n",
-                                       CC->quickroom.QRname
+                                       "list.\n"
+                                       "To post to the list: %s\n",
+                                       CC->quickroom.QRname, buf
                );
                network_deliver_digest(&sc);    /* deliver and close */
        }