[MM-47145] My Insights license change (#21443)
* tools updates * Revert "tools updates" This reverts commit 6293297b55803c5a263e200ebd80192899666ae9. * remove license checks for my insights endpoints * removing new config * remove license checks from insights test * adding some license tests for team endpoints * fixing tests Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.local> Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MBP.ht.home> Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MBP.fritz.box> Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.fritz.box> Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
@@ -99,13 +99,8 @@ func getTopReactionsForTeamSince(c *Context, w http.ResponseWriter, r *http.Requ
|
||||
}
|
||||
|
||||
func getTopReactionsForUserSince(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
// license and guest user check
|
||||
permissionErr := minimumProfessionalLicense(c)
|
||||
if permissionErr != nil {
|
||||
c.Err = permissionErr
|
||||
return
|
||||
}
|
||||
permissionErr = rejectGuests(c)
|
||||
// guest user check
|
||||
permissionErr := rejectGuests(c)
|
||||
if permissionErr != nil {
|
||||
c.Err = permissionErr
|
||||
return
|
||||
@@ -233,13 +228,8 @@ func getTopChannelsForTeamSince(c *Context, w http.ResponseWriter, r *http.Reque
|
||||
}
|
||||
|
||||
func getTopChannelsForUserSince(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
// license and guest user check
|
||||
permissionErr := minimumProfessionalLicense(c)
|
||||
if permissionErr != nil {
|
||||
c.Err = permissionErr
|
||||
return
|
||||
}
|
||||
permissionErr = rejectGuests(c)
|
||||
// guest user check
|
||||
permissionErr := rejectGuests(c)
|
||||
if permissionErr != nil {
|
||||
c.Err = permissionErr
|
||||
return
|
||||
@@ -367,13 +357,8 @@ func getTopThreadsForTeamSince(c *Context, w http.ResponseWriter, r *http.Reques
|
||||
}
|
||||
|
||||
func getTopThreadsForUserSince(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
// license and guest user check
|
||||
permissionErr := minimumProfessionalLicense(c)
|
||||
if permissionErr != nil {
|
||||
c.Err = permissionErr
|
||||
return
|
||||
}
|
||||
permissionErr = rejectGuests(c)
|
||||
// guest user check
|
||||
permissionErr := rejectGuests(c)
|
||||
if permissionErr != nil {
|
||||
c.Err = permissionErr
|
||||
return
|
||||
@@ -433,13 +418,8 @@ func getTopThreadsForUserSince(c *Context, w http.ResponseWriter, r *http.Reques
|
||||
|
||||
// Top DMs
|
||||
func getTopDMsForUserSince(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
// license and guest user check
|
||||
permissionErr := minimumProfessionalLicense(c)
|
||||
if permissionErr != nil {
|
||||
c.Err = permissionErr
|
||||
return
|
||||
}
|
||||
permissionErr = rejectGuests(c)
|
||||
// guest user check
|
||||
permissionErr := rejectGuests(c)
|
||||
if permissionErr != nil {
|
||||
c.Err = permissionErr
|
||||
return
|
||||
@@ -540,13 +520,8 @@ func getTopInactiveChannelsForTeamSince(c *Context, w http.ResponseWriter, r *ht
|
||||
// top inactive channels
|
||||
|
||||
func getTopInactiveChannelsForUserSince(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
// license and guest user check
|
||||
permissionErr := minimumProfessionalLicense(c)
|
||||
if permissionErr != nil {
|
||||
c.Err = permissionErr
|
||||
return
|
||||
}
|
||||
permissionErr = rejectGuests(c)
|
||||
// guest user check
|
||||
permissionErr := rejectGuests(c)
|
||||
if permissionErr != nil {
|
||||
c.Err = permissionErr
|
||||
return
|
||||
|
||||
@@ -242,14 +242,20 @@ func TestGetTopReactionsForTeamSince(t *testing.T) {
|
||||
assert.Error(t, err)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
})
|
||||
|
||||
t.Run("get-top-reactions-for-team-since invalid license", func(t *testing.T) {
|
||||
th.App.Srv().SetLicense(model.NewTestLicense(""))
|
||||
|
||||
_, resp, err := client.GetTopReactionsForTeamSince(teamId, model.TimeRangeToday, 0, 5)
|
||||
assert.Error(t, err)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetTopReactionsForUserSince(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional))
|
||||
|
||||
client := th.Client
|
||||
|
||||
userId := th.BasicUser.Id
|
||||
@@ -539,14 +545,20 @@ func TestGetTopChannelsForTeamSince(t *testing.T) {
|
||||
assert.Error(t, err)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
})
|
||||
|
||||
t.Run("get-top-channels-for-team-since invalid license", func(t *testing.T) {
|
||||
th.App.Srv().SetLicense(model.NewTestLicense(""))
|
||||
|
||||
_, resp, err := client.GetTopChannelsForTeamSince(teamId, model.TimeRangeToday, 0, 5)
|
||||
assert.Error(t, err)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetTopChannelsForUserSince(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional))
|
||||
|
||||
client := th.Client
|
||||
userId := th.BasicUser.Id
|
||||
|
||||
@@ -708,12 +720,19 @@ func TestGetTopThreadsForTeamSince(t *testing.T) {
|
||||
topTeamThreadsByUser2IncludingPrivate, _, _ := client.GetTopThreadsForTeamSince(th.BasicTeam.Id, model.TimeRangeToday, 0, 10)
|
||||
require.Nil(t, appErr)
|
||||
require.Len(t, topTeamThreadsByUser2IncludingPrivate.Items, 2)
|
||||
|
||||
t.Run("get-top-threads-for-team-since invalid license", func(t *testing.T) {
|
||||
th.App.Srv().SetLicense(model.NewTestLicense(""))
|
||||
|
||||
_, resp, err := client.GetTopThreadsForTeamSince(th.BasicTeam.Id, model.TimeRangeToday, 0, 5)
|
||||
assert.Error(t, err)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetTopThreadsForUserSince(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional))
|
||||
|
||||
th.LoginBasic()
|
||||
client := th.Client
|
||||
@@ -958,6 +977,14 @@ func TestGetTopInactiveChannelsForTeamSince(t *testing.T) {
|
||||
assert.Equal(t, expectedTopChannels[i].ID, channel.ID)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("get-top-inactive-channels-for-team-since invalid license", func(t *testing.T) {
|
||||
th.App.Srv().SetLicense(model.NewTestLicense(""))
|
||||
|
||||
_, resp, err := client.GetTopInactiveChannelsForTeamSince(teamId, model.TimeRangeToday, 0, 5)
|
||||
assert.Error(t, err)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetTopDMsForUserSince(t *testing.T) {
|
||||
@@ -970,7 +997,6 @@ func TestGetTopDMsForUserSince(t *testing.T) {
|
||||
*c.TeamSettings.EnableUserDeactivation = true
|
||||
})
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableBotAccountCreation = true })
|
||||
th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuProfessional))
|
||||
|
||||
// basicuser1 - bu1, basicuser - bu
|
||||
// create dm channels for bu-bu, bu1-bu1, bu-bu1, bot-bu
|
||||
@@ -1169,4 +1195,12 @@ func TestNewTeamMembersSince(t *testing.T) {
|
||||
require.Len(t, list.Items, 1)
|
||||
require.False(t, list.HasNext)
|
||||
})
|
||||
|
||||
t.Run("get-new-team-members-since invalid license", func(t *testing.T) {
|
||||
th.App.Srv().SetLicense(model.NewTestLicense(""))
|
||||
|
||||
_, resp, err := th.Client.GetNewTeamMembersSince(team.Id, model.TimeRangeToday, 0, 2)
|
||||
assert.Error(t, err)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ func GenerateClientConfig(c *model.Config, telemetryID string, license *model.Li
|
||||
props["ExperimentalSharedChannels"] = "false"
|
||||
props["CollapsedThreads"] = *c.ServiceSettings.CollapsedThreads
|
||||
props["EnableCustomGroups"] = "false"
|
||||
props["InsightsEnabled"] = "false"
|
||||
props["InsightsEnabled"] = strconv.FormatBool(c.FeatureFlags.InsightsEnabled)
|
||||
props["PostPriority"] = strconv.FormatBool(*c.ServiceSettings.PostPriority)
|
||||
|
||||
if license != nil {
|
||||
@@ -206,10 +206,6 @@ func GenerateClientConfig(c *model.Config, telemetryID string, license *model.Li
|
||||
if license.SkuShortName == model.LicenseShortSkuProfessional || license.SkuShortName == model.LicenseShortSkuEnterprise {
|
||||
props["EnableCustomGroups"] = strconv.FormatBool(*c.ServiceSettings.EnableCustomGroups)
|
||||
}
|
||||
|
||||
if (license.SkuShortName == model.LicenseShortSkuProfessional || license.SkuShortName == model.LicenseShortSkuEnterprise) && c.FeatureFlags.InsightsEnabled {
|
||||
props["InsightsEnabled"] = "true"
|
||||
}
|
||||
}
|
||||
|
||||
return props
|
||||
|
||||
@@ -195,7 +195,7 @@ func TestGetClientConfig(t *testing.T) {
|
||||
SkuShortName: "other",
|
||||
},
|
||||
map[string]string{
|
||||
"InsightsEnabled": "false",
|
||||
"InsightsEnabled": "true",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Ссылка в новой задаче
Block a user