Renamed SUBS command to LSUB and changed its parameters. Subscription Type no longer...
[citadel.git] / webcit / listsub.c
index 5d9ceb8a7b1ac6baed11707263887cdb748eb1df..d445d05bd16cacdda9da0a7fe2850b02968100e7 100644 (file)
 /*
  * List subscription handling
  */
-
-int Conditional_LISTSUB_EXECUTE_SUBSCRIBE(StrBuf *Target, WCTemplputParams *TP)
-{
+int Conditional_LISTSUB_EXECUTE_SUBSCRIBE(StrBuf *Target, WCTemplputParams *TP) {
        int rc;
        StrBuf *Line;
        const char *ImpMsg;
-       const StrBuf *Room, *Email, *SubType;
-       
+       const StrBuf *Room, *Email;
+
+       if (strcmp(bstr("cmd"), "subscribe")) {
+               return 0;
+       }
+
        Room = sbstr("room");
        if (Room == NULL)
        {
@@ -39,30 +41,29 @@ int Conditional_LISTSUB_EXECUTE_SUBSCRIBE(StrBuf *Target, WCTemplputParams *TP)
                AppendImportantMessage(ImpMsg, -1);
                return 0;
        }
-       SubType = sbstr("subtype");
 
        Line = NewStrBuf();
-       serv_printf("SUBS subscribe|%s|%s|%s|%s/listsub",
-                   ChrPtr(Room),
-                   ChrPtr(Email),
-                   ChrPtr(SubType),
-                   ChrPtr(site_prefix)
-               );
+       serv_printf("LSUB subscribe|%s|%s|%s/listsub", ChrPtr(Room), ChrPtr(Email), ChrPtr(site_prefix));
        StrBuf_ServGetln(Line);
        rc = GetServerStatusMsg(Line, NULL, 1, 2);
        FreeStrBuf(&Line);
-       if (rc == 2)
+       if (rc == 2) {
                putbstr("__FAIL", NewStrBufPlain(HKEY("1")));
+       }
        return rc == 2;
 }
 
-int Conditional_LISTSUB_EXECUTE_UNSUBSCRIBE(StrBuf *Target, WCTemplputParams *TP)
-{
+
+int Conditional_LISTSUB_EXECUTE_UNSUBSCRIBE(StrBuf *Target, WCTemplputParams *TP) {
        int rc;
        StrBuf *Line;
        const char *ImpMsg;
        const StrBuf *Room, *Email;
-       
+
+       if (strcmp(bstr("cmd"), "unsubscribe")) {
+               return 0;
+       }
+
        Room = sbstr("room");
        if (Room == NULL)
        {
@@ -78,11 +79,7 @@ int Conditional_LISTSUB_EXECUTE_UNSUBSCRIBE(StrBuf *Target, WCTemplputParams *TP
                return 0;
        }
 
-       serv_printf("SUBS unsubscribe|%s|%s|%s/listsub",
-                   ChrPtr(Room),
-                   ChrPtr(Email),
-                   ChrPtr(site_prefix)
-               );
+       serv_printf("LSUB unsubscribe|%s|%s|%s/listsub", ChrPtr(Room), ChrPtr(Email), ChrPtr(site_prefix));
        Line = NewStrBuf();
        StrBuf_ServGetln(Line);
        rc = GetServerStatusMsg(Line, NULL, 1, 2);
@@ -98,7 +95,11 @@ int Conditional_LISTSUB_EXECUTE_CONFIRM_SUBSCRIBE(StrBuf *Target, WCTemplputPara
        StrBuf *Line;
        const char *ImpMsg;
        const StrBuf *Room, *Token;
-       
+
+       if (strcmp(bstr("cmd"), "confirm")) {
+               return 0;
+       }
+
        Room = sbstr("room");
        if (Room == NULL)
        {
@@ -115,10 +116,7 @@ int Conditional_LISTSUB_EXECUTE_CONFIRM_SUBSCRIBE(StrBuf *Target, WCTemplputPara
        }
 
        Line = NewStrBuf();
-       serv_printf("SUBS confirm|%s|%s",
-                   ChrPtr(Room),
-                   ChrPtr(Token)
-               );
+       serv_printf("LSUB confirm|%s|%s", ChrPtr(Room), ChrPtr(Token));
        StrBuf_ServGetln(Line);
        rc = GetServerStatusMsg(Line, NULL, 1, 2);
        FreeStrBuf(&Line);