mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* PLT-6787 Fixed being able to send a post before files finished uploading (#6617) * Fix quick switcher for channels/users not stored locally (#6610) * Fix button text on confirm mention modal (#6609) * fix post delete permission of channel admin (#6608) * open comment thread for the most recent reply-able message (#6605) * Use mutex flag with yarn to prevent concurrent builds interfering (#6619) * Use mutex flag with yarn to prevent concurrent builds interfering * Remove yarn mutex file with clean * Minor bug fixes (#6615) * PLT-6774 - Fixing color for offline icon * PLT-6784 - Fixing status icon * Fixing icon margin * Updating caret position * PLT-6070 Have ChannelMentionProvider stop searching after a term returns no results (#6620) * Fixing JS error (#6623) * Minor bug fixes (#6622) * PLT-6808 - Updating channel switcher on mobile * PLT-6743 - Updating scrollbar styling * Login instead of failing if user exists in OAuth sign-up flow (#6627) * PLT-6802 Disable team switcher (#6626) * Disable team switcher * Fix ESLint errors * PLT-6807 Ensured select teams page can scroll on iOS (#6630) * Do not redirect from account switch pages on 401 (#6631) * Fixing loadtest command and renaming to /test (#6624) * PLT-6820 Update mattermost-redux dependency (#6632) * translations PR 20170612 (#6629) * Bump HTTP client timeout to 30 seconds (#6633) * For team unreads return empty array instead of null (#6636) * PLT-6831 Fix status modal localization IDs (#6637) * Fix status modal localization IDs * Update test snapshot
110 lines
3.0 KiB
Go
110 lines
3.0 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
package app
|
|
|
|
import (
|
|
"github.com/mattermost/platform/model"
|
|
"github.com/mattermost/platform/store"
|
|
"github.com/mattermost/platform/utils"
|
|
|
|
l4g "github.com/alecthomas/log4go"
|
|
)
|
|
|
|
type AutoUserCreator struct {
|
|
client *model.Client
|
|
team *model.Team
|
|
EmailLength utils.Range
|
|
EmailCharset string
|
|
NameLength utils.Range
|
|
NameCharset string
|
|
Fuzzy bool
|
|
}
|
|
|
|
func NewAutoUserCreator(client *model.Client, team *model.Team) *AutoUserCreator {
|
|
return &AutoUserCreator{
|
|
client: client,
|
|
team: team,
|
|
EmailLength: USER_EMAIL_LEN,
|
|
EmailCharset: utils.LOWERCASE,
|
|
NameLength: USER_NAME_LEN,
|
|
NameCharset: utils.LOWERCASE,
|
|
Fuzzy: false,
|
|
}
|
|
}
|
|
|
|
// Basic test team and user so you always know one
|
|
func CreateBasicUser(client *model.Client) *model.AppError {
|
|
result, _ := client.FindTeamByName(BTEST_TEAM_NAME)
|
|
if result.Data.(bool) == false {
|
|
newteam := &model.Team{DisplayName: BTEST_TEAM_DISPLAY_NAME, Name: BTEST_TEAM_NAME, Email: BTEST_TEAM_EMAIL, Type: BTEST_TEAM_TYPE}
|
|
result, err := client.CreateTeam(newteam)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
basicteam := result.Data.(*model.Team)
|
|
newuser := &model.User{Email: BTEST_USER_EMAIL, Nickname: BTEST_USER_NAME, Password: BTEST_USER_PASSWORD}
|
|
result, err = client.CreateUser(newuser, "")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
ruser := result.Data.(*model.User)
|
|
store.Must(Srv.Store.User().VerifyEmail(ruser.Id))
|
|
store.Must(Srv.Store.Team().SaveMember(&model.TeamMember{TeamId: basicteam.Id, UserId: ruser.Id}))
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (cfg *AutoUserCreator) createRandomUser() (*model.User, bool) {
|
|
var userEmail string
|
|
var userName string
|
|
if cfg.Fuzzy {
|
|
userEmail = "success+" + model.NewId() + "@simulator.amazonses.com"
|
|
userName = utils.FuzzName()
|
|
} else {
|
|
userEmail = "success+" + model.NewId() + "@simulator.amazonses.com"
|
|
userName = utils.RandomName(cfg.NameLength, cfg.NameCharset)
|
|
}
|
|
|
|
user := &model.User{
|
|
Email: userEmail,
|
|
Nickname: userName,
|
|
Password: USER_PASSWORD}
|
|
|
|
result, err := cfg.client.CreateUserWithInvite(user, "", "", cfg.team.InviteId)
|
|
if err != nil {
|
|
err.Translate(utils.T)
|
|
l4g.Error(err.Error())
|
|
return nil, false
|
|
}
|
|
|
|
ruser := result.Data.(*model.User)
|
|
|
|
status := &model.Status{UserId: ruser.Id, Status: model.STATUS_ONLINE, Manual: false, LastActivityAt: model.GetMillis(), ActiveChannel: ""}
|
|
if result := <-Srv.Store.Status().SaveOrUpdate(status); result.Err != nil {
|
|
result.Err.Translate(utils.T)
|
|
l4g.Error(result.Err.Error())
|
|
return nil, false
|
|
}
|
|
|
|
// We need to cheat to verify the user's email
|
|
store.Must(Srv.Store.User().VerifyEmail(ruser.Id))
|
|
|
|
return result.Data.(*model.User), true
|
|
}
|
|
|
|
func (cfg *AutoUserCreator) CreateTestUsers(num utils.Range) ([]*model.User, bool) {
|
|
numUsers := utils.RandIntFromRange(num)
|
|
users := make([]*model.User, numUsers)
|
|
|
|
for i := 0; i < numUsers; i++ {
|
|
var err bool
|
|
users[i], err = cfg.createRandomUser()
|
|
if err != true {
|
|
return users, false
|
|
}
|
|
}
|
|
|
|
return users, true
|
|
}
|