summaryrefslogtreecommitdiffstats
path: root/api4
diff options
context:
space:
mode:
authorJesús Espino <jespinog@gmail.com>2018-09-20 19:07:03 +0200
committerChristopher Speller <crspeller@gmail.com>2018-09-20 10:07:03 -0700
commita08df883b4ddb514d53b518f41431ce7efb50d8f (patch)
tree9e16aeb09188f4aa34b268b77d78e7ebaa5a5978 /api4
parentf1be975d7ab17a7da89ddb3cf6fea2c1b282a89e (diff)
downloadchat-a08df883b4ddb514d53b518f41431ce7efb50d8f.tar.gz
chat-a08df883b4ddb514d53b518f41431ce7efb50d8f.tar.bz2
chat-a08df883b4ddb514d53b518f41431ce7efb50d8f.zip
Move file backend to its own service (#9435)
* Move file backend to its own service * Moving utils/inbucket to mailservice package
Diffstat (limited to 'api4')
-rw-r--r--api4/system.go6
-rw-r--r--api4/team_test.go13
-rw-r--r--api4/user_test.go10
3 files changed, 15 insertions, 14 deletions
diff --git a/api4/system.go b/api4/system.go
index 65d3b424b..2f6e53ab8 100644
--- a/api4/system.go
+++ b/api4/system.go
@@ -12,7 +12,7 @@ import (
"github.com/mattermost/mattermost-server/mlog"
"github.com/mattermost/mattermost-server/model"
- "github.com/mattermost/mattermost-server/utils"
+ "github.com/mattermost/mattermost-server/services/filesstore"
)
func (api *API) InitSystem() {
@@ -427,7 +427,7 @@ func testS3(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- err := utils.CheckMandatoryS3Fields(&cfg.FileSettings)
+ err := filesstore.CheckMandatoryS3Fields(&cfg.FileSettings)
if err != nil {
c.Err = err
return
@@ -438,7 +438,7 @@ func testS3(c *Context, w http.ResponseWriter, r *http.Request) {
}
license := c.App.License()
- backend, appErr := utils.NewFileBackend(&cfg.FileSettings, license != nil && *license.Features.Compliance)
+ backend, appErr := filesstore.NewFileBackend(&cfg.FileSettings, license != nil && *license.Features.Compliance)
if appErr == nil {
appErr = backend.TestConnection()
}
diff --git a/api4/team_test.go b/api4/team_test.go
index 547b8d4a9..8f1027cc5 100644
--- a/api4/team_test.go
+++ b/api4/team_test.go
@@ -15,6 +15,7 @@ import (
"github.com/mattermost/mattermost-server/app"
"github.com/mattermost/mattermost-server/model"
+ "github.com/mattermost/mattermost-server/services/mailservice"
"github.com/mattermost/mattermost-server/utils"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -1894,8 +1895,8 @@ func TestInviteUsersToTeam(t *testing.T) {
emailList := []string{user1, user2}
//Delete all the messages before check the sample email
- utils.DeleteMailBox(user1)
- utils.DeleteMailBox(user2)
+ mailservice.DeleteMailBox(user1)
+ mailservice.DeleteMailBox(user2)
enableEmailInvitations := *th.App.Config().ServiceSettings.EnableEmailInvitations
restrictCreationToDomains := th.App.Config().TeamSettings.RestrictCreationToDomains
@@ -1925,10 +1926,10 @@ func TestInviteUsersToTeam(t *testing.T) {
//Check if the email was send to the rigth email address
for _, email := range emailList {
- var resultsMailbox utils.JSONMessageHeaderInbucket
- err := utils.RetryInbucket(5, func() error {
+ var resultsMailbox mailservice.JSONMessageHeaderInbucket
+ err := mailservice.RetryInbucket(5, func() error {
var err error
- resultsMailbox, err = utils.GetMailBox(email)
+ resultsMailbox, err = mailservice.GetMailBox(email)
return err
})
if err != nil {
@@ -1939,7 +1940,7 @@ func TestInviteUsersToTeam(t *testing.T) {
if !strings.ContainsAny(resultsMailbox[len(resultsMailbox)-1].To[0], email) {
t.Fatal("Wrong To recipient")
} else {
- if resultsEmail, err := utils.GetMessageFromMailbox(email, resultsMailbox[len(resultsMailbox)-1].ID); err == nil {
+ if resultsEmail, err := mailservice.GetMessageFromMailbox(email, resultsMailbox[len(resultsMailbox)-1].ID); err == nil {
if resultsEmail.Subject != expectedSubject {
t.Log(resultsEmail.Subject)
t.Log(expectedSubject)
diff --git a/api4/user_test.go b/api4/user_test.go
index e624d747d..fd60a40ee 100644
--- a/api4/user_test.go
+++ b/api4/user_test.go
@@ -1919,7 +1919,7 @@ func TestUpdateUserPassword(t *testing.T) {
Client.Logout()
user := th.BasicUser
// Delete all the messages before check the reset password
- utils.DeleteMailBox(user.Email)
+ mailservice.DeleteMailBox(user.Email)
success, resp := Client.SendPasswordResetEmail(user.Email)
CheckNoError(t, resp)
if !success {
@@ -1934,10 +1934,10 @@ func TestUpdateUserPassword(t *testing.T) {
t.Fatal("should have succeeded")
}
// Check if the email was send to the right email address and the recovery key match
- var resultsMailbox utils.JSONMessageHeaderInbucket
- err := utils.RetryInbucket(5, func() error {
+ var resultsMailbox mailservice.JSONMessageHeaderInbucket
+ err := mailservice.RetryInbucket(5, func() error {
var err error
- resultsMailbox, err = utils.GetMailBox(user.Email)
+ resultsMailbox, err = mailservice.GetMailBox(user.Email)
return err
})
if err != nil {
@@ -1949,7 +1949,7 @@ func TestUpdateUserPassword(t *testing.T) {
if !strings.ContainsAny(resultsMailbox[0].To[0], user.Email) {
t.Fatal("Wrong To recipient")
} else {
- if resultsEmail, err := utils.GetMessageFromMailbox(user.Email, resultsMailbox[0].ID); err == nil {
+ if resultsEmail, err := mailservice.GetMessageFromMailbox(user.Email, resultsMailbox[0].ID); err == nil {
loc := strings.Index(resultsEmail.Body.Text, "token=")
if loc == -1 {
t.Log(resultsEmail.Body.Text)