summaryrefslogtreecommitdiffstats
path: root/api/user.go
diff options
context:
space:
mode:
authorAsaad Mahmood <Unknowngi@live.com>2015-10-16 18:06:40 +0500
committerAsaad Mahmood <Unknowngi@live.com>2015-10-16 18:06:40 +0500
commit0fbe63eb37b0764a106b0fdd47bc149f122b520d (patch)
tree77cadc54d3a8d0e7812e69c50628cc7f3c5d71b7 /api/user.go
parentb00ffa83e7371fa7dd4570130ee8b506943aee01 (diff)
parent89716cb046ee3c8f13b361053d91149f5ce29cbf (diff)
downloadchat-0fbe63eb37b0764a106b0fdd47bc149f122b520d.tar.gz
chat-0fbe63eb37b0764a106b0fdd47bc149f122b520d.tar.bz2
chat-0fbe63eb37b0764a106b0fdd47bc149f122b520d.zip
Merge branch 'master' of https://github.com/mattermost/platform into ui-improvements
Diffstat (limited to 'api/user.go')
-rw-r--r--api/user.go43
1 files changed, 42 insertions, 1 deletions
diff --git a/api/user.go b/api/user.go
index 146ede015..ac33e81a1 100644
--- a/api/user.go
+++ b/api/user.go
@@ -198,7 +198,9 @@ func CreateUser(c *Context, team *model.Team, user *model.User) *model.User {
l4g.Error("Encountered an issue joining default channels user_id=%s, team_id=%s, err=%v", ruser.Id, ruser.TeamId, err)
}
- fireAndForgetWelcomeEmail(result.Data.(*model.User).Id, ruser.Email, team.Name, team.DisplayName, c.GetSiteURL(), c.GetTeamURLFromTeam(team), user.EmailVerified)
+ fireAndForgetWelcomeEmail(ruser.Id, ruser.Email, team.Name, team.DisplayName, c.GetSiteURL(), c.GetTeamURLFromTeam(team), user.EmailVerified)
+
+ addDirectChannelsAndForget(ruser)
if user.EmailVerified {
if cresult := <-Srv.Store.User().VerifyEmail(ruser.Id); cresult.Err != nil {
@@ -237,6 +239,45 @@ func fireAndForgetWelcomeEmail(userId, email, teamName, teamDisplayName, siteURL
}()
}
+func addDirectChannelsAndForget(user *model.User) {
+ go func() {
+ var profiles map[string]*model.User
+ if result := <-Srv.Store.User().GetProfiles(user.TeamId); result.Err != nil {
+ l4g.Error("Failed to add direct channel preferences for user user_id=%s, team_id=%s, err=%v", user.Id, user.TeamId, result.Err.Error())
+ return
+ } else {
+ profiles = result.Data.(map[string]*model.User)
+ }
+
+ var preferences model.Preferences
+
+ for id := range profiles {
+ if id == user.Id {
+ continue
+ }
+
+ profile := profiles[id]
+
+ preference := model.Preference{
+ UserId: user.Id,
+ Category: model.PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW,
+ Name: profile.Id,
+ Value: "true",
+ }
+
+ preferences = append(preferences, preference)
+
+ if len(preferences) >= 10 {
+ break
+ }
+ }
+
+ if result := <-Srv.Store.Preference().Save(&preferences); result.Err != nil {
+ l4g.Error("Failed to add direct channel preferences for new user user_id=%s, eam_id=%s, err=%v", user.Id, user.TeamId, result.Err.Error())
+ }
+ }()
+}
+
func FireAndForgetVerifyEmail(userId, userEmail, teamName, teamDisplayName, siteURL, teamURL string) {
go func() {