mirror of
https://github.com/mattermost/mattermost.git
synced 2026-08-26 21:27:40 -05:00
Wait for channel membership before completing GM creation (#6133)
This commit is contained in:
committed by
George Goldberg
parent
934a4a05b2
commit
0171d2e8f0
+1
-1
@@ -124,7 +124,7 @@ func createGroupChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
userIds = append(userIds, c.Session.UserId)
|
||||
}
|
||||
|
||||
if sc, err := app.CreateGroupChannel(userIds); err != nil {
|
||||
if sc, err := app.CreateGroupChannel(userIds, c.Session.UserId); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
} else {
|
||||
|
||||
+5
-1
@@ -218,7 +218,7 @@ func WaitForChannelMembership(channelId string, userId string) {
|
||||
}
|
||||
}
|
||||
|
||||
func CreateGroupChannel(userIds []string) (*model.Channel, *model.AppError) {
|
||||
func CreateGroupChannel(userIds []string, creatorId string) (*model.Channel, *model.AppError) {
|
||||
if len(userIds) > model.CHANNEL_GROUP_MAX_USERS || len(userIds) < model.CHANNEL_GROUP_MIN_USERS {
|
||||
return nil, model.NewAppError("CreateGroupChannel", "api.channel.create_group.bad_size.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
@@ -261,6 +261,10 @@ func CreateGroupChannel(userIds []string) (*model.Channel, *model.AppError) {
|
||||
return nil, result.Err
|
||||
}
|
||||
|
||||
if user.Id == creatorId {
|
||||
WaitForChannelMembership(group.Id, creatorId)
|
||||
}
|
||||
|
||||
InvalidateCacheForUser(user.Id)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user