[MM-44475] Team Unarchive: Do not allow to unarchive if workspace has reached the limit of teams (#20281)
* Prevent cloud limited installations from restoring teams when at or above the teams limit * Code clean up * fix i18n * Actually fix i18n * updates for govet * Update model/client4.go Co-authored-by: Vishal <vish9812@gmail.com> * [MM-44397] Restrict team creation based on subscription limits (#20282) * restrict team creation based on limits * Update api4/team.go Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com> * Fix tests Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com> * Add additional field to teamsusage * Fix * remove useless test * Fix error for team creation * Remove apostrophe Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: Vishal <vish9812@gmail.com> Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com>
Этот коммит содержится в:
@@ -757,6 +757,7 @@ type AppIface interface {
|
||||
GetTeamsForSchemePage(scheme *model.Scheme, page int, perPage int) ([]*model.Team, *model.AppError)
|
||||
GetTeamsForUser(userID string) ([]*model.Team, *model.AppError)
|
||||
GetTeamsUnreadForUser(excludeTeamId string, userID string, includeCollapsedThreads bool) ([]*model.TeamUnread, *model.AppError)
|
||||
GetTeamsUsage() (*model.TeamsUsage, *model.AppError)
|
||||
GetTermsOfService(id string) (*model.TermsOfService, *model.AppError)
|
||||
GetThreadForUser(teamID string, threadMembership *model.ThreadMembership, extended bool) (*model.ThreadResponse, *model.AppError)
|
||||
GetThreadMembershipForUser(userId, threadId string) (*model.ThreadMembership, *model.AppError)
|
||||
|
||||
@@ -9596,6 +9596,28 @@ func (a *OpenTracingAppLayer) GetTeamsUnreadForUser(excludeTeamId string, userID
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetTeamsUsage() (*model.TeamsUsage, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetTeamsUsage")
|
||||
|
||||
a.ctx = newCtx
|
||||
a.app.Srv().Store.SetContext(newCtx)
|
||||
defer func() {
|
||||
a.app.Srv().Store.SetContext(origCtx)
|
||||
a.ctx = origCtx
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1 := a.app.GetTeamsUsage()
|
||||
|
||||
if resultVar1 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar1))
|
||||
ext.Error.Set(span, true)
|
||||
}
|
||||
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetTermsOfService(id string) (*model.TermsOfService, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetTermsOfService")
|
||||
|
||||
28
app/usage.go
28
app/usage.go
@@ -54,3 +54,31 @@ func (a *App) GetPostsUsage() (int64, *model.AppError) {
|
||||
|
||||
return utils.RoundOffToZeroes(float64(count)), nil
|
||||
}
|
||||
|
||||
func (a *App) GetTeamsUsage() (*model.TeamsUsage, *model.AppError) {
|
||||
usage := &model.TeamsUsage{}
|
||||
includeDeleted := false
|
||||
teamCount, err := a.Srv().Store.Team().AnalyticsTeamCount(&model.TeamSearch{IncludeDeleted: &includeDeleted})
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetTeamsUsage", "app.post.analytics_teams_count.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
usage.Active = teamCount
|
||||
|
||||
allTeams, appErr := a.GetAllTeams()
|
||||
if appErr != nil {
|
||||
return nil, appErr
|
||||
}
|
||||
|
||||
cloudArchivedTeamCount := 0
|
||||
|
||||
for _, team := range allTeams {
|
||||
if team.DeleteAt > 0 && team.CloudLimitsArchived {
|
||||
cloudArchivedTeamCount += 1
|
||||
}
|
||||
}
|
||||
|
||||
usage.CloudArchived = int64(cloudArchivedTeamCount)
|
||||
|
||||
return usage, nil
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user