Use master to fetch user profiles when creating a GM (#32152)

Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es>
Этот коммит содержится в:
Miguel de la Cruz
2025-06-26 15:47:29 +02:00
коммит произвёл GitHub
родитель 124ceb54ee
Коммит d042d242dd
2 изменённых файлов: 7 добавлений и 3 удалений

Просмотреть файл

@@ -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 {

Просмотреть файл

@@ -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) {