summaryrefslogtreecommitdiffstats
path: root/web/web.go
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2015-10-08 09:49:29 -0700
committerCorey Hulen <corey@hulen.com>2015-10-08 09:49:29 -0700
commit26252ccebf23d8e0ce6cd0f6b79b268e5c3b90fd (patch)
treee82aedf48df06bd9802c22a3a8c66e9c5eae2ee0 /web/web.go
parentd30a694d11a0a7ae3474674b8a1a0e3472d4eae1 (diff)
parente640bf7b6c1f6b3f20db954b27430261c18accda (diff)
downloadchat-26252ccebf23d8e0ce6cd0f6b79b268e5c3b90fd.tar.gz
chat-26252ccebf23d8e0ce6cd0f6b79b268e5c3b90fd.tar.bz2
chat-26252ccebf23d8e0ce6cd0f6b79b268e5c3b90fd.zip
Merge pull request #971 from mattermost/PLT-567
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 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)
+ }
+ }
}
}