diff options
Diffstat (limited to 'web/web.go')
-rw-r--r-- | web/web.go | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/web/web.go b/web/web.go index b87636187..7ab50a073 100644 --- a/web/web.go +++ b/web/web.go @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. +// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. package web @@ -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) + } + } } } @@ -414,7 +425,12 @@ func verifyEmail(c *api.Context, w http.ResponseWriter, r *http.Request) { return } else { user := result.Data.(*model.User) - api.FireAndForgetVerifyEmail(user.Id, user.Email, team.Name, team.DisplayName, c.GetSiteURL(), c.GetTeamURLFromTeam(team)) + + if user.LastActivityAt > 0 { + api.FireAndForgetEmailChangeVerifyEmail(user.Id, user.Email, team.Name, team.DisplayName, c.GetSiteURL(), c.GetTeamURLFromTeam(team)) + } else { + api.FireAndForgetVerifyEmail(user.Id, user.Email, team.Name, team.DisplayName, c.GetSiteURL(), c.GetTeamURLFromTeam(team)) + } newAddress := strings.Replace(r.URL.String(), "&resend=true", "&resend_success=true", -1) http.Redirect(w, r, newAddress, http.StatusFound) |