diff options
author | Chris <ccbrown112@gmail.com> | 2018-03-07 12:36:40 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-07 12:36:40 -0600 |
commit | e8943936c51450540a4f2e8e7a2f3a2af90d14db (patch) | |
tree | bc7d32557780a2235a4f9a878d3b0841a1df0bda /app | |
parent | fd9ee780ed713c10f122f9eb83e07bfdf09ce4a4 (diff) | |
download | chat-e8943936c51450540a4f2e8e7a2f3a2af90d14db.tar.gz chat-e8943936c51450540a4f2e8e7a2f3a2af90d14db.tar.bz2 chat-e8943936c51450540a4f2e8e7a2f3a2af90d14db.zip |
general cleanup (#8387)
Diffstat (limited to 'app')
-rw-r--r-- | app/apptestlib.go | 8 | ||||
-rw-r--r-- | app/authorization.go | 12 | ||||
-rw-r--r-- | app/auto_constants.go | 22 | ||||
-rw-r--r-- | app/auto_posts.go | 15 | ||||
-rw-r--r-- | app/channel.go | 4 | ||||
-rw-r--r-- | app/server.go | 47 | ||||
-rw-r--r-- | app/slackimport.go | 12 | ||||
-rw-r--r-- | app/user.go | 1 |
8 files changed, 16 insertions, 105 deletions
diff --git a/app/apptestlib.go b/app/apptestlib.go index c7846c9b5..9e5bfc637 100644 --- a/app/apptestlib.go +++ b/app/apptestlib.go @@ -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() diff --git a/app/authorization.go b/app/authorization.go index 3a64bb717..4231cac77 100644 --- a/app/authorization.go +++ b/app/authorization.go @@ -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 { diff --git a/app/auto_constants.go b/app/auto_constants.go index c52eb6243..520d4e363 100644 --- a/app/auto_constants.go +++ b/app/auto_constants.go @@ -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"} ) diff --git a/app/auto_posts.go b/app/auto_posts.go index 6d1e352e5..379c74ab7 100644 --- a/app/auto_posts.go +++ b/app/auto_posts.go @@ -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 -} diff --git a/app/channel.go b/app/channel.go index 76147a508..4e294abbb 100644 --- a/app/channel.go +++ b/app/channel.go @@ -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 } diff --git a/app/server.go b/app/server.go index 93804a372..0c6c25ba5 100644 --- a/app/server.go +++ b/app/server.go @@ -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) diff --git a/app/slackimport.go b/app/slackimport.go index 9d1b4cf9c..ed522671a 100644 --- a/app/slackimport.go +++ b/app/slackimport.go @@ -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) { diff --git a/app/user.go b/app/user.go index 5790be21e..c303cbc68 100644 --- a/app/user.go +++ b/app/user.go @@ -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 ) |