mirror of
https://github.com/jech/galene.git
synced 2024-11-22 08:35:57 +01:00
Implement group redirection.
This commit is contained in:
parent
c2b1723bd4
commit
4bdd7c7665
4 changed files with 18 additions and 2 deletions
4
README
4
README
|
@ -75,7 +75,9 @@ fields, all of which are optional.
|
||||||
- `allow-recording`: if true, then recording is allowed in this group;
|
- `allow-recording`: if true, then recording is allowed in this group;
|
||||||
- `allow-anonymous`: if true, then users may connect with an empty
|
- `allow-anonymous`: if true, then users may connect with an empty
|
||||||
username; this is not recommended, since anonymous users are not
|
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:
|
A user definition is a dictionary with the following fields:
|
||||||
|
|
||||||
|
|
1
group.go
1
group.go
|
@ -334,6 +334,7 @@ type groupDescription struct {
|
||||||
loadTime time.Time `json:"-"`
|
loadTime time.Time `json:"-"`
|
||||||
modTime time.Time `json:"-"`
|
modTime time.Time `json:"-"`
|
||||||
fileSize int64 `json:"-"`
|
fileSize int64 `json:"-"`
|
||||||
|
Redirect string `json:"redirect,omitempty"`
|
||||||
Public bool `json:"public,omitempty"`
|
Public bool `json:"public,omitempty"`
|
||||||
MaxClients int `json:"max-clients,omitempty"`
|
MaxClients int `json:"max-clients,omitempty"`
|
||||||
AllowAnonymous bool `json:"allow-anonymous,omitempty"`
|
AllowAnonymous bool `json:"allow-anonymous,omitempty"`
|
||||||
|
|
|
@ -709,6 +709,12 @@ func startClient(conn *websocket.Conn) (err error) {
|
||||||
}
|
}
|
||||||
return
|
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
|
c.group = g
|
||||||
defer delClient(c)
|
defer delClient(c)
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ func groupHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := addGroup(name, nil)
|
g, err := addGroup(name, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
http.NotFound(w, r)
|
http.NotFound(w, r)
|
||||||
|
@ -104,6 +104,13 @@ func groupHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if g.description.Redirect != "" {
|
||||||
|
http.Redirect(w, r, g.description.Redirect,
|
||||||
|
http.StatusPermanentRedirect)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
http.ServeFile(w, r, filepath.Join(staticRoot, "sfu.html"))
|
http.ServeFile(w, r, filepath.Join(staticRoot, "sfu.html"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue