diff --git a/app/channel.go b/app/channel.go index 64d61c20aa..164a7e4176 100644 --- a/app/channel.go +++ b/app/channel.go @@ -614,7 +614,7 @@ func (a *App) createGroupChannel(c request.CTX, userIDs []string) (*model.Channe for _, user := range users { cm := &model.ChannelMember{ UserId: user.Id, - ChannelId: group.Id, + ChannelId: channel.Id, NotifyProps: model.GetDefaultChannelNotifyProps(), SchemeGuest: user.IsGuest(), SchemeUser: !user.IsGuest(), diff --git a/store/sqlstore/channel_store.go b/store/sqlstore/channel_store.go index cfd30c85c2..69b6835766 100644 --- a/store/sqlstore/channel_store.go +++ b/store/sqlstore/channel_store.go @@ -687,7 +687,9 @@ func (s SqlChannelStore) saveChannelT(transaction *sqlxTxWrapper, channel *model (:Id, :CreateAt, :UpdateAt, :DeleteAt, :TeamId, :Type, :DisplayName, :Name, :Header, :Purpose, :LastPostAt, :TotalMsgCount, :ExtraUpdateAt, :CreatorId, :SchemeId, :GroupConstrained, :Shared, :TotalMsgCountRoot, :LastRootPostAt)`, channel); err != nil { if IsUniqueConstraintError(err, []string{"Name", "channels_name_teamid_key"}) { dupChannel := model.Channel{} - s.GetMasterX().Get(&dupChannel, "SELECT * FROM Channels WHERE TeamId = ? AND Name = ?", channel.TeamId, channel.Name) + if serr := s.GetMasterX().Get(&dupChannel, "SELECT * FROM Channels WHERE TeamId = ? AND Name = ?", channel.TeamId, channel.Name); serr != nil { + return nil, errors.Wrapf(serr, "error while retrieving existing channel %s", channel.Name) // do not return this as a *store.ErrConflict as it would be treated as a recoverable error + } return &dupChannel, store.NewErrConflict("Channel", err, "id="+channel.Id) } return nil, errors.Wrapf(err, "save_channel: id=%s", channel.Id)