Actually make sure the user is in the channel before embedding channel data
This commit is contained in:
parent
8724121552
commit
7f755d2a83
@ -90,24 +90,30 @@ func getIndexData(r *http.Request, session *Session) *indexData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
server, channel := getTabFromPath(r.URL.EscapedPath())
|
server, channel := getTabFromPath(r.URL.EscapedPath())
|
||||||
if channel != "" {
|
if isInChannel(channels, server, channel) {
|
||||||
data.addUsersAndMessages(server, channel, session)
|
data.addUsersAndMessages(server, channel, session)
|
||||||
return &data
|
return &data
|
||||||
}
|
}
|
||||||
|
|
||||||
server, channel = parseTabCookie(r, r.URL.Path)
|
server, channel = parseTabCookie(r, r.URL.Path)
|
||||||
if channel != "" {
|
if isInChannel(channels, server, channel) {
|
||||||
for _, ch := range channels {
|
data.addUsersAndMessages(server, channel, session)
|
||||||
if server == ch.Server && channel == ch.Name {
|
|
||||||
data.addUsersAndMessages(server, channel, session)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &data
|
return &data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isInChannel(channels []storage.Channel, server, channel string) bool {
|
||||||
|
if channel != "" {
|
||||||
|
for _, ch := range channels {
|
||||||
|
if server == ch.Server && channel == ch.Name {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func getTabFromPath(rawPath string) (string, string) {
|
func getTabFromPath(rawPath string) (string, string) {
|
||||||
path := strings.Split(strings.Trim(rawPath, "/"), "/")
|
path := strings.Split(strings.Trim(rawPath, "/"), "/")
|
||||||
if len(path) == 2 {
|
if len(path) == 2 {
|
||||||
|
Loading…
Reference in New Issue
Block a user