mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Config to make town square read only (#7140)
* Be able to make Town Square read-only (Disable typing messages for non admins). * Do not emit UserTypingEvent when TownSquareIsReadOnly and is Town Square. * Add unit tests for TownSquareIsReadOnly config value and logic. * Add TownSquareIsReadOnly to System console>Policy. Added Telemetry. * Add control for TownSquareIsReadOnly=true only for License Enterprise Edition E10 & E20. * Update en.json * Update en.json * Update policy_settings.jsx * Change config value from TownSquareIsReadOnly to ExperimentalTownSquareIsReadOnly. * Refactored to simplify. Avoid code repeat and multiple db calls.
This commit is contained in:
committed by
Joram Wilander
parent
baa992a559
commit
3c52801193
@@ -22,6 +22,12 @@ import (
|
||||
)
|
||||
|
||||
func TestCreatePost(t *testing.T) {
|
||||
adm := Setup().InitSystemAdmin()
|
||||
AdminClient := adm.SystemAdminClient
|
||||
adminTeam := adm.SystemAdminTeam
|
||||
adminUser := adm.CreateUser(adm.SystemAdminClient)
|
||||
LinkUserToTeam(adminUser, adminTeam)
|
||||
|
||||
th := Setup().InitBasic()
|
||||
Client := th.BasicClient
|
||||
team := th.BasicTeam
|
||||
@@ -142,6 +148,39 @@ func TestCreatePost(t *testing.T) {
|
||||
t.Fatal("should've attached all 3 files to post")
|
||||
}
|
||||
}
|
||||
|
||||
isLicensed := utils.IsLicensed()
|
||||
license := utils.License()
|
||||
disableTownSquareReadOnly := utils.Cfg.TeamSettings.ExperimentalTownSquareIsReadOnly
|
||||
defer func() {
|
||||
utils.Cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = disableTownSquareReadOnly
|
||||
utils.SetIsLicensed(isLicensed)
|
||||
utils.SetLicense(license)
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
}()
|
||||
*utils.Cfg.TeamSettings.ExperimentalTownSquareIsReadOnly = true
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
utils.SetIsLicensed(true)
|
||||
utils.SetLicense(&model.License{Features: &model.Features{}})
|
||||
utils.License().Features.SetDefaults()
|
||||
|
||||
defaultChannel := store.Must(app.Srv.Store.Channel().GetByName(team.Id, model.DEFAULT_CHANNEL, true)).(*model.Channel)
|
||||
defaultPost := &model.Post{
|
||||
ChannelId: defaultChannel.Id,
|
||||
Message: "Default Channel Post",
|
||||
}
|
||||
if _, err = Client.CreatePost(defaultPost); err == nil {
|
||||
t.Fatal("should have failed -- ExperimentalTownSquareIsReadOnly is true and it's a read only channel")
|
||||
}
|
||||
|
||||
adminDefaultChannel := store.Must(app.Srv.Store.Channel().GetByName(adminTeam.Id, model.DEFAULT_CHANNEL, true)).(*model.Channel)
|
||||
adminDefaultPost := &model.Post{
|
||||
ChannelId: adminDefaultChannel.Id,
|
||||
Message: "Admin Default Channel Post",
|
||||
}
|
||||
if _, err = AdminClient.CreatePost(adminDefaultPost); err != nil {
|
||||
t.Fatal("should not have failed -- ExperimentalTownSquareIsReadOnly is true and admin can post to channel")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreatePostWithCreateAt(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user