Fix default landing mechanism
authorWilfried Goesgens <dothebart@citadel.org>
Sat, 10 May 2014 09:04:59 +0000 (11:04 +0200)
committerWilfried Goesgens <dothebart@citadel.org>
Sat, 10 May 2014 09:04:59 +0000 (11:04 +0200)
if we fail to find a handler for the current URL, we redirect to landing, forcing a go.
If i.e. a RSS gives a false link, the session then is moved to the lobby, which is bad.

webcit/context_loop.c
webcit/roomops.c

index a04c711bf2b665420c09d9af4d9164e93722b07d..2a6fe162dd72331f10b86e0affc86884be104caa 100644 (file)
@@ -344,7 +344,7 @@ int ReadHttpSubject(ParsedHttpHdrs *Hdr, StrBuf *Line, StrBuf *Buf)
                int return_value;
                StrBuf *NewLine = NewStrBuf();
                Hdr->HR.DontNeedAuth = 1;
-               StrBufAppendPrintf(NewLine, "GET /landing?go=%s HTTP/1.0", ChrPtr(Buf));
+               StrBufAppendPrintf(NewLine, "GET /landing?go=%s?failvisibly=1 HTTP/1.0", ChrPtr(Buf));
                syslog(LOG_DEBUG, "Replacing with: %s", ChrPtr(NewLine));
                return_value = ReadHttpSubject(Hdr, NewLine, Buf);
                FreeStrBuf(&NewLine);
index 8720aecbc4e782b46d8c8c7c08898f289358aa1f..cf0b370bb43db8734a57716ce67bb8afe66d917a 100644 (file)
@@ -127,8 +127,10 @@ void dotgoto(void) {
  * goto next room
  */
 void smart_goto(const StrBuf *next_room) {
-       gotoroom(next_room);
-       readloop(readnew, eUseDefault);
+       if (gotoroom(next_room) == 2)
+               readloop(readnew, eUseDefault);
+       else
+               do_404();
 }
 
 /*
@@ -182,6 +184,10 @@ long gotoroom(const StrBuf *gname)
        long err = 0;
        int room_name_supplied = 0;
        int is_baseroom = 0;
+       int failvisibly;
+
+       /* on fail, should we fallback to _BASEROOM_? */
+       failvisibly = ibstr("failvisibly");
 
        /* store ungoto information */
        if (StrLength(gname) > 0) {
@@ -206,6 +212,10 @@ long gotoroom(const StrBuf *gname)
        }
        StrBuf_ServGetln(Buf);
        if  (GetServerStatus(Buf, &err) != 2) {
+               if (failvisibly) {
+                       FreeStrBuf(&Buf);
+                       return err;
+               }
                serv_puts("GOTO _BASEROOM_");
                StrBuf_ServGetln(Buf);
                /*