MM-55733 add request context to Channelstore.Save method (#26141)
Этот коммит содержится в:
@@ -220,7 +220,7 @@ func (a *App) RenameChannel(c request.CTX, channel *model.Channel, newChannelNam
|
||||
|
||||
func (a *App) CreateChannel(c request.CTX, channel *model.Channel, addMember bool) (*model.Channel, *model.AppError) {
|
||||
channel.DisplayName = strings.TrimSpace(channel.DisplayName)
|
||||
sc, nErr := a.Srv().Store().Channel().Save(channel, *a.Config().TeamSettings.MaxChannelsPerTeam)
|
||||
sc, nErr := a.Srv().Store().Channel().Save(c, channel, *a.Config().TeamSettings.MaxChannelsPerTeam)
|
||||
if nErr != nil {
|
||||
var invErr *store.ErrInvalidInput
|
||||
var cErr *store.ErrConflict
|
||||
@@ -528,7 +528,7 @@ func (a *App) createGroupChannel(c request.CTX, userIDs []string) (*model.Channe
|
||||
Type: model.ChannelTypeGroup,
|
||||
}
|
||||
|
||||
channel, nErr := a.Srv().Store().Channel().Save(group, *a.Config().TeamSettings.MaxChannelsPerTeam)
|
||||
channel, nErr := a.Srv().Store().Channel().Save(c, group, *a.Config().TeamSettings.MaxChannelsPerTeam)
|
||||
if nErr != nil {
|
||||
var invErr *store.ErrInvalidInput
|
||||
var cErr *store.ErrConflict
|
||||
|
||||
@@ -189,7 +189,7 @@ func (th *TestHelper) createChannel(team *model.Team, channelType string) *model
|
||||
}
|
||||
|
||||
var err error
|
||||
if channel, err = th.store.Channel().Save(channel, *th.configStore.Get().TeamSettings.MaxChannelsPerTeam); err != nil {
|
||||
if channel, err = th.store.Channel().Save(th.Context, channel, *th.configStore.Get().TeamSettings.MaxChannelsPerTeam); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -283,7 +283,7 @@ func (th *TestHelper) CreateChannel(team *model.Team, options ...ChannelOption)
|
||||
}
|
||||
|
||||
var err error
|
||||
channel, err = th.Service.Store.Channel().Save(channel, 999)
|
||||
channel, err = th.Service.Store.Channel().Save(th.Context, channel, 999)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ func (a *App) AdjustTeamsFromProductLimits(teamLimits *model.TeamsLimits) *model
|
||||
}
|
||||
|
||||
func (a *App) CreateTeam(c request.CTX, team *model.Team) (*model.Team, *model.AppError) {
|
||||
rteam, err := a.ch.srv.teamService.CreateTeam(team)
|
||||
rteam, err := a.ch.srv.teamService.CreateTeam(c, team)
|
||||
if err != nil {
|
||||
var invErr *store.ErrInvalidInput
|
||||
|
||||
|
||||
@@ -9,14 +9,14 @@ import (
|
||||
"github.com/mattermost/mattermost/server/public/shared/request"
|
||||
)
|
||||
|
||||
func (ts *TeamService) CreateTeam(team *model.Team) (*model.Team, error) {
|
||||
func (ts *TeamService) CreateTeam(rctx request.CTX, team *model.Team) (*model.Team, error) {
|
||||
team.InviteId = ""
|
||||
rteam, err := ts.store.Save(team)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if _, err := ts.createDefaultChannels(rteam.Id); err != nil {
|
||||
if _, err := ts.createDefaultChannels(rctx, rteam.Id); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ func (ts *TeamService) GetTeams(teamIDs []string) ([]*model.Team, error) {
|
||||
}
|
||||
|
||||
// CreateDefaultChannels creates channels in the given team for each channel returned by (*App).DefaultChannelNames.
|
||||
func (ts *TeamService) createDefaultChannels(teamID string) ([]*model.Channel, error) {
|
||||
func (ts *TeamService) createDefaultChannels(rctx request.CTX, teamID string) ([]*model.Channel, error) {
|
||||
displayNames := map[string]string{
|
||||
"town-square": i18n.T("api.channel.create_default_channels.town_square"),
|
||||
"off-topic": i18n.T("api.channel.create_default_channels.off_topic"),
|
||||
@@ -56,7 +56,7 @@ func (ts *TeamService) createDefaultChannels(teamID string) ([]*model.Channel, e
|
||||
// and let the subscribers do the job, in this case it would be the channels service.
|
||||
// Currently we are adding services to the server and because of that we are using
|
||||
// the channel store here. This should be replaced in the future.
|
||||
if _, err := ts.channelStore.Save(channel, *ts.config().TeamSettings.MaxChannelsPerTeam); err != nil {
|
||||
if _, err := ts.channelStore.Save(rctx, channel, *ts.config().TeamSettings.MaxChannelsPerTeam); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
channels = append(channels, channel)
|
||||
|
||||
@@ -24,10 +24,10 @@ func TestCreateTeam(t *testing.T) {
|
||||
Type: model.TeamOpen,
|
||||
}
|
||||
|
||||
_, err := th.service.CreateTeam(team)
|
||||
_, err := th.service.CreateTeam(th.Context, team)
|
||||
require.NoError(t, err, "Should create a new team")
|
||||
|
||||
_, err = th.service.CreateTeam(team)
|
||||
_, err = th.service.CreateTeam(th.Context, team)
|
||||
require.Error(t, err, "Should not create a new team - team already exist")
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ func TestJoinUserToTeam(t *testing.T) {
|
||||
Type: model.TeamOpen,
|
||||
}
|
||||
|
||||
_, err := th.service.CreateTeam(team)
|
||||
_, err := th.service.CreateTeam(th.Context, team)
|
||||
require.NoError(t, err, "Should create a new team")
|
||||
|
||||
maxUsersPerTeam := th.service.config().TeamSettings.MaxUsersPerTeam
|
||||
|
||||
Ссылка в новой задаче
Block a user