mirror of
https://github.com/jech/galene.git
synced 2024-11-25 01:55:57 +01:00
Publish websocket endpoint in group status.
This commit is contained in:
parent
4e275a63b4
commit
4bc873a574
4 changed files with 24 additions and 8 deletions
|
@ -1177,6 +1177,7 @@ func (desc *Description) GetPermission(group string, creds ClientCredentials) (s
|
|||
|
||||
type Status struct {
|
||||
Name string `json:"name"`
|
||||
Endpoint string `json:"endpoint"`
|
||||
DisplayName string `json:"displayName,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
AuthServer string `json:"authServer,omitempty"`
|
||||
|
@ -1185,10 +1186,11 @@ type Status struct {
|
|||
ClientCount *int `json:"clientCount,omitempty"`
|
||||
}
|
||||
|
||||
func (g *Group) Status(authentified bool) Status {
|
||||
func (g *Group) Status(authentified bool, endpoint string) Status {
|
||||
desc := g.Description()
|
||||
d := Status{
|
||||
Name: g.name,
|
||||
Endpoint: endpoint,
|
||||
DisplayName: desc.DisplayName,
|
||||
AuthServer: desc.AuthServer,
|
||||
AuthPortal: desc.AuthPortal,
|
||||
|
@ -1209,7 +1211,7 @@ func GetPublic() []Status {
|
|||
gs := make([]Status, 0)
|
||||
Range(func(g *Group) bool {
|
||||
if g.Description().Public {
|
||||
gs = append(gs, g.Status(false))
|
||||
gs = append(gs, g.Status(false, ""))
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
|
|
@ -1148,7 +1148,7 @@ func handleAction(c *webClient, a interface{}) error {
|
|||
if a.group != "" {
|
||||
g := group.Get(a.group)
|
||||
if g != nil {
|
||||
s := g.Status(true)
|
||||
s := g.Status(true, "")
|
||||
status = &s
|
||||
data = g.Data()
|
||||
}
|
||||
|
@ -1170,7 +1170,7 @@ func handleAction(c *webClient, a interface{}) error {
|
|||
return errors.New("Permissions changed in no group")
|
||||
}
|
||||
perms := append([]string(nil), c.permissions...)
|
||||
status := g.Status(true)
|
||||
status := g.Status(true, "")
|
||||
c.write(clientMessage{
|
||||
Type: "joined",
|
||||
Kind: "change",
|
||||
|
|
|
@ -3431,7 +3431,12 @@ async function serverConnect() {
|
|||
serverConnection.onusermessage = gotUserMessage;
|
||||
serverConnection.onfiletransfer = gotFileTransfer;
|
||||
|
||||
let url = `ws${location.protocol === 'https:' ? 's' : ''}://${location.host}/ws`;
|
||||
let url = groupStatus.endpoint;
|
||||
if(!url) {
|
||||
console.warn("no endpoint in status");
|
||||
url = `ws${location.protocol === 'https:' ? 's' : ''}://${location.host}/ws`;
|
||||
}
|
||||
|
||||
try {
|
||||
await serverConnection.connect(url);
|
||||
} catch(e) {
|
||||
|
|
|
@ -327,7 +327,7 @@ func groupHandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
status := g.Status(false)
|
||||
status := g.Status(false, "")
|
||||
cspHeader(w, status.AuthServer)
|
||||
serveFile(w, r, filepath.Join(StaticRoot, "galene.html"))
|
||||
}
|
||||
|
@ -351,7 +351,16 @@ func groupStatusHandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
d := g.Status(false)
|
||||
scheme := "wss"
|
||||
if Insecure {
|
||||
scheme = "ws"
|
||||
}
|
||||
endpoint := url.URL{
|
||||
Scheme: scheme,
|
||||
Host: r.Host,
|
||||
Path: "/ws",
|
||||
}
|
||||
d := g.Status(false, endpoint.String())
|
||||
w.Header().Set("content-type", "application/json")
|
||||
w.Header().Set("cache-control", "no-cache")
|
||||
|
||||
|
|
Loading…
Reference in a new issue