summaryrefslogtreecommitdiffstats
path: root/web/web.go
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2015-10-07 17:13:55 -0700
committer=Corey Hulen <corey@hulen.com>2015-10-07 17:13:55 -0700
commitf548e0ffb9a6b956b9732ae1ceab58a54b03d203 (patch)
treefb5a6e655800a85b1fa5b53346469afd3e2a7dcf /web/web.go
parentc189e2bb7681ba01edc9b8c5accd90b94c898d0a (diff)
downloadchat-f548e0ffb9a6b956b9732ae1ceab58a54b03d203.tar.gz
chat-f548e0ffb9a6b956b9732ae1ceab58a54b03d203.tar.bz2
chat-f548e0ffb9a6b956b9732ae1ceab58a54b03d203.zip
PLT-567 auto join open channels
Diffstat (limited to 'web/web.go')
-rw-r--r--web/web.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/web/web.go b/web/web.go
index b87636187..46e8e25a7 100644
--- a/web/web.go
+++ b/web/web.go
@@ -372,11 +372,22 @@ func getChannel(c *api.Context, w http.ResponseWriter, r *http.Request) {
return
}
- //api.Handle404(w, r)
- //Bad channel urls just redirect to the town-square for now
+ // We will attempt to auto-join open channels
+ if cr := <-api.Srv.Store.Channel().GetByName(c.Session.TeamId, name); cr.Err != nil {
+ http.Redirect(w, r, c.GetTeamURL()+"/channels/town-square", http.StatusFound)
+ } else {
+ channel := cr.Data.(*model.Channel)
+ if channel.Type == model.CHANNEL_OPEN {
+ api.JoinChannel(c, channel.Id, "")
+ if c.Err != nil {
+ return
+ }
- http.Redirect(w, r, c.GetTeamURL()+"/channels/town-square", http.StatusFound)
- return
+ channelId = channel.Id
+ } else {
+ http.Redirect(w, r, c.GetTeamURL()+"/channels/town-square", http.StatusFound)
+ }
+ }
}
}