[MM-53086] Remove SendWelcomePost A/B test and feature (#23733)
Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
@@ -895,7 +895,6 @@ type AppIface interface {
|
||||
InviteNewUsersToTeamGracefully(memberInvite *model.MemberInvite, teamID, senderId string, reminderInterval string) ([]*model.EmailInviteWithError, *model.AppError)
|
||||
IsCRTEnabledForUser(c request.CTX, userID string) bool
|
||||
IsConfigReadOnly() bool
|
||||
IsFirstAdmin(user *model.User) bool
|
||||
IsFirstUserAccount() bool
|
||||
IsLeader() bool
|
||||
IsPasswordValid(password string) *model.AppError
|
||||
|
||||
@@ -12,8 +12,6 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/logr/v2"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/public/plugin"
|
||||
"github.com/mattermost/mattermost/server/public/shared/i18n"
|
||||
@@ -189,35 +187,6 @@ func (a *App) JoinDefaultChannels(c request.CTX, teamID string, user *model.User
|
||||
message.Add("user_id", user.Id)
|
||||
message.Add("team_id", channel.TeamId)
|
||||
a.Publish(message)
|
||||
|
||||
// A/B Test on the welcome post
|
||||
if a.Config().FeatureFlags.SendWelcomePost && channelName == model.DefaultChannelName {
|
||||
nbTeams, err := a.Srv().Store().Team().AnalyticsTeamCount(&model.TeamSearch{
|
||||
IncludeDeleted: model.NewBool(true),
|
||||
})
|
||||
if err != nil {
|
||||
c.Logger().Warn("unable to get number of teams", logr.Err(err))
|
||||
return nil
|
||||
}
|
||||
|
||||
if nbTeams == 1 && a.IsFirstAdmin(user) {
|
||||
// Post the welcome message
|
||||
if _, err := a.CreatePost(c, &model.Post{
|
||||
ChannelId: channel.Id,
|
||||
Type: model.PostTypeWelcomePost,
|
||||
UserId: user.Id,
|
||||
}, channel, false, false); err != nil {
|
||||
c.Logger().Warn("unable to post welcome message", logr.Err(err))
|
||||
return nil
|
||||
}
|
||||
ts := a.Srv().GetTelemetryService()
|
||||
if ts != nil {
|
||||
ts.SendTelemetry("welcome-message-sent", map[string]any{
|
||||
"category": "growth",
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if nErr != nil {
|
||||
|
||||
@@ -12003,23 +12003,6 @@ func (a *OpenTracingAppLayer) IsConfigReadOnly() bool {
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) IsFirstAdmin(user *model.User) bool {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.IsFirstAdmin")
|
||||
|
||||
a.ctx = newCtx
|
||||
a.app.Srv().Store().SetContext(newCtx)
|
||||
defer func() {
|
||||
a.app.Srv().Store().SetContext(origCtx)
|
||||
a.ctx = origCtx
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0 := a.app.IsFirstAdmin(user)
|
||||
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) IsFirstUserAccount() bool {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.IsFirstUserAccount")
|
||||
|
||||
@@ -217,19 +217,6 @@ func (a *App) IsFirstUserAccount() bool {
|
||||
return a.ch.srv.platform.IsFirstUserAccount()
|
||||
}
|
||||
|
||||
func (a *App) IsFirstAdmin(user *model.User) bool {
|
||||
if !user.IsSystemAdmin() {
|
||||
return false
|
||||
}
|
||||
|
||||
adminID, err := a.Srv().Store().User().GetFirstSystemAdminID()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return adminID == user.Id
|
||||
}
|
||||
|
||||
// CreateUser creates a user and sets several fields of the returned User struct to
|
||||
// their zero values.
|
||||
func (a *App) CreateUser(c request.CTX, user *model.User) (*model.User, *model.AppError) {
|
||||
|
||||
@@ -1875,57 +1875,6 @@ func TestCreateUserWithInitialPreferences(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestIsFirstAdmin(t *testing.T) {
|
||||
t.Run("should return false if user is not sysadmin", func(t *testing.T) {
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
Id := model.NewId()
|
||||
isFirstAdmin := th.App.IsFirstAdmin(&model.User{
|
||||
Id: Id,
|
||||
Roles: model.SystemUserRoleId,
|
||||
})
|
||||
require.False(t, isFirstAdmin)
|
||||
})
|
||||
|
||||
t.Run("should return false if user is sysadmin but not the first one", func(t *testing.T) {
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
Id := model.NewId()
|
||||
|
||||
mockUserStore := storemocks.UserStore{}
|
||||
mockUserStore.On("GetFirstSystemAdminID").Return(model.NewId(), nil)
|
||||
|
||||
mockStore := th.App.Srv().Store().(*storemocks.Store)
|
||||
mockStore.On("User").Return(&mockUserStore)
|
||||
|
||||
isFirstAdmin := th.App.IsFirstAdmin(&model.User{
|
||||
Id: Id,
|
||||
Roles: model.SystemAdminRoleId,
|
||||
})
|
||||
require.False(t, isFirstAdmin)
|
||||
})
|
||||
|
||||
t.Run("should return true if user is sysadmin and the first one", func(t *testing.T) {
|
||||
th := SetupWithStoreMock(t)
|
||||
defer th.TearDown()
|
||||
|
||||
Id := model.NewId()
|
||||
|
||||
mockStore := th.App.Srv().Store().(*storemocks.Store)
|
||||
mockUserStore := storemocks.UserStore{}
|
||||
mockUserStore.On("GetFirstSystemAdminID").Return(Id, nil)
|
||||
mockStore.On("User").Return(&mockUserStore)
|
||||
|
||||
isFirstAdmin := th.App.IsFirstAdmin(&model.User{
|
||||
Id: Id,
|
||||
Roles: model.SystemAdminRoleId,
|
||||
})
|
||||
require.True(t, isFirstAdmin)
|
||||
})
|
||||
}
|
||||
|
||||
func TestSendSubscriptionHistoryEvent(t *testing.T) {
|
||||
cloudProduct := &model.Product{
|
||||
ID: "prod_test1",
|
||||
|
||||
Ссылка в новой задаче
Block a user