summaryrefslogtreecommitdiffstats
path: root/api/team.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-06-07 17:43:06 -0400
committerJoram Wilander <jwawilander@gmail.com>2016-06-07 17:43:06 -0400
commit68c2b070da59bd2cf9c5cd91901a4e3bf6084061 (patch)
tree40b28fa96f65931a9c9e29724bf161c970e37362 /api/team.go
parent52b5db3a0b5d2ed3b96a72d8e8865d61d865320e (diff)
downloadchat-68c2b070da59bd2cf9c5cd91901a4e3bf6084061.tar.gz
chat-68c2b070da59bd2cf9c5cd91901a4e3bf6084061.tar.bz2
chat-68c2b070da59bd2cf9c5cd91901a4e3bf6084061.zip
Auto join teams if coming from team sign-up page to login for GitLab (#3284)
Diffstat (limited to 'api/team.go')
-rw-r--r--api/team.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/api/team.go b/api/team.go
index 8eb7c4fef..46bff617b 100644
--- a/api/team.go
+++ b/api/team.go
@@ -17,6 +17,7 @@ import (
"github.com/gorilla/mux"
"github.com/mattermost/platform/model"
+ "github.com/mattermost/platform/store"
"github.com/mattermost/platform/utils"
)
@@ -247,6 +248,14 @@ func CreateTeam(c *Context, team *model.Team) *model.Team {
}
}
+func JoinUserToTeamById(teamId string, user *model.User) *model.AppError {
+ if result := <-Srv.Store.Team().Get(teamId); result.Err != nil {
+ return result.Err
+ } else {
+ return JoinUserToTeam(result.Data.(*model.Team), user)
+ }
+}
+
func JoinUserToTeam(team *model.Team, user *model.User) *model.AppError {
tm := &model.TeamMember{TeamId: team.Id, UserId: user.Id}
@@ -258,6 +267,9 @@ func JoinUserToTeam(team *model.Team, user *model.User) *model.AppError {
}
if tmr := <-Srv.Store.Team().SaveMember(tm); tmr.Err != nil {
+ if tmr.Err.Id == store.TEAM_MEMBER_EXISTS_ERROR {
+ return nil
+ }
return tmr.Err
}