1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-12-22 07:15:47 +01:00

Implement group redirection.

This commit is contained in:
Juliusz Chroboczek 2020-09-10 13:55:57 +02:00
parent c2b1723bd4
commit 4bdd7c7665
4 changed files with 18 additions and 2 deletions

4
README
View file

@ -75,7 +75,9 @@ fields, all of which are optional.
- `allow-recording`: if true, then recording is allowed in this group;
- `allow-anonymous`: if true, then users may connect with an empty
username; this is not recommended, since anonymous users are not
allowed to participate in the chat.
allowed to participate in the chat;
- `redirect`: if set, then attempts to join the group will be redirected
to the given URL; most other fields are ignored in this case.
A user definition is a dictionary with the following fields:

View file

@ -334,6 +334,7 @@ type groupDescription struct {
loadTime time.Time `json:"-"`
modTime time.Time `json:"-"`
fileSize int64 `json:"-"`
Redirect string `json:"redirect,omitempty"`
Public bool `json:"public,omitempty"`
MaxClients int `json:"max-clients,omitempty"`
AllowAnonymous bool `json:"allow-anonymous,omitempty"`

View file

@ -709,6 +709,12 @@ func startClient(conn *websocket.Conn) (err error) {
}
return
}
if g.description.Redirect != "" {
// We normally redirect at the HTTP level, but the group
// description could have been edited in the meantime.
err = userError("group is now at " + g.description.Redirect)
return
}
c.group = g
defer delClient(c)

View file

@ -93,7 +93,7 @@ func groupHandler(w http.ResponseWriter, r *http.Request) {
return
}
_, err := addGroup(name, nil)
g, err := addGroup(name, nil)
if err != nil {
if os.IsNotExist(err) {
http.NotFound(w, r)
@ -104,6 +104,13 @@ func groupHandler(w http.ResponseWriter, r *http.Request) {
}
return
}
if g.description.Redirect != "" {
http.Redirect(w, r, g.description.Redirect,
http.StatusPermanentRedirect)
return
}
http.ServeFile(w, r, filepath.Join(staticRoot, "sfu.html"))
}