general cleanup (#8387)
Этот коммит содержится в:
@@ -135,10 +135,6 @@ func (me *TestHelper) InitBasic() *TestHelper {
|
||||
return me
|
||||
}
|
||||
|
||||
func (me *TestHelper) MakeUsername() string {
|
||||
return "un_" + model.NewId()
|
||||
}
|
||||
|
||||
func (me *TestHelper) MakeEmail() string {
|
||||
return "success_" + model.NewId() + "@simulator.amazonses.com"
|
||||
}
|
||||
@@ -191,10 +187,6 @@ func (me *TestHelper) CreateChannel(team *model.Team) *model.Channel {
|
||||
return me.createChannel(team, model.CHANNEL_OPEN)
|
||||
}
|
||||
|
||||
func (me *TestHelper) CreatePrivateChannel(team *model.Team) *model.Channel {
|
||||
return me.createChannel(team, model.CHANNEL_PRIVATE)
|
||||
}
|
||||
|
||||
func (me *TestHelper) createChannel(team *model.Team, channelType string) *model.Channel {
|
||||
id := model.NewId()
|
||||
|
||||
|
||||
@@ -181,18 +181,6 @@ func (a *App) HasPermissionToChannelByPost(askingUserId string, postId string, p
|
||||
return a.HasPermissionTo(askingUserId, permission)
|
||||
}
|
||||
|
||||
func (a *App) HasPermissionToUser(askingUserId string, userId string) bool {
|
||||
if askingUserId == userId {
|
||||
return true
|
||||
}
|
||||
|
||||
if a.HasPermissionTo(askingUserId, model.PERMISSION_EDIT_OTHER_USERS) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (a *App) CheckIfRolesGrantPermission(roles []string, permissionId string) bool {
|
||||
for _, roleId := range roles {
|
||||
if role := a.Role(roleId); role == nil {
|
||||
|
||||
@@ -9,16 +9,15 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
USER_PASSWORD = "passwd"
|
||||
CHANNEL_TYPE = model.CHANNEL_OPEN
|
||||
FUZZ_USER_EMAIL_PREFIX_LEN = 10
|
||||
BTEST_TEAM_DISPLAY_NAME = "TestTeam"
|
||||
BTEST_TEAM_NAME = "z-z-testdomaina"
|
||||
BTEST_TEAM_EMAIL = "test@nowhere.com"
|
||||
BTEST_TEAM_TYPE = model.TEAM_OPEN
|
||||
BTEST_USER_NAME = "Mr. Testing Tester"
|
||||
BTEST_USER_EMAIL = "success+ttester@simulator.amazonses.com"
|
||||
BTEST_USER_PASSWORD = "passwd"
|
||||
USER_PASSWORD = "passwd"
|
||||
CHANNEL_TYPE = model.CHANNEL_OPEN
|
||||
BTEST_TEAM_DISPLAY_NAME = "TestTeam"
|
||||
BTEST_TEAM_NAME = "z-z-testdomaina"
|
||||
BTEST_TEAM_EMAIL = "test@nowhere.com"
|
||||
BTEST_TEAM_TYPE = model.TEAM_OPEN
|
||||
BTEST_USER_NAME = "Mr. Testing Tester"
|
||||
BTEST_USER_EMAIL = "success+ttester@simulator.amazonses.com"
|
||||
BTEST_USER_PASSWORD = "passwd"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -29,8 +28,5 @@ var (
|
||||
USER_EMAIL_LEN = utils.Range{Begin: 15, End: 30}
|
||||
CHANNEL_DISPLAY_NAME_LEN = utils.Range{Begin: 10, End: 20}
|
||||
CHANNEL_NAME_LEN = utils.Range{Begin: 5, End: 20}
|
||||
POST_MESSAGE_LEN = utils.Range{Begin: 100, End: 400}
|
||||
POST_HASHTAGS_NUM = utils.Range{Begin: 5, End: 10}
|
||||
POST_MENTIONS_NUM = utils.Range{Begin: 0, End: 3}
|
||||
TEST_IMAGE_FILENAMES = []string{"test.png", "testjpg.jpg", "testgif.gif"}
|
||||
)
|
||||
|
||||
@@ -90,18 +90,3 @@ func (cfg *AutoPostCreator) CreateRandomPost() (*model.Post, bool) {
|
||||
}
|
||||
return result.Data.(*model.Post), true
|
||||
}
|
||||
|
||||
func (cfg *AutoPostCreator) CreateTestPosts(rangePosts utils.Range) ([]*model.Post, bool) {
|
||||
numPosts := utils.RandIntFromRange(rangePosts)
|
||||
posts := make([]*model.Post, numPosts)
|
||||
|
||||
for i := 0; i < numPosts; i++ {
|
||||
var err bool
|
||||
posts[i], err = cfg.CreateRandomPost()
|
||||
if !err {
|
||||
return posts, false
|
||||
}
|
||||
}
|
||||
|
||||
return posts, true
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ func (a *App) postChannelPrivacyMessage(user *model.User, channel *model.Channel
|
||||
})[channel.Type]
|
||||
post := &model.Post{
|
||||
ChannelId: channel.Id,
|
||||
Message: fmt.Sprintf(utils.T("api.channel.change_channel_privacy." + privacy)),
|
||||
Message: utils.T("api.channel.change_channel_privacy." + privacy),
|
||||
Type: model.POST_CHANGE_CHANNEL_PRIVACY,
|
||||
UserId: user.Id,
|
||||
Props: model.StringInterface{
|
||||
@@ -1062,7 +1062,7 @@ func (a *App) LeaveChannel(channelId string, userId string) *model.AppError {
|
||||
return err
|
||||
}
|
||||
|
||||
if channel.Name == model.DEFAULT_CHANNEL && *a.Config().ServiceSettings.ExperimentalEnableDefaultChannelLeaveJoinMessages == false {
|
||||
if channel.Name == model.DEFAULT_CHANNEL && !*a.Config().ServiceSettings.ExperimentalEnableDefaultChannelLeaveJoinMessages {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -84,28 +84,6 @@ func (cw *CorsWrapper) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
const TIME_TO_WAIT_FOR_CONNECTIONS_TO_CLOSE_ON_SERVER_SHUTDOWN = time.Second
|
||||
|
||||
type VaryBy struct {
|
||||
useIP bool
|
||||
useAuth bool
|
||||
}
|
||||
|
||||
func (m *VaryBy) Key(r *http.Request) string {
|
||||
key := ""
|
||||
|
||||
if m.useAuth {
|
||||
token, tokenLocation := ParseAuthTokenFromRequest(r)
|
||||
if tokenLocation != TokenLocationNotFound {
|
||||
key += token
|
||||
} else if m.useIP { // If we don't find an authentication token and IP based is enabled, fall back to IP
|
||||
key += utils.GetIpAddress(r)
|
||||
}
|
||||
} else if m.useIP { // Only if Auth based is not enabed do we use a plain IP based
|
||||
key = utils.GetIpAddress(r)
|
||||
}
|
||||
|
||||
return key
|
||||
}
|
||||
|
||||
func redirectHTTPToHTTPS(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Host == "" {
|
||||
http.Error(w, "Not Found", http.StatusNotFound)
|
||||
@@ -223,31 +201,6 @@ func (a *App) StartServer() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type tcpKeepAliveListener struct {
|
||||
*net.TCPListener
|
||||
}
|
||||
|
||||
func (ln tcpKeepAliveListener) Accept() (c net.Conn, err error) {
|
||||
tc, err := ln.AcceptTCP()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
tc.SetKeepAlive(true)
|
||||
tc.SetKeepAlivePeriod(3 * time.Minute)
|
||||
return tc, nil
|
||||
}
|
||||
|
||||
func (a *App) Listen(addr string) (net.Listener, error) {
|
||||
if addr == "" {
|
||||
addr = ":http"
|
||||
}
|
||||
ln, err := net.Listen("tcp", addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return tcpKeepAliveListener{ln.(*net.TCPListener)}, nil
|
||||
}
|
||||
|
||||
func (a *App) StopServer() {
|
||||
if a.Srv.Server != nil {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), TIME_TO_WAIT_FOR_CONNECTIONS_TO_CLOSE_ON_SERVER_SHUTDOWN)
|
||||
|
||||
@@ -109,13 +109,11 @@ func SlackParseUsers(data io.Reader) ([]SlackUser, error) {
|
||||
decoder := json.NewDecoder(data)
|
||||
|
||||
var users []SlackUser
|
||||
if err := decoder.Decode(&users); err != nil {
|
||||
// This actually returns errors that are ignored.
|
||||
// In this case it is erroring because of a null that Slack
|
||||
// introduced. So we just return the users here.
|
||||
return users, err
|
||||
}
|
||||
return users, nil
|
||||
err := decoder.Decode(&users)
|
||||
// This actually returns errors that are ignored.
|
||||
// In this case it is erroring because of a null that Slack
|
||||
// introduced. So we just return the users here.
|
||||
return users, err
|
||||
}
|
||||
|
||||
func SlackParsePosts(data io.Reader) ([]SlackPost, error) {
|
||||
|
||||
@@ -34,7 +34,6 @@ const (
|
||||
TOKEN_TYPE_PASSWORD_RECOVERY = "password_recovery"
|
||||
TOKEN_TYPE_VERIFY_EMAIL = "verify_email"
|
||||
PASSWORD_RECOVER_EXPIRY_TIME = 1000 * 60 * 60 // 1 hour
|
||||
VERIFY_EMAIL_EXPIRY_TIME = 1000 * 60 * 60 // 1 hour
|
||||
IMAGE_PROFILE_PIXEL_DIMENSION = 128
|
||||
)
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user