summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2018-03-07 12:36:40 -0600
committerGitHub <noreply@github.com>2018-03-07 12:36:40 -0600
commite8943936c51450540a4f2e8e7a2f3a2af90d14db (patch)
treebc7d32557780a2235a4f9a878d3b0841a1df0bda
parentfd9ee780ed713c10f122f9eb83e07bfdf09ce4a4 (diff)
downloadchat-e8943936c51450540a4f2e8e7a2f3a2af90d14db.tar.gz
chat-e8943936c51450540a4f2e8e7a2f3a2af90d14db.tar.bz2
chat-e8943936c51450540a4f2e8e7a2f3a2af90d14db.zip
general cleanup (#8387)
-rw-r--r--api/context.go13
-rw-r--r--api4/apitestlib.go27
-rw-r--r--api4/webhook.go1
-rw-r--r--app/apptestlib.go8
-rw-r--r--app/authorization.go12
-rw-r--r--app/auto_constants.go22
-rw-r--r--app/auto_posts.go15
-rw-r--r--app/channel.go4
-rw-r--r--app/server.go47
-rw-r--r--app/slackimport.go12
-rw-r--r--app/user.go1
-rw-r--r--cmd/platform/sampledata.go9
-rw-r--r--jobs/testworker.go106
-rw-r--r--model/authorization.go13
-rw-r--r--model/channel.go5
-rw-r--r--model/cluster_info.go6
-rw-r--r--model/config.go19
-rw-r--r--model/emoji.go4
-rw-r--r--model/ldap.go1
-rw-r--r--model/manifest.go9
-rw-r--r--model/manifest_test.go6
-rw-r--r--model/oauth.go11
-rw-r--r--model/saml.go3
-rw-r--r--model/search_params.go6
-rw-r--r--model/team.go9
-rw-r--r--model/user.go6
-rw-r--r--model/utils.go15
-rw-r--r--model/version.go4
-rw-r--r--store/layered_store_supplier.go2
-rw-r--r--utils/config.go3
-rw-r--r--utils/i18n.go5
-rw-r--r--utils/log.go33
-rw-r--r--utils/logger/log4go_json_writer.go30
-rw-r--r--utils/logger/logger.go222
-rw-r--r--utils/mail.go6
35 files changed, 30 insertions, 665 deletions
diff --git a/api/context.go b/api/context.go
index a8ff2b694..1eb1e3f4f 100644
--- a/api/context.go
+++ b/api/context.go
@@ -364,10 +364,6 @@ func NewInvalidParamError(where string, name string) *model.AppError {
return err
}
-func (c *Context) SetUnknownError(where string, details string) {
- c.Err = model.NewAppError(where, "api.context.unknown.app_error", nil, details, http.StatusInternalServerError)
-}
-
func (c *Context) SetPermissionError(permission *model.Permission) {
c.Err = model.NewAppError("Permissions", "api.context.permissions.app_error", nil, "userId="+c.Session.UserId+", "+"permission="+permission.Id, http.StatusForbidden)
}
@@ -387,11 +383,6 @@ func (c *Context) SetSiteURLHeader(url string) {
c.siteURLHeader = strings.TrimRight(url, "/")
}
-// TODO see where these are used
-func (c *Context) GetTeamURLFromTeam(team *model.Team) string {
- return c.GetSiteURLHeader() + "/" + team.Name
-}
-
func (c *Context) GetTeamURL() string {
if !c.teamURLValid {
c.SetTeamURLFromSession()
@@ -406,10 +397,6 @@ func (c *Context) GetSiteURLHeader() string {
return c.siteURLHeader
}
-func (c *Context) GetCurrentTeamMember() *model.TeamMember {
- return c.Session.GetTeamByTeamId(c.TeamId)
-}
-
func (c *Context) HandleEtag(etag string, routeName string, w http.ResponseWriter, r *http.Request) bool {
metrics := c.App.Metrics
if et := r.Header.Get(model.HEADER_ETAG_CLIENT); len(etag) > 0 {
diff --git a/api4/apitestlib.go b/api4/apitestlib.go
index e55ca8c8b..2bb80ddfb 100644
--- a/api4/apitestlib.go
+++ b/api4/apitestlib.go
@@ -510,18 +510,6 @@ func CheckUserSanitization(t *testing.T, user *model.User) {
}
}
-func CheckTeamSanitization(t *testing.T, team *model.Team) {
- t.Helper()
-
- if team.Email != "" {
- t.Fatal("email wasn't blank")
- }
-
- if team.AllowedDomains != "" {
- t.Fatal("'allowed domains' wasn't blank")
- }
-}
-
func CheckEtag(t *testing.T, data interface{}, resp *model.Response) {
t.Helper()
@@ -669,21 +657,6 @@ func CheckInternalErrorStatus(t *testing.T, resp *model.Response) {
}
}
-func CheckPayLoadTooLargeStatus(t *testing.T, resp *model.Response) {
- t.Helper()
-
- if resp.Error == nil {
- t.Fatal("should have errored with status:" + strconv.Itoa(http.StatusRequestEntityTooLarge))
- return
- }
-
- if resp.StatusCode != http.StatusRequestEntityTooLarge {
- t.Log("actual: " + strconv.Itoa(resp.StatusCode))
- t.Log("expected: " + strconv.Itoa(http.StatusRequestEntityTooLarge))
- t.Fatal("wrong status code")
- }
-}
-
func readTestFile(name string) ([]byte, error) {
path, _ := utils.FindDir("tests")
file, err := os.Open(path + "/" + name)
diff --git a/api4/webhook.go b/api4/webhook.go
index e19f14704..853cf43f3 100644
--- a/api4/webhook.go
+++ b/api4/webhook.go
@@ -510,7 +510,6 @@ func commandWebhook(c *Context, w http.ResponseWriter, r *http.Request) {
}
func decodePayload(payload io.Reader) (*model.IncomingWebhookRequest, *model.AppError) {
- decodeError := &model.AppError{}
incomingWebhookPayload, decodeError := model.IncomingWebhookRequestFromJson(payload)
if decodeError != nil {
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
)
diff --git a/cmd/platform/sampledata.go b/cmd/platform/sampledata.go
index 98a041d8f..97a73b021 100644
--- a/cmd/platform/sampledata.go
+++ b/cmd/platform/sampledata.go
@@ -312,7 +312,7 @@ func sampleDataCmdF(cmd *cobra.Command, args []string) error {
}
importErr, lineNumber := a.BulkImport(bulkFile, false, workers)
if importErr != nil {
- return errors.New(fmt.Sprintf("%s: %s, %s (line: %d)", importErr.Where, importErr.Message, importErr.DetailedError, lineNumber))
+ return fmt.Errorf("%s: %s, %s (line: %d)", importErr.Where, importErr.Message, importErr.DetailedError, lineNumber)
}
} else if bulk != "-" {
err := bulkFile.Close()
@@ -395,7 +395,7 @@ func createUser(idx int, teamMemberships int, channelMemberships int, teamsAndCh
position := rand.Intn(len(possibleTeams))
team := possibleTeams[position]
possibleTeams = append(possibleTeams[:position], possibleTeams[position+1:]...)
- if teamChannels, err := teamsAndChannels[team]; err == true {
+ if teamChannels, err := teamsAndChannels[team]; err {
teams = append(teams, createTeamMembership(channelMemberships, teamChannels, &team))
}
}
@@ -429,10 +429,7 @@ func createTeamMembership(numOfchannels int, teamChannels []string, teamName *st
roles = "team_user team_admin"
}
channels := []app.UserChannelImportData{}
- teamChannelsCopy := []string{}
- for _, value := range teamChannels {
- teamChannelsCopy = append(teamChannelsCopy, value)
- }
+ teamChannelsCopy := append([]string(nil), teamChannels...)
for x := 0; x < numOfchannels; x++ {
if len(teamChannelsCopy) == 0 {
break
diff --git a/jobs/testworker.go b/jobs/testworker.go
deleted file mode 100644
index 9cfc8614f..000000000
--- a/jobs/testworker.go
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package jobs
-
-import (
- "context"
- "time"
-
- l4g "github.com/alecthomas/log4go"
- "github.com/mattermost/mattermost-server/model"
-)
-
-type TestWorker struct {
- srv *JobServer
- name string
- stop chan bool
- stopped chan bool
- jobs chan model.Job
-}
-
-func (srv *JobServer) MakeTestWorker(name string) *TestWorker {
- return &TestWorker{
- srv: srv,
- name: name,
- stop: make(chan bool, 1),
- stopped: make(chan bool, 1),
- jobs: make(chan model.Job),
- }
-}
-
-func (worker *TestWorker) Run() {
- l4g.Debug("Worker %v: Started", worker.name)
-
- defer func() {
- l4g.Debug("Worker %v: Finished", worker.name)
- worker.stopped <- true
- }()
-
- for {
- select {
- case <-worker.stop:
- l4g.Debug("Worker %v: Received stop signal", worker.name)
- return
- case job := <-worker.jobs:
- l4g.Debug("Worker %v: Received a new candidate job.", worker.name)
- worker.DoJob(&job)
- }
- }
-}
-
-func (worker *TestWorker) DoJob(job *model.Job) {
- if claimed, err := worker.srv.ClaimJob(job); err != nil {
- l4g.Error("Job: %v: Error occurred while trying to claim job: %v", job.Id, err.Error())
- return
- } else if !claimed {
- return
- }
-
- cancelCtx, cancelCancelWatcher := context.WithCancel(context.Background())
- cancelWatcherChan := make(chan interface{}, 1)
- go worker.srv.CancellationWatcher(cancelCtx, job.Id, cancelWatcherChan)
-
- defer cancelCancelWatcher()
-
- counter := 0
- for {
- select {
- case <-cancelWatcherChan:
- l4g.Debug("Job %v: Job has been canceled via CancellationWatcher.", job.Id)
- if err := worker.srv.SetJobCanceled(job); err != nil {
- l4g.Error("Failed to mark job: %v as canceled. Error: %v", job.Id, err.Error())
- }
- return
- case <-worker.stop:
- l4g.Debug("Job %v: Job has been canceled via Worker Stop.", job.Id)
- if err := worker.srv.SetJobCanceled(job); err != nil {
- l4g.Error("Failed to mark job: %v as canceled. Error: %v", job.Id, err.Error())
- }
- return
- case <-time.After(5 * time.Second):
- counter++
- if counter > 10 {
- l4g.Debug("Job %v: Job completed.", job.Id)
- if err := worker.srv.SetJobSuccess(job); err != nil {
- l4g.Error("Failed to mark job: %v as succeeded. Error: %v", job.Id, err.Error())
- }
- return
- } else {
- if err := worker.srv.SetJobProgress(job, int64(counter*10)); err != nil {
- l4g.Error("Job: %v: an error occured while trying to set job progress: %v", job.Id, err.Error())
- }
- }
- }
- }
-}
-
-func (worker *TestWorker) Stop() {
- l4g.Debug("Worker %v: Stopping", worker.name)
- worker.stop <- true
- <-worker.stopped
-}
-
-func (worker *TestWorker) JobChannel() chan<- model.Job {
- return worker.jobs
-}
diff --git a/model/authorization.go b/model/authorization.go
index 9f4e36eab..34faf8bba 100644
--- a/model/authorization.go
+++ b/model/authorization.go
@@ -503,19 +503,6 @@ func initializeDefaultRoles() {
}
}
-func RoleIdsToString(roles []string) string {
- output := ""
- for _, role := range roles {
- output += role + ", "
- }
-
- if output == "" {
- return "[<NO ROLES>]"
- }
-
- return output[:len(output)-1]
-}
-
func init() {
initializePermissions()
initializeDefaultRoles()
diff --git a/model/channel.go b/model/channel.go
index ce812be3d..df68202d6 100644
--- a/model/channel.go
+++ b/model/channel.go
@@ -86,12 +86,7 @@ func (o *Channel) Etag() string {
return Etag(o.Id, o.UpdateAt)
}
-func (o *Channel) StatsEtag() string {
- return Etag(o.Id, o.ExtraUpdateAt)
-}
-
func (o *Channel) IsValid() *AppError {
-
if len(o.Id) != 26 {
return NewAppError("Channel.IsValid", "model.channel.is_valid.id.app_error", nil, "", http.StatusBadRequest)
}
diff --git a/model/cluster_info.go b/model/cluster_info.go
index a8d63ec32..46a3487a9 100644
--- a/model/cluster_info.go
+++ b/model/cluster_info.go
@@ -6,7 +6,6 @@ package model
import (
"encoding/json"
"io"
- "strings"
)
type ClusterInfo struct {
@@ -22,11 +21,6 @@ func (me *ClusterInfo) ToJson() string {
return string(b)
}
-func (me *ClusterInfo) Copy() *ClusterInfo {
- json := me.ToJson()
- return ClusterInfoFromJson(strings.NewReader(json))
-}
-
func ClusterInfoFromJson(data io.Reader) *ClusterInfo {
var me *ClusterInfo
json.NewDecoder(data).Decode(&me)
diff --git a/model/config.go b/model/config.go
index 1b916fe13..8e1dfce0a 100644
--- a/model/config.go
+++ b/model/config.go
@@ -35,10 +35,6 @@ const (
SERVICE_GOOGLE = "google"
SERVICE_OFFICE365 = "office365"
- WEBSERVER_MODE_REGULAR = "regular"
- WEBSERVER_MODE_GZIP = "gzip"
- WEBSERVER_MODE_DISABLED = "disabled"
-
GENERIC_NO_CHANNEL_NOTIFICATION = "generic_no_channel"
GENERIC_NOTIFICATION = "generic"
FULL_NOTIFICATION = "full"
@@ -99,15 +95,12 @@ const (
EMAIL_SETTINGS_DEFAULT_FEEDBACK_ORGANIZATION = ""
- SUPPORT_SETTINGS_DEFAULT_TERMS_OF_SERVICE_LINK = "https://about.mattermost.com/default-terms/"
- SUPPORT_SETTINGS_DEFAULT_PRIVACY_POLICY_LINK = "https://about.mattermost.com/default-privacy-policy/"
- SUPPORT_SETTINGS_DEFAULT_ABOUT_LINK = "https://about.mattermost.com/default-about/"
- SUPPORT_SETTINGS_DEFAULT_HELP_LINK = "https://about.mattermost.com/default-help/"
- SUPPORT_SETTINGS_DEFAULT_REPORT_A_PROBLEM_LINK = "https://about.mattermost.com/default-report-a-problem/"
- SUPPORT_SETTINGS_DEFAULT_ADMINISTRATORS_GUIDE_LINK = "https://about.mattermost.com/administrators-guide/"
- SUPPORT_SETTINGS_DEFAULT_TROUBLESHOOTING_FORUM_LINK = "https://about.mattermost.com/troubleshooting-forum/"
- SUPPORT_SETTINGS_DEFAULT_COMMERCIAL_SUPPORT_LINK = "https://about.mattermost.com/commercial-support/"
- SUPPORT_SETTINGS_DEFAULT_SUPPORT_EMAIL = "feedback@mattermost.com"
+ SUPPORT_SETTINGS_DEFAULT_TERMS_OF_SERVICE_LINK = "https://about.mattermost.com/default-terms/"
+ SUPPORT_SETTINGS_DEFAULT_PRIVACY_POLICY_LINK = "https://about.mattermost.com/default-privacy-policy/"
+ SUPPORT_SETTINGS_DEFAULT_ABOUT_LINK = "https://about.mattermost.com/default-about/"
+ SUPPORT_SETTINGS_DEFAULT_HELP_LINK = "https://about.mattermost.com/default-help/"
+ SUPPORT_SETTINGS_DEFAULT_REPORT_A_PROBLEM_LINK = "https://about.mattermost.com/default-report-a-problem/"
+ SUPPORT_SETTINGS_DEFAULT_SUPPORT_EMAIL = "feedback@mattermost.com"
LDAP_SETTINGS_DEFAULT_FIRST_NAME_ATTRIBUTE = ""
LDAP_SETTINGS_DEFAULT_LAST_NAME_ATTRIBUTE = ""
diff --git a/model/emoji.go b/model/emoji.go
index a1703abb1..47d170bb3 100644
--- a/model/emoji.go
+++ b/model/emoji.go
@@ -56,10 +56,6 @@ func (emoji *Emoji) PreSave() {
emoji.UpdateAt = emoji.CreateAt
}
-func (emoji *Emoji) PreUpdate() {
- emoji.UpdateAt = GetMillis()
-}
-
func (emoji *Emoji) ToJson() string {
b, _ := json.Marshal(emoji)
return string(b)
diff --git a/model/ldap.go b/model/ldap.go
index 1453a4add..9051c5a30 100644
--- a/model/ldap.go
+++ b/model/ldap.go
@@ -5,5 +5,4 @@ package model
const (
USER_AUTH_SERVICE_LDAP = "ldap"
- LDAP_SYNC_TASK_NAME = "LDAP Syncronization"
)
diff --git a/model/manifest.go b/model/manifest.go
index 5ba4854b6..fdf69c2e6 100644
--- a/model/manifest.go
+++ b/model/manifest.go
@@ -13,15 +13,6 @@ import (
"gopkg.in/yaml.v2"
)
-const (
- PLUGIN_CONFIG_TYPE_TEXT = "text"
- PLUGIN_CONFIG_TYPE_BOOL = "bool"
- PLUGIN_CONFIG_TYPE_RADIO = "radio"
- PLUGIN_CONFIG_TYPE_DROPDOWN = "dropdown"
- PLUGIN_CONFIG_TYPE_GENERATED = "generated"
- PLUGIN_CONFIG_TYPE_USERNAME = "username"
-)
-
type PluginOption struct {
// The display name for the option.
DisplayName string `json:"display_name" yaml:"display_name"`
diff --git a/model/manifest_test.go b/model/manifest_test.go
index 3fdc13ec4..b63e388bc 100644
--- a/model/manifest_test.go
+++ b/model/manifest_test.go
@@ -74,7 +74,7 @@ func TestManifestUnmarshal(t *testing.T) {
&PluginSetting{
Key: "thesetting",
DisplayName: "thedisplayname",
- Type: PLUGIN_CONFIG_TYPE_DROPDOWN,
+ Type: "dropdown",
HelpText: "thehelptext",
RegenerateHelpText: "theregeneratehelptext",
Placeholder: "theplaceholder",
@@ -181,7 +181,7 @@ func TestManifestJson(t *testing.T) {
&PluginSetting{
Key: "thesetting",
DisplayName: "thedisplayname",
- Type: PLUGIN_CONFIG_TYPE_DROPDOWN,
+ Type: "dropdown",
HelpText: "thehelptext",
RegenerateHelpText: "theregeneratehelptext",
Placeholder: "theplaceholder",
@@ -246,7 +246,7 @@ func TestManifestClientManifest(t *testing.T) {
&PluginSetting{
Key: "thesetting",
DisplayName: "thedisplayname",
- Type: PLUGIN_CONFIG_TYPE_DROPDOWN,
+ Type: "dropdown",
HelpText: "thehelptext",
RegenerateHelpText: "theregeneratehelptext",
Placeholder: "theplaceholder",
diff --git a/model/oauth.go b/model/oauth.go
index 70e8a3f26..c92b1ec41 100644
--- a/model/oauth.go
+++ b/model/oauth.go
@@ -141,17 +141,6 @@ func OAuthAppFromJson(data io.Reader) *OAuthApp {
return app
}
-func OAuthAppMapToJson(a map[string]*OAuthApp) string {
- b, _ := json.Marshal(a)
- return string(b)
-}
-
-func OAuthAppMapFromJson(data io.Reader) map[string]*OAuthApp {
- var apps map[string]*OAuthApp
- json.NewDecoder(data).Decode(&apps)
- return apps
-}
-
func OAuthAppListToJson(l []*OAuthApp) string {
b, _ := json.Marshal(l)
return string(b)
diff --git a/model/saml.go b/model/saml.go
index e74750156..528ac45cc 100644
--- a/model/saml.go
+++ b/model/saml.go
@@ -11,9 +11,6 @@ import (
const (
USER_AUTH_SERVICE_SAML = "saml"
USER_AUTH_SERVICE_SAML_TEXT = "With SAML"
- SAML_IDP_CERTIFICATE = 1
- SAML_PRIVATE_KEY = 2
- SAML_PUBLIC_CERT = 3
)
type SamlAuthRequest struct {
diff --git a/model/search_params.go b/model/search_params.go
index 1692b3aaf..481671ab5 100644
--- a/model/search_params.go
+++ b/model/search_params.go
@@ -4,7 +4,6 @@
package model
import (
- "encoding/json"
"regexp"
"strings"
)
@@ -20,11 +19,6 @@ type SearchParams struct {
OrTerms bool
}
-func (o *SearchParams) ToJson() string {
- b, _ := json.Marshal(o)
- return string(b)
-}
-
var searchFlags = [...]string{"from", "channel", "in"}
func splitWords(text string) []string {
diff --git a/model/team.go b/model/team.go
index 15a708220..7968c9d48 100644
--- a/model/team.go
+++ b/model/team.go
@@ -243,15 +243,6 @@ func (o *Team) Sanitize() {
o.AllowedDomains = ""
}
-func (o *Team) SanitizeForNotLoggedIn() {
- o.Email = ""
- o.AllowedDomains = ""
- o.CompanyName = ""
- if !o.AllowOpenInvite {
- o.InviteId = ""
- }
-}
-
func (t *Team) Patch(patch *TeamPatch) {
if patch.DisplayName != nil {
t.DisplayName = *patch.DisplayName
diff --git a/model/user.go b/model/user.go
index 1e1d49f7d..f64275c83 100644
--- a/model/user.go
+++ b/model/user.go
@@ -373,12 +373,6 @@ func (u *User) MakeNonNil() {
}
}
-func (u *User) AddProp(key string, value string) {
- u.MakeNonNil()
-
- u.Props[key] = value
-}
-
func (u *User) AddNotifyProp(key string, value string) {
u.MakeNonNil()
diff --git a/model/utils.go b/model/utils.go
index 331a1aaaa..72369852b 100644
--- a/model/utils.go
+++ b/model/utils.go
@@ -394,9 +394,6 @@ func ClearMentionTags(post string) string {
return post
}
-var UrlRegex = regexp.MustCompile(`^((?:[a-z]+:\/\/)?(?:(?:[a-z0-9\-]+\.)+(?:[a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|local|internal))(:[0-9]{1,5})?(?:\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(?:\?[a-z0-9+_~\-\.%=&amp;]*)?)?(?:#[a-zA-Z0-9!$&'()*+.=-_~:@/?]*)?)(?:\s+|$)$`)
-var PartialUrlRegex = regexp.MustCompile(`/([A-Za-z0-9]{26})/([A-Za-z0-9]{26})/((?:[A-Za-z0-9]{26})?.+(?:\.[A-Za-z0-9]{3,})?)`)
-
func IsValidHttpUrl(rawUrl string) bool {
if strings.Index(rawUrl, "http://") != 0 && strings.Index(rawUrl, "https://") != 0 {
return false
@@ -409,18 +406,6 @@ func IsValidHttpUrl(rawUrl string) bool {
return true
}
-func IsValidHttpsUrl(rawUrl string) bool {
- if strings.Index(rawUrl, "https://") != 0 {
- return false
- }
-
- if _, err := url.ParseRequestURI(rawUrl); err != nil {
- return false
- }
-
- return true
-}
-
func IsValidTurnOrStunServer(rawUri string) bool {
if strings.Index(rawUri, "turn:") != 0 && strings.Index(rawUri, "stun:") != 0 {
return false
diff --git a/model/version.go b/model/version.go
index 3e75478d3..e4e0af491 100644
--- a/model/version.go
+++ b/model/version.go
@@ -107,10 +107,6 @@ func GetPreviousVersion(version string) string {
return ""
}
-func IsOfficalBuild() bool {
- return BuildNumber != "_BUILD_NUMBER_"
-}
-
func IsCurrentVersion(versionToCheck string) bool {
currentMajor, currentMinor, _ := SplitVersion(CurrentVersion)
toCheckMajor, toCheckMinor, _ := SplitVersion(versionToCheck)
diff --git a/store/layered_store_supplier.go b/store/layered_store_supplier.go
index 841b75a32..d5e654019 100644
--- a/store/layered_store_supplier.go
+++ b/store/layered_store_supplier.go
@@ -6,8 +6,6 @@ package store
import "github.com/mattermost/mattermost-server/model"
import "context"
-type ResultHandler func(*StoreResult)
-
type LayeredStoreSupplierResult struct {
StoreResult
}
diff --git a/utils/config.go b/utils/config.go
index 679e5f62c..1b6d7714e 100644
--- a/utils/config.go
+++ b/utils/config.go
@@ -26,9 +26,6 @@ import (
)
const (
- MODE_DEV = "dev"
- MODE_BETA = "beta"
- MODE_PROD = "prod"
LOG_ROTATE_SIZE = 10000
LOG_FILENAME = "mattermost.log"
)
diff --git a/utils/i18n.go b/utils/i18n.go
index 71e1aaee1..8ed82d19f 100644
--- a/utils/i18n.go
+++ b/utils/i18n.go
@@ -91,11 +91,6 @@ func GetUserTranslations(locale string) i18n.TranslateFunc {
return translations
}
-func SetTranslations(locale string) i18n.TranslateFunc {
- translations := TfuncWithFallback(locale)
- return translations
-}
-
func GetTranslationsAndLocale(w http.ResponseWriter, r *http.Request) (i18n.TranslateFunc, string) {
// This is for checking against locales like pt_BR or zn_CN
headerLocaleFull := strings.Split(r.Header.Get("Accept-Language"), ",")[0]
diff --git a/utils/log.go b/utils/log.go
deleted file mode 100644
index c1f579e9d..000000000
--- a/utils/log.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package utils
-
-import (
- "bytes"
- "io"
- "io/ioutil"
-
- l4g "github.com/alecthomas/log4go"
-)
-
-// InfoReader logs the content of the io.Reader and returns a new io.Reader
-// with the same content as the received io.Reader.
-// If you pass reader by reference, it won't be re-created unless the loglevel
-// includes Debug.
-// If an error is returned, the reader is consumed an cannot be read again.
-func InfoReader(reader io.Reader, message string) (io.Reader, error) {
- var err error
- l4g.Info(func() string {
- content, err := ioutil.ReadAll(reader)
- if err != nil {
- return ""
- }
-
- reader = bytes.NewReader(content)
-
- return message + string(content)
- })
-
- return reader, err
-}
diff --git a/utils/logger/log4go_json_writer.go b/utils/logger/log4go_json_writer.go
deleted file mode 100644
index ede541b2b..000000000
--- a/utils/logger/log4go_json_writer.go
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-// glue functions that allow logger.go to leverage log4Go to write JSON-formatted log records to a file
-
-package logger
-
-import (
- l4g "github.com/alecthomas/log4go"
- "github.com/mattermost/mattermost-server/utils"
-)
-
-// newJSONLogWriter is a utility method for creating a FileLogWriter set up to
-// output JSON record log messages instead of line-based ones.
-func newJSONLogWriter(fname string, rotate bool) *l4g.FileLogWriter {
- return l4g.NewFileLogWriter(fname, rotate).SetFormat(
- `{"level": "%L",
- "timestamp": "%D %T",
- "source": "%S",
- "message": %M
- }`).SetRotateLines(utils.LOG_ROTATE_SIZE)
-}
-
-// NewJSONFileLogger - Create a new logger with a "file" filter configured to send JSON-formatted log messages at
-// or above lvl to a file with the specified filename.
-func NewJSONFileLogger(lvl l4g.Level, filename string) l4g.Logger {
- return l4g.Logger{
- "file": &l4g.Filter{Level: lvl, LogWriter: newJSONLogWriter(filename, false)},
- }
-}
diff --git a/utils/logger/logger.go b/utils/logger/logger.go
deleted file mode 100644
index 558f3fe47..000000000
--- a/utils/logger/logger.go
+++ /dev/null
@@ -1,222 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-// this is a new logger interface for mattermost
-
-package logger
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "path/filepath"
- "runtime"
-
- l4g "github.com/alecthomas/log4go"
-
- "strings"
-
- "github.com/mattermost/mattermost-server/model"
- "github.com/mattermost/mattermost-server/utils"
- "github.com/pkg/errors"
-)
-
-// this pattern allows us to "mock" the underlying l4g code when unit testing
-var logger l4g.Logger
-var debugLog = l4g.Debug
-var infoLog = l4g.Info
-var errorLog = l4g.Error
-
-// assumes that ../config.go::configureLog has already been called, and has in turn called l4g.close() to clean up
-// any old filters that we might have previously created
-func initL4g(logSettings model.LogSettings) {
- // TODO: add support for newConfig.LogSettings.EnableConsole. Right now, ../config.go sets it up in its configureLog
- // method. If we also set it up here, messages will be written to the console twice. Eventually, when all instances
- // of l4g have been replaced by this logger, we can move that code to here
- if logSettings.EnableFile {
- level := l4g.DEBUG
- if logSettings.FileLevel == "INFO" {
- level = l4g.INFO
- } else if logSettings.FileLevel == "WARN" {
- level = l4g.WARNING
- } else if logSettings.FileLevel == "ERROR" {
- level = l4g.ERROR
- }
-
- // create a logger that writes JSON objects to a file, and override our log methods to use it
- if logger != nil {
- logger.Close()
- }
- logger = NewJSONFileLogger(level, utils.GetLogFileLocation(logSettings.FileLocation)+".jsonl")
- debugLog = logger.Debug
- infoLog = logger.Info
- errorLog = logger.Error
- }
-}
-
-// contextKey lets us add contextual information to log messages
-type contextKey string
-
-func (c contextKey) String() string {
- return string(c)
-}
-
-const contextKeyUserID contextKey = contextKey("user_id")
-const contextKeyRequestID contextKey = contextKey("request_id")
-
-// any contextKeys added to this array will be serialized in every log message
-var contextKeys = [2]contextKey{contextKeyUserID, contextKeyRequestID}
-
-// WithUserId adds a user id to the specified context. If the returned Context is subsequently passed to a logging
-// method, the user id will automatically be included in the logged message
-func WithUserId(ctx context.Context, userID string) context.Context {
- return context.WithValue(ctx, contextKeyUserID, userID)
-}
-
-// WithRequestId adds a request id to the specified context. If the returned Context is subsequently passed to a logging
-// method, the request id will automatically be included in the logged message
-func WithRequestId(ctx context.Context, requestID string) context.Context {
- return context.WithValue(ctx, contextKeyRequestID, requestID)
-}
-
-// extracts known contextKey values from the specified Context and assembles them into the returned map
-func serializeContext(ctx context.Context) map[string]string {
- serialized := make(map[string]string)
- for _, key := range contextKeys {
- value, ok := ctx.Value(key).(string)
- if ok {
- serialized[string(key)] = value
- }
- }
- return serialized
-}
-
-// Returns the path to the next file up the callstack that has a different name than this file
-// in other words, finds the path to the file that is doing the logging.
-// Removes machine-specific prefix, so returned path starts with /mattermost-server.
-// Looks a maximum of 10 frames up the call stack to find a file that has a different name than this one.
-func getCallerFilename() (string, error) {
- _, currentFilename, _, ok := runtime.Caller(0)
- if !ok {
- return "", errors.New("Failed to traverse stack frame")
- }
-
- platformDirectory := currentFilename
- for filepath.Base(platformDirectory) != "platform" {
- platformDirectory = filepath.Dir(platformDirectory)
- if platformDirectory == "." || platformDirectory == string(filepath.Separator) {
- break
- }
- }
-
- for i := 1; i < 10; i++ {
- _, parentFilename, _, ok := runtime.Caller(i)
- if !ok {
- return "", errors.New("Failed to traverse stack frame")
- } else if parentFilename != currentFilename && strings.Contains(parentFilename, platformDirectory) {
- // trim parentFilename such that we return the path to parentFilename, relative to platformDirectory
- return parentFilename[strings.LastIndex(parentFilename, platformDirectory)+len(platformDirectory)+1:], nil
- }
- }
- return "", errors.New("Failed to traverse stack frame")
-}
-
-// creates a JSON representation of a log message
-func serializeLogMessage(ctx context.Context, message string) string {
- callerFilename, err := getCallerFilename()
- if err != nil {
- callerFilename = "Unknown"
- }
-
- bytes, err := json.Marshal(&struct {
- Context map[string]string `json:"context"`
- File string `json:"file"`
- Message string `json:"message"`
- }{
- serializeContext(ctx),
- callerFilename,
- message,
- })
- if err != nil {
- errorLog("Failed to serialize log message %v", message)
- }
- return string(bytes)
-}
-
-func formatMessage(args ...interface{}) string {
- msg, ok := args[0].(string)
- if !ok {
- panic("Second argument is not of type string")
- }
- if len(args) > 1 {
- variables := args[1:]
- msg = fmt.Sprintf(msg, variables...)
- }
- return msg
-}
-
-// Debugc logs a debugLog level message, including context information that is stored in the first parameter.
-// If two parameters are supplied, the second must be a message string, and will be logged directly.
-// If more than two parameters are supplied, the second parameter must be a format string, and the remaining parameters
-// must be the variables to substitute into the format string, following the convention of the fmt.Sprintf(...) function.
-func Debugc(ctx context.Context, args ...interface{}) {
- debugLog(func() string {
- msg := formatMessage(args...)
- return serializeLogMessage(ctx, msg)
- })
-}
-
-// Debugf logs a debugLog level message.
-// If one parameter is supplied, it must be a message string, and will be logged directly.
-// If two or more parameters are specified, the first parameter must be a format string, and the remaining parameters
-// must be the variables to substitute into the format string, following the convention of the fmt.Sprintf(...) function.
-func Debugf(args ...interface{}) {
- debugLog(func() string {
- msg := formatMessage(args...)
- return serializeLogMessage(context.Background(), msg)
- })
-}
-
-// Infoc logs an infoLog level message, including context information that is stored in the first parameter.
-// If two parameters are supplied, the second must be a message string, and will be logged directly.
-// If more than two parameters are supplied, the second parameter must be a format string, and the remaining parameters
-// must be the variables to substitute into the format string, following the convention of the fmt.Sprintf(...) function.
-func Infoc(ctx context.Context, args ...interface{}) {
- infoLog(func() string {
- msg := formatMessage(args...)
- return serializeLogMessage(ctx, msg)
- })
-}
-
-// Infof logs an infoLog level message.
-// If one parameter is supplied, it must be a message string, and will be logged directly.
-// If two or more parameters are specified, the first parameter must be a format string, and the remaining parameters
-// must be the variables to substitute into the format string, following the convention of the fmt.Sprintf(...) function.
-func Infof(args ...interface{}) {
- infoLog(func() string {
- msg := formatMessage(args...)
- return serializeLogMessage(context.Background(), msg)
- })
-}
-
-// Errorc logs an error level message, including context information that is stored in the first parameter.
-// If two parameters are supplied, the second must be a message string, and will be logged directly.
-// If more than two parameters are supplied, the second parameter must be a format string, and the remaining parameters
-// must be the variables to substitute into the format string, following the convention of the fmt.Sprintf(...) function.
-func Errorc(ctx context.Context, args ...interface{}) {
- errorLog(func() string {
- msg := formatMessage(args...)
- return serializeLogMessage(ctx, msg)
- })
-}
-
-// Errorf logs an error level message.
-// If one parameter is supplied, it must be a message string, and will be logged directly.
-// If two or more parameters are specified, the first parameter must be a format string, and the remaining parameters
-// must be the variables to substitute into the format string, following the convention of the fmt.Sprintf(...) function.
-func Errorf(args ...interface{}) {
- errorLog(func() string {
- msg := formatMessage(args...)
- return serializeLogMessage(context.Background(), msg)
- })
-}
diff --git a/utils/mail.go b/utils/mail.go
index 2bc0ce9e1..3b9f4bd9d 100644
--- a/utils/mail.go
+++ b/utils/mail.go
@@ -186,10 +186,8 @@ func sendMail(mimeTo, smtpTo string, from mail.Address, subject, htmlBody string
"Auto-Submitted": {"auto-generated"},
"Precedence": {"bulk"},
}
- if mimeHeaders != nil {
- for k, v := range mimeHeaders {
- headers[k] = []string{encodeRFC2047Word(v)}
- }
+ for k, v := range mimeHeaders {
+ headers[k] = []string{encodeRFC2047Word(v)}
}
m := gomail.NewMessage(gomail.SetCharset("UTF-8"))