diff --git a/server/channels/app/channel.go b/server/channels/app/channel.go index 9f9417cae7..995ae2a482 100644 --- a/server/channels/app/channel.go +++ b/server/channels/app/channel.go @@ -534,7 +534,11 @@ func (a *App) createGroupChannel(c request.CTX, userIDs []string, creatorID stri return nil, model.NewAppError("CreateGroupChannel", "api.channel.create_group.bad_size.app_error", nil, "", http.StatusBadRequest) } - users, err := a.Srv().Store().User().GetProfileByIds(context.Background(), userIDs, nil, true) + // we skip cache and use master when fetching profiles to avoid + // issues in shared channels and HA, when users are created from a + // shared channels GM invite right before creating the GM + ctx := sqlstore.RequestContextWithMaster(c).Context() + users, err := a.Srv().Store().User().GetProfileByIds(ctx, userIDs, nil, false) if err != nil { return nil, model.NewAppError("createGroupChannel", "app.user.get_profiles.app_error", nil, "", http.StatusInternalServerError).Wrap(err) } @@ -650,7 +654,7 @@ func (a *App) createGroupChannel(c request.CTX, userIDs []string, creatorID stri } else { // if we could successfully share the channel, we invite // the remotes involved to it - if sc, _ := a.getSharedChannelsService(); sc != nil { + if sc, _ := a.getSharedChannelsService(false); sc != nil { for remoteID := range remoteIDs { rc, err := a.Srv().Store().RemoteCluster().Get(remoteID, false) if err != nil { diff --git a/server/platform/services/sharedchannel/channelinvite.go b/server/platform/services/sharedchannel/channelinvite.go index ebf1693008..f21a393316 100644 --- a/server/platform/services/sharedchannel/channelinvite.go +++ b/server/platform/services/sharedchannel/channelinvite.go @@ -559,7 +559,7 @@ func (scs *Service) createGroupChannel(invite channelInviteMsg, rc *model.Remote return nil, false, fmt.Errorf("cannot create group channel `%s` there are no local users", invite.ChannelId) } - // check if this DM already exists. + // check if this GM already exists. channelName := model.GetGroupNameFromUserIds(invite.DirectParticipantIDs) channelExists, err := scs.server.GetStore().Channel().GetByName("", channelName, true) if err != nil && !isNotFoundError(err) {