Grab referer in /init handler instead of getIndexData()
This commit is contained in:
parent
bd0541120f
commit
9b40934654
|
@ -83,15 +83,6 @@ func getIndexData(r *http.Request, path string, state *State) *indexData {
|
|||
}
|
||||
data.Channels = channels
|
||||
|
||||
referer, err := url.Parse(r.Header.Get("Referer"))
|
||||
if err == nil {
|
||||
server, channel := getTabFromPath(referer.EscapedPath())
|
||||
if isInChannel(channels, server, channel) {
|
||||
data.addUsersAndMessages(server, channel, state)
|
||||
return &data
|
||||
}
|
||||
}
|
||||
|
||||
server, channel := getTabFromPath(path)
|
||||
if isInChannel(channels, server, channel) {
|
||||
data.addUsersAndMessages(server, channel, state)
|
||||
|
|
|
@ -181,10 +181,17 @@ func (d *Dispatch) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
d.upgradeWS(w, r, state)
|
||||
} else if strings.HasPrefix(r.URL.Path, "/init") {
|
||||
referer, err := url.Parse(r.Header.Get("Referer"))
|
||||
if err != nil {
|
||||
fail(w, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
state := d.handleAuth(w, r, true, true)
|
||||
data := getIndexData(r, "/", state)
|
||||
data := getIndexData(r, referer.EscapedPath(), state)
|
||||
|
||||
writeJSON(w, r, data)
|
||||
|
||||
} else {
|
||||
d.serveFiles(w, r)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue