summaryrefslogtreecommitdiffstats
path: root/web/web.go
diff options
context:
space:
mode:
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 87c96659d..8dfac4a8d 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)
+ }
+ }
}
}