mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Revert " PLT-7 adding loc for db calls"
This commit is contained in:
12
api/admin.go
12
api/admin.go
@@ -128,7 +128,7 @@ func testEmail(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.User().Get(c.T, c.Session.UserId); result.Err != nil {
|
||||
if result := <-Srv.Store.User().Get(c.Session.UserId); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -157,9 +157,9 @@ func getAnalytics(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
rows[0] = &model.AnalyticsRow{"channel_open_count", 0}
|
||||
rows[1] = &model.AnalyticsRow{"channel_private_count", 0}
|
||||
rows[2] = &model.AnalyticsRow{"post_count", 0}
|
||||
openChan := Srv.Store.Channel().AnalyticsTypeCount(c.T, teamId, model.CHANNEL_OPEN)
|
||||
privateChan := Srv.Store.Channel().AnalyticsTypeCount(c.T, teamId, model.CHANNEL_PRIVATE)
|
||||
postChan := Srv.Store.Post().AnalyticsPostCount(c.T, teamId)
|
||||
openChan := Srv.Store.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_OPEN)
|
||||
privateChan := Srv.Store.Channel().AnalyticsTypeCount(teamId, model.CHANNEL_PRIVATE)
|
||||
postChan := Srv.Store.Post().AnalyticsPostCount(teamId)
|
||||
|
||||
if r := <-openChan; r.Err != nil {
|
||||
c.Err = r.Err
|
||||
@@ -184,14 +184,14 @@ func getAnalytics(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
w.Write([]byte(rows.ToJson()))
|
||||
} else if name == "post_counts_day" {
|
||||
if r := <-Srv.Store.Post().AnalyticsPostCountsByDay(c.T, teamId); r.Err != nil {
|
||||
if r := <-Srv.Store.Post().AnalyticsPostCountsByDay(teamId); r.Err != nil {
|
||||
c.Err = r.Err
|
||||
return
|
||||
} else {
|
||||
w.Write([]byte(r.Data.(model.AnalyticsRows).ToJson()))
|
||||
}
|
||||
} else if name == "user_counts_with_posts_day" {
|
||||
if r := <-Srv.Store.Post().AnalyticsUserCountsWithPostsByDay(c.T, teamId); r.Err != nil {
|
||||
if r := <-Srv.Store.Post().AnalyticsUserCountsWithPostsByDay(teamId); r.Err != nil {
|
||||
c.Err = r.Err
|
||||
return
|
||||
} else {
|
||||
|
||||
@@ -19,7 +19,7 @@ func TestGetLogs(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -63,7 +63,7 @@ func TestGetConfig(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -97,7 +97,7 @@ func TestSaveConfig(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -131,7 +131,7 @@ func TestEmailTest(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -159,7 +159,7 @@ func TestGetAnalyticsStandard(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -225,7 +225,7 @@ func TestGetPostCount(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -270,7 +270,7 @@ func TestUserCountsWithPostsByDay(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ func SetupBenchmark() (*model.Team, *model.User, *model.Channel) {
|
||||
team = Client.Must(Client.CreateTeam(team)).Data.(*model.Team)
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "benchmark@test.com", Nickname: "Mr. Benchmarker", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
channel := &model.Channel{DisplayName: "Benchmark Channel", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id}
|
||||
channel = Client.Must(Client.CreateChannel(channel)).Data.(*model.Channel)
|
||||
|
||||
@@ -46,7 +46,7 @@ func CreateBasicUser(client *model.Client) *model.AppError {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, result.Data.(*model.User).Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(result.Data.(*model.User).Id))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -73,7 +73,7 @@ func (cfg *AutoUserCreator) createRandomUser() (*model.User, bool) {
|
||||
return nil, false
|
||||
}
|
||||
// We need to cheat to verify the user's email
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, result.Data.(*model.User).Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(result.Data.(*model.User).Id))
|
||||
return result.Data.(*model.User), true
|
||||
}
|
||||
|
||||
|
||||
132
api/channel.go
132
api/channel.go
@@ -5,14 +5,12 @@ package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/mattermost/platform/model"
|
||||
goi18n "github.com/nicksnyder/go-i18n/i18n"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -78,7 +76,7 @@ func createChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func CreateChannel(c *Context, channel *model.Channel, addMember bool) (*model.Channel, *model.AppError) {
|
||||
if result := <-Srv.Store.Channel().Save(c.T, channel); result.Err != nil {
|
||||
if result := <-Srv.Store.Channel().Save(channel); result.Err != nil {
|
||||
return nil, result.Err
|
||||
} else {
|
||||
sc := result.Data.(*model.Channel)
|
||||
@@ -87,7 +85,7 @@ func CreateChannel(c *Context, channel *model.Channel, addMember bool) (*model.C
|
||||
cm := &model.ChannelMember{ChannelId: sc.Id, UserId: c.Session.UserId,
|
||||
Roles: model.CHANNEL_ROLE_ADMIN, NotifyProps: model.GetDefaultChannelNotifyProps()}
|
||||
|
||||
if cmresult := <-Srv.Store.Channel().SaveMember(c.T, cm); cmresult.Err != nil {
|
||||
if cmresult := <-Srv.Store.Channel().SaveMember(cm); cmresult.Err != nil {
|
||||
return nil, cmresult.Err
|
||||
}
|
||||
}
|
||||
@@ -125,7 +123,7 @@ func CreateDirectChannel(c *Context, otherUserId string) (*model.Channel, *model
|
||||
return nil, model.NewAppError("CreateDirectChannel", "Invalid other user id ", otherUserId)
|
||||
}
|
||||
|
||||
uc := Srv.Store.User().Get(c.T, otherUserId)
|
||||
uc := Srv.Store.User().Get(otherUserId)
|
||||
|
||||
channel := new(model.Channel)
|
||||
|
||||
@@ -151,7 +149,7 @@ func CreateDirectChannel(c *Context, otherUserId string) (*model.Channel, *model
|
||||
NotifyProps: model.GetDefaultChannelNotifyProps(),
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Channel().SaveDirectChannel(c.T, channel, cm1, cm2); result.Err != nil {
|
||||
if result := <-Srv.Store.Channel().SaveDirectChannel(channel, cm1, cm2); result.Err != nil {
|
||||
return nil, result.Err
|
||||
} else {
|
||||
return result.Data.(*model.Channel), nil
|
||||
@@ -184,8 +182,8 @@ func updateChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
sc := Srv.Store.Channel().Get(c.T, channel.Id)
|
||||
cmc := Srv.Store.Channel().GetMember(c.T, channel.Id, c.Session.UserId)
|
||||
sc := Srv.Store.Channel().Get(channel.Id)
|
||||
cmc := Srv.Store.Channel().GetMember(channel.Id, c.Session.UserId)
|
||||
|
||||
if cresult := <-sc; cresult.Err != nil {
|
||||
c.Err = cresult.Err
|
||||
@@ -235,7 +233,7 @@ func updateChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
oldChannel.Type = channel.Type
|
||||
}
|
||||
|
||||
if ucresult := <-Srv.Store.Channel().Update(c.T, oldChannel); ucresult.Err != nil {
|
||||
if ucresult := <-Srv.Store.Channel().Update(oldChannel); ucresult.Err != nil {
|
||||
c.Err = ucresult.Err
|
||||
return
|
||||
} else {
|
||||
@@ -260,8 +258,8 @@ func updateChannelHeader(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
sc := Srv.Store.Channel().Get(c.T, channelId)
|
||||
cmc := Srv.Store.Channel().GetMember(c.T, channelId, c.Session.UserId)
|
||||
sc := Srv.Store.Channel().Get(channelId)
|
||||
cmc := Srv.Store.Channel().GetMember(channelId, c.Session.UserId)
|
||||
|
||||
if cresult := <-sc; cresult.Err != nil {
|
||||
c.Err = cresult.Err
|
||||
@@ -279,7 +277,7 @@ func updateChannelHeader(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
oldChannelHeader := channel.Header
|
||||
channel.Header = channelHeader
|
||||
|
||||
if ucresult := <-Srv.Store.Channel().Update(c.T, channel); ucresult.Err != nil {
|
||||
if ucresult := <-Srv.Store.Channel().Update(channel); ucresult.Err != nil {
|
||||
c.Err = ucresult.Err
|
||||
return
|
||||
} else {
|
||||
@@ -292,7 +290,7 @@ func updateChannelHeader(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func PostUpdateChannelHeaderMessageAndForget(c *Context, channelId string, oldChannelHeader, newChannelHeader string) {
|
||||
go func() {
|
||||
uc := Srv.Store.User().Get(c.T, c.Session.UserId)
|
||||
uc := Srv.Store.User().Get(c.Session.UserId)
|
||||
|
||||
if uresult := <-uc; uresult.Err != nil {
|
||||
l4g.Error("Failed to retrieve user while trying to save update channel header message %v", uresult.Err)
|
||||
@@ -335,8 +333,8 @@ func updateChannelPurpose(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
sc := Srv.Store.Channel().Get(c.T, channelId)
|
||||
cmc := Srv.Store.Channel().GetMember(c.T, channelId, c.Session.UserId)
|
||||
sc := Srv.Store.Channel().Get(channelId)
|
||||
cmc := Srv.Store.Channel().GetMember(channelId, c.Session.UserId)
|
||||
|
||||
if cresult := <-sc; cresult.Err != nil {
|
||||
c.Err = cresult.Err
|
||||
@@ -354,7 +352,7 @@ func updateChannelPurpose(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
channel.Purpose = channelPurpose
|
||||
|
||||
if ucresult := <-Srv.Store.Channel().Update(c.T, channel); ucresult.Err != nil {
|
||||
if ucresult := <-Srv.Store.Channel().Update(channel); ucresult.Err != nil {
|
||||
c.Err = ucresult.Err
|
||||
return
|
||||
} else {
|
||||
@@ -368,10 +366,10 @@ func getChannels(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// user is already in the team
|
||||
|
||||
if result := <-Srv.Store.Channel().GetChannels(c.T, c.Session.TeamId, c.Session.UserId); result.Err != nil {
|
||||
if result := <-Srv.Store.Channel().GetChannels(c.Session.TeamId, c.Session.UserId); result.Err != nil {
|
||||
if result.Err.Message == "No channels were found" {
|
||||
// lets make sure the user is valid
|
||||
if result := <-Srv.Store.User().Get(c.T, c.Session.UserId); result.Err != nil {
|
||||
if result := <-Srv.Store.User().Get(c.Session.UserId); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
c.RemoveSessionCookie(w, r)
|
||||
l4g.Error("Error in getting users profile for id=%v forcing logout", c.Session.UserId)
|
||||
@@ -393,7 +391,7 @@ func getMoreChannels(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// user is already in the team
|
||||
|
||||
if result := <-Srv.Store.Channel().GetMoreChannels(c.T, c.Session.TeamId, c.Session.UserId); result.Err != nil {
|
||||
if result := <-Srv.Store.Channel().GetMoreChannels(c.Session.TeamId, c.Session.UserId); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else if HandleEtag(result.Data.(*model.ChannelList).Etag(), w, r) {
|
||||
@@ -409,7 +407,7 @@ func getChannelCounts(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// user is already in the team
|
||||
|
||||
if result := <-Srv.Store.Channel().GetChannelCounts(c.T, c.Session.TeamId, c.Session.UserId); result.Err != nil {
|
||||
if result := <-Srv.Store.Channel().GetChannelCounts(c.Session.TeamId, c.Session.UserId); result.Err != nil {
|
||||
c.Err = model.NewAppError("getChannelCounts", "Unable to get channel counts from the database", result.Err.Message)
|
||||
return
|
||||
} else if HandleEtag(result.Data.(*model.ChannelCounts).Etag(), w, r) {
|
||||
@@ -439,8 +437,8 @@ func join(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func JoinChannel(c *Context, channelId string, role string) {
|
||||
|
||||
sc := Srv.Store.Channel().Get(c.T, channelId)
|
||||
uc := Srv.Store.User().Get(c.T, c.Session.UserId)
|
||||
sc := Srv.Store.Channel().Get(channelId)
|
||||
uc := Srv.Store.User().Get(c.Session.UserId)
|
||||
|
||||
if cresult := <-sc; cresult.Err != nil {
|
||||
c.Err = cresult.Err
|
||||
@@ -457,7 +455,7 @@ func JoinChannel(c *Context, channelId string, role string) {
|
||||
}
|
||||
|
||||
if channel.Type == model.CHANNEL_OPEN {
|
||||
if _, err := AddUserToChannel(c.T, user, channel); err != nil {
|
||||
if _, err := AddUserToChannel(user, channel); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
@@ -483,7 +481,7 @@ func PostUserAddRemoveMessageAndForget(c *Context, channelId string, message str
|
||||
}()
|
||||
}
|
||||
|
||||
func AddUserToChannel(T goi18n.TranslateFunc, user *model.User, channel *model.Channel) (*model.ChannelMember, *model.AppError) {
|
||||
func AddUserToChannel(user *model.User, channel *model.Channel) (*model.ChannelMember, *model.AppError) {
|
||||
if channel.DeleteAt > 0 {
|
||||
return nil, model.NewAppError("AddUserToChannel", "The channel has been archived or deleted", "")
|
||||
}
|
||||
@@ -493,7 +491,7 @@ func AddUserToChannel(T goi18n.TranslateFunc, user *model.User, channel *model.C
|
||||
}
|
||||
|
||||
newMember := &model.ChannelMember{ChannelId: channel.Id, UserId: user.Id, NotifyProps: model.GetDefaultChannelNotifyProps()}
|
||||
if cmresult := <-Srv.Store.Channel().SaveMember(T, newMember); cmresult.Err != nil {
|
||||
if cmresult := <-Srv.Store.Channel().SaveMember(newMember); cmresult.Err != nil {
|
||||
l4g.Error("Failed to add member user_id=%v channel_id=%v err=%v", user.Id, channel.Id, cmresult.Err)
|
||||
return nil, model.NewAppError("AddUserToChannel", "Failed to add user to channel", "")
|
||||
}
|
||||
@@ -508,29 +506,29 @@ func AddUserToChannel(T goi18n.TranslateFunc, user *model.User, channel *model.C
|
||||
return newMember, nil
|
||||
}
|
||||
|
||||
func JoinDefaultChannels(T goi18n.TranslateFunc, user *model.User, channelRole string) *model.AppError {
|
||||
func JoinDefaultChannels(user *model.User, channelRole string) *model.AppError {
|
||||
// We don't call JoinChannel here since c.Session is not populated on user creation
|
||||
|
||||
var err *model.AppError = nil
|
||||
|
||||
if result := <-Srv.Store.Channel().GetByName(T, user.TeamId, "town-square"); result.Err != nil {
|
||||
if result := <-Srv.Store.Channel().GetByName(user.TeamId, "town-square"); result.Err != nil {
|
||||
err = result.Err
|
||||
} else {
|
||||
cm := &model.ChannelMember{ChannelId: result.Data.(*model.Channel).Id, UserId: user.Id,
|
||||
Roles: channelRole, NotifyProps: model.GetDefaultChannelNotifyProps()}
|
||||
|
||||
if cmResult := <-Srv.Store.Channel().SaveMember(T, cm); cmResult.Err != nil {
|
||||
if cmResult := <-Srv.Store.Channel().SaveMember(cm); cmResult.Err != nil {
|
||||
err = cmResult.Err
|
||||
}
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Channel().GetByName(T, user.TeamId, "off-topic"); result.Err != nil {
|
||||
if result := <-Srv.Store.Channel().GetByName(user.TeamId, "off-topic"); result.Err != nil {
|
||||
err = result.Err
|
||||
} else {
|
||||
cm := &model.ChannelMember{ChannelId: result.Data.(*model.Channel).Id, UserId: user.Id,
|
||||
Roles: channelRole, NotifyProps: model.GetDefaultChannelNotifyProps()}
|
||||
|
||||
if cmResult := <-Srv.Store.Channel().SaveMember(T, cm); cmResult.Err != nil {
|
||||
if cmResult := <-Srv.Store.Channel().SaveMember(cm); cmResult.Err != nil {
|
||||
err = cmResult.Err
|
||||
}
|
||||
}
|
||||
@@ -543,8 +541,8 @@ func leave(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
params := mux.Vars(r)
|
||||
id := params["id"]
|
||||
|
||||
sc := Srv.Store.Channel().Get(c.T, id)
|
||||
uc := Srv.Store.User().Get(c.T, c.Session.UserId)
|
||||
sc := Srv.Store.Channel().Get(id)
|
||||
uc := Srv.Store.User().Get(c.Session.UserId)
|
||||
|
||||
if cresult := <-sc; cresult.Err != nil {
|
||||
c.Err = cresult.Err
|
||||
@@ -572,12 +570,12 @@ func leave(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if cmresult := <-Srv.Store.Channel().RemoveMember(c.T, channel.Id, c.Session.UserId); cmresult.Err != nil {
|
||||
if cmresult := <-Srv.Store.Channel().RemoveMember(channel.Id, c.Session.UserId); cmresult.Err != nil {
|
||||
c.Err = cmresult.Err
|
||||
return
|
||||
}
|
||||
|
||||
RemoveUserFromChannel(c.T, c.Session.UserId, c.Session.UserId, channel)
|
||||
RemoveUserFromChannel(c.Session.UserId, c.Session.UserId, channel)
|
||||
|
||||
PostUserAddRemoveMessageAndForget(c, channel.Id, fmt.Sprintf(`%v has left the channel.`, user.Username))
|
||||
|
||||
@@ -592,11 +590,11 @@ func deleteChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
params := mux.Vars(r)
|
||||
id := params["id"]
|
||||
|
||||
sc := Srv.Store.Channel().Get(c.T, id)
|
||||
scm := Srv.Store.Channel().GetMember(c.T, id, c.Session.UserId)
|
||||
uc := Srv.Store.User().Get(c.T, c.Session.UserId)
|
||||
ihc := Srv.Store.Webhook().GetIncomingByChannel(c.T, id)
|
||||
ohc := Srv.Store.Webhook().GetOutgoingByChannel(c.T, id)
|
||||
sc := Srv.Store.Channel().Get(id)
|
||||
scm := Srv.Store.Channel().GetMember(id, c.Session.UserId)
|
||||
uc := Srv.Store.User().Get(c.Session.UserId)
|
||||
ihc := Srv.Store.Webhook().GetIncomingByChannel(id)
|
||||
ohc := Srv.Store.Webhook().GetOutgoingByChannel(id)
|
||||
|
||||
if cresult := <-sc; cresult.Err != nil {
|
||||
c.Err = cresult.Err
|
||||
@@ -645,7 +643,7 @@ func deleteChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
now := model.GetMillis()
|
||||
for _, hook := range incomingHooks {
|
||||
go func() {
|
||||
if result := <-Srv.Store.Webhook().DeleteIncoming(c.T, hook.Id, now); result.Err != nil {
|
||||
if result := <-Srv.Store.Webhook().DeleteIncoming(hook.Id, now); result.Err != nil {
|
||||
l4g.Error("Encountered error deleting incoming webhook, id=" + hook.Id)
|
||||
}
|
||||
}()
|
||||
@@ -653,13 +651,13 @@ func deleteChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
for _, hook := range outgoingHooks {
|
||||
go func() {
|
||||
if result := <-Srv.Store.Webhook().DeleteOutgoing(c.T, hook.Id, now); result.Err != nil {
|
||||
if result := <-Srv.Store.Webhook().DeleteOutgoing(hook.Id, now); result.Err != nil {
|
||||
l4g.Error("Encountered error deleting outgoing webhook, id=" + hook.Id)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
if dresult := <-Srv.Store.Channel().Delete(c.T, channel.Id, model.GetMillis()); dresult.Err != nil {
|
||||
if dresult := <-Srv.Store.Channel().Delete(channel.Id, model.GetMillis()); dresult.Err != nil {
|
||||
c.Err = dresult.Err
|
||||
return
|
||||
}
|
||||
@@ -685,7 +683,7 @@ func updateLastViewedAt(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
params := mux.Vars(r)
|
||||
id := params["id"]
|
||||
|
||||
Srv.Store.Channel().UpdateLastViewedAt(c.T, id, c.Session.UserId)
|
||||
Srv.Store.Channel().UpdateLastViewedAt(id, c.Session.UserId)
|
||||
|
||||
preference := model.Preference{
|
||||
UserId: c.Session.UserId,
|
||||
@@ -694,7 +692,7 @@ func updateLastViewedAt(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
Value: id,
|
||||
}
|
||||
|
||||
Srv.Store.Preference().Save(c.T, &model.Preferences{preference})
|
||||
Srv.Store.Preference().Save(&model.Preferences{preference})
|
||||
|
||||
message := model.NewMessage(c.Session.TeamId, id, c.Session.UserId, model.ACTION_CHANNEL_VIEWED)
|
||||
message.Add("channel_id", id)
|
||||
@@ -711,8 +709,8 @@ func getChannel(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
id := params["id"]
|
||||
|
||||
//pchan := Srv.Store.Channel().CheckPermissionsTo(c.Session.TeamId, id, c.Session.UserId)
|
||||
cchan := Srv.Store.Channel().Get(c.T, id)
|
||||
cmchan := Srv.Store.Channel().GetMember(c.T, id, c.Session.UserId)
|
||||
cchan := Srv.Store.Channel().Get(id)
|
||||
cmchan := Srv.Store.Channel().GetMember(id, c.Session.UserId)
|
||||
|
||||
if cresult := <-cchan; cresult.Err != nil {
|
||||
c.Err = cresult.Err
|
||||
@@ -751,7 +749,7 @@ func getChannelExtraInfo(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
memberLimit = int(memberLimitInt64)
|
||||
}
|
||||
|
||||
sc := Srv.Store.Channel().Get(c.T, id)
|
||||
sc := Srv.Store.Channel().Get(id)
|
||||
var channel *model.Channel
|
||||
if cresult := <-sc; cresult.Err != nil {
|
||||
c.Err = cresult.Err
|
||||
@@ -765,9 +763,9 @@ func getChannelExtraInfo(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
scm := Srv.Store.Channel().GetMember(c.T, id, c.Session.UserId)
|
||||
ecm := Srv.Store.Channel().GetExtraMembers(c.T, id, memberLimit)
|
||||
ccm := Srv.Store.Channel().GetMemberCount(c.T, id)
|
||||
scm := Srv.Store.Channel().GetMember(id, c.Session.UserId)
|
||||
ecm := Srv.Store.Channel().GetExtraMembers(id, memberLimit)
|
||||
ccm := Srv.Store.Channel().GetMemberCount(id)
|
||||
|
||||
if cmresult := <-scm; cmresult.Err != nil {
|
||||
c.Err = cmresult.Err
|
||||
@@ -816,10 +814,10 @@ func addMember(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.T, c.Session.TeamId, id, c.Session.UserId)
|
||||
sc := Srv.Store.Channel().Get(c.T, id)
|
||||
ouc := Srv.Store.User().Get(c.T, c.Session.UserId)
|
||||
nuc := Srv.Store.User().Get(c.T, userId)
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.Session.TeamId, id, c.Session.UserId)
|
||||
sc := Srv.Store.Channel().Get(id)
|
||||
ouc := Srv.Store.User().Get(c.Session.UserId)
|
||||
nuc := Srv.Store.User().Get(userId)
|
||||
|
||||
// Only need to be a member of the channel to add a new member
|
||||
if !c.HasPermissionsToChannel(cchan, "addMember") {
|
||||
@@ -842,7 +840,7 @@ func addMember(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
} else {
|
||||
oUser := oresult.Data.(*model.User)
|
||||
|
||||
cm, err := AddUserToChannel(c.T, nUser, channel)
|
||||
cm, err := AddUserToChannel(nUser, channel)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
@@ -852,7 +850,7 @@ func addMember(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
PostUserAddRemoveMessageAndForget(c, channel.Id, fmt.Sprintf(`%v added to the channel by %v`, nUser.Username, oUser.Username))
|
||||
|
||||
<-Srv.Store.Channel().UpdateLastViewedAt(c.T, id, oUser.Id)
|
||||
<-Srv.Store.Channel().UpdateLastViewedAt(id, oUser.Id)
|
||||
w.Write([]byte(cm.ToJson()))
|
||||
}
|
||||
}
|
||||
@@ -870,8 +868,8 @@ func removeMember(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
sc := Srv.Store.Channel().Get(c.T, channelId)
|
||||
cmc := Srv.Store.Channel().GetMember(c.T, channelId, c.Session.UserId)
|
||||
sc := Srv.Store.Channel().Get(channelId)
|
||||
cmc := Srv.Store.Channel().GetMember(channelId, c.Session.UserId)
|
||||
|
||||
if cresult := <-sc; cresult.Err != nil {
|
||||
c.Err = cresult.Err
|
||||
@@ -893,7 +891,7 @@ func removeMember(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := RemoveUserFromChannel(c.T, userIdToRemove, c.Session.UserId, channel); err != nil {
|
||||
if err := RemoveUserFromChannel(userIdToRemove, c.Session.UserId, channel); err != nil {
|
||||
c.Err = model.NewAppError("updateChannel", "Unable to remove user.", err.Message)
|
||||
return
|
||||
}
|
||||
@@ -908,12 +906,12 @@ func removeMember(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
}
|
||||
|
||||
func RemoveUserFromChannel(T goi18n.TranslateFunc, userIdToRemove string, removerUserId string, channel *model.Channel) *model.AppError {
|
||||
func RemoveUserFromChannel(userIdToRemove string, removerUserId string, channel *model.Channel) *model.AppError {
|
||||
if channel.DeleteAt > 0 {
|
||||
return model.NewAppError("updateChannel", "The channel has been archived or deleted", "")
|
||||
}
|
||||
|
||||
if cmresult := <-Srv.Store.Channel().RemoveMember(T, channel.Id, userIdToRemove); cmresult.Err != nil {
|
||||
if cmresult := <-Srv.Store.Channel().RemoveMember(channel.Id, userIdToRemove); cmresult.Err != nil {
|
||||
return cmresult.Err
|
||||
}
|
||||
|
||||
@@ -941,7 +939,7 @@ func updateNotifyProps(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.T, c.Session.TeamId, channelId, c.Session.UserId)
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.Session.TeamId, channelId, c.Session.UserId)
|
||||
|
||||
if !c.HasPermissionsToUser(userId, "updateNotifyLevel") {
|
||||
return
|
||||
@@ -951,7 +949,7 @@ func updateNotifyProps(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
result := <-Srv.Store.Channel().GetMember(c.T, channelId, userId)
|
||||
result := <-Srv.Store.Channel().GetMember(channelId, userId)
|
||||
if result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
@@ -968,7 +966,7 @@ func updateNotifyProps(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
member.NotifyProps["desktop"] = desktop
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Channel().UpdateMember(c.T, &member); result.Err != nil {
|
||||
if result := <-Srv.Store.Channel().UpdateMember(&member); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
|
||||
@@ -140,7 +140,7 @@ func BenchmarkJoinChannel(b *testing.B) {
|
||||
// Secondary test user to join channels created by primary test user
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "random@test.com", Nickname: "That Guy", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
// Benchmark Start
|
||||
|
||||
@@ -24,7 +24,7 @@ func TestCreateChannel(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -101,11 +101,11 @@ func TestCreateDirectChannel(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -156,15 +156,15 @@ func TestUpdateChannel(t *testing.T) {
|
||||
|
||||
userTeamAdmin := &model.User{TeamId: team.Id, Email: team.Email, Nickname: "Corey Hulen", Password: "pwd"}
|
||||
userTeamAdmin = Client.Must(Client.CreateUser(userTeamAdmin, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, userTeamAdmin.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(userTeamAdmin.Id))
|
||||
|
||||
userChannelAdmin := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
userChannelAdmin = Client.Must(Client.CreateUser(userChannelAdmin, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, userChannelAdmin.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(userChannelAdmin.Id))
|
||||
|
||||
userStd := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
userStd = Client.Must(Client.CreateUser(userStd, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, userStd.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(userStd.Id))
|
||||
userStd.Roles = ""
|
||||
|
||||
Client.LoginByEmail(team.Name, userChannelAdmin.Email, "pwd")
|
||||
@@ -238,7 +238,7 @@ func TestUpdateChannelHeader(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -278,7 +278,7 @@ func TestUpdateChannelHeader(t *testing.T) {
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user2.Email, "pwd")
|
||||
|
||||
@@ -297,7 +297,7 @@ func TestUpdateChannelPurpose(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -337,7 +337,7 @@ func TestUpdateChannelPurpose(t *testing.T) {
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user2.Email, "pwd")
|
||||
|
||||
@@ -356,7 +356,7 @@ func TestGetChannel(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -419,7 +419,7 @@ func TestGetMoreChannel(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -431,7 +431,7 @@ func TestGetMoreChannel(t *testing.T) {
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user2.Email, "pwd")
|
||||
|
||||
@@ -463,7 +463,7 @@ func TestGetChannelCounts(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -504,7 +504,7 @@ func TestJoinChannel(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -516,7 +516,7 @@ func TestJoinChannel(t *testing.T) {
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user2.Email, "pwd")
|
||||
|
||||
@@ -548,7 +548,7 @@ func TestLeaveChannel(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -560,7 +560,7 @@ func TestLeaveChannel(t *testing.T) {
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user2.Email, "pwd")
|
||||
|
||||
@@ -597,11 +597,11 @@ func TestDeleteChannel(t *testing.T) {
|
||||
|
||||
userTeamAdmin := &model.User{TeamId: team.Id, Email: team.Email, Nickname: "Corey Hulen", Password: "pwd"}
|
||||
userTeamAdmin = Client.Must(Client.CreateUser(userTeamAdmin, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, userTeamAdmin.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(userTeamAdmin.Id))
|
||||
|
||||
userChannelAdmin := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
userChannelAdmin = Client.Must(Client.CreateUser(userChannelAdmin, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, userChannelAdmin.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(userChannelAdmin.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, userChannelAdmin.Email, "pwd")
|
||||
|
||||
@@ -633,7 +633,7 @@ func TestDeleteChannel(t *testing.T) {
|
||||
|
||||
userStd := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
userStd = Client.Must(Client.CreateUser(userStd, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, userStd.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(userStd.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, userStd.Email, "pwd")
|
||||
|
||||
@@ -667,7 +667,7 @@ func TestGetChannelExtraInfo(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -703,7 +703,7 @@ func TestGetChannelExtraInfo(t *testing.T) {
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "tester2@test.com", Nickname: "Tester 2", Password: "pwd"}
|
||||
user2 = Client2.Must(Client2.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
Client2.LoginByEmail(team.Name, user2.Email, "pwd")
|
||||
Client2.Must(Client2.JoinChannel(channel1.Id))
|
||||
@@ -791,7 +791,7 @@ func TestAddChannelMember(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -800,7 +800,7 @@ func TestAddChannelMember(t *testing.T) {
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
if _, err := Client.AddChannelMember(channel1.Id, user2.Id); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -849,11 +849,11 @@ func TestRemoveChannelMember(t *testing.T) {
|
||||
|
||||
userTeamAdmin := &model.User{TeamId: team.Id, Email: team.Email, Nickname: "Corey Hulen", Password: "pwd"}
|
||||
userTeamAdmin = Client.Must(Client.CreateUser(userTeamAdmin, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, userTeamAdmin.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(userTeamAdmin.Id))
|
||||
|
||||
userChannelAdmin := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
userChannelAdmin = Client.Must(Client.CreateUser(userChannelAdmin, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, userChannelAdmin.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(userChannelAdmin.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, userChannelAdmin.Email, "pwd")
|
||||
|
||||
@@ -869,7 +869,7 @@ func TestRemoveChannelMember(t *testing.T) {
|
||||
|
||||
userStd := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
userStd = Client.Must(Client.CreateUser(userStd, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, userStd.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(userStd.Id))
|
||||
|
||||
Client.Must(Client.AddChannelMember(channel1.Id, userStd.Id))
|
||||
|
||||
@@ -919,7 +919,7 @@ func TestUpdateNotifyProps(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -1041,7 +1041,7 @@ func TestFuzzyChannel(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ func checkCommand(c *Context, command *model.Command) bool {
|
||||
}
|
||||
|
||||
if len(command.ChannelId) > 0 {
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.T, c.Session.TeamId, command.ChannelId, c.Session.UserId)
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.Session.TeamId, command.ChannelId, c.Session.UserId)
|
||||
|
||||
if !c.HasPermissionsToChannel(cchan, "checkCommand") {
|
||||
return true
|
||||
@@ -269,7 +269,7 @@ func joinCommand(c *Context, command *model.Command) bool {
|
||||
startsWith = parts[1]
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Channel().GetMoreChannels(c.T, c.Session.TeamId, c.Session.UserId); result.Err != nil {
|
||||
if result := <-Srv.Store.Channel().GetMoreChannels(c.Session.TeamId, c.Session.UserId); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return false
|
||||
} else {
|
||||
@@ -544,7 +544,7 @@ func loadTestPostsCommand(c *Context, command *model.Command) bool {
|
||||
}
|
||||
|
||||
var usernames []string
|
||||
if result := <-Srv.Store.User().GetProfiles(c.T, c.Session.TeamId); result.Err == nil {
|
||||
if result := <-Srv.Store.User().GetProfiles(c.Session.TeamId); result.Err == nil {
|
||||
profileUsers := result.Data.(map[string]*model.User)
|
||||
usernames = make([]string, len(profileUsers))
|
||||
i := 0
|
||||
|
||||
@@ -21,7 +21,7 @@ func TestSuggestRootCommands(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -70,7 +70,7 @@ func TestLogoutCommands(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -88,7 +88,7 @@ func TestJoinCommands(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -102,7 +102,7 @@ func TestJoinCommands(t *testing.T) {
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
data := make(map[string]string)
|
||||
data["user_id"] = user2.Id
|
||||
@@ -164,7 +164,7 @@ func TestEchoCommand(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -202,7 +202,7 @@ func TestLoadTestUrlCommand(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if len(token) != 0 {
|
||||
session := GetSession(c.T, token)
|
||||
session := GetSession(token)
|
||||
|
||||
if session == nil || session.IsExpired() {
|
||||
c.RemoveSessionCookie(w, r)
|
||||
@@ -195,7 +195,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if c.Err == nil && h.isUserActivity && token != "" && len(c.Session.UserId) > 0 {
|
||||
go func() {
|
||||
if err := (<-Srv.Store.User().UpdateUserAndSessionActivity(c.T, c.Session.UserId, c.Session.Id, model.GetMillis())).Err; err != nil {
|
||||
if err := (<-Srv.Store.User().UpdateUserAndSessionActivity(c.Session.UserId, c.Session.Id, model.GetMillis())).Err; err != nil {
|
||||
l4g.Error("Failed to update LastActivityAt for user_id=%v and session_id=%v, err=%v", c.Session.UserId, c.Session.Id, err)
|
||||
}
|
||||
}()
|
||||
@@ -233,7 +233,7 @@ func GetProtocol(r *http.Request) string {
|
||||
|
||||
func (c *Context) LogAudit(extraInfo string) {
|
||||
audit := &model.Audit{UserId: c.Session.UserId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.Id}
|
||||
if r := <-Srv.Store.Audit().Save(c.T, audit); r.Err != nil {
|
||||
if r := <-Srv.Store.Audit().Save(audit); r.Err != nil {
|
||||
c.LogError(r.Err)
|
||||
}
|
||||
}
|
||||
@@ -245,7 +245,7 @@ func (c *Context) LogAuditWithUserId(userId, extraInfo string) {
|
||||
}
|
||||
|
||||
audit := &model.Audit{UserId: userId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.Id}
|
||||
if r := <-Srv.Store.Audit().Save(c.T, audit); r.Err != nil {
|
||||
if r := <-Srv.Store.Audit().Save(audit); r.Err != nil {
|
||||
c.LogError(r.Err)
|
||||
}
|
||||
}
|
||||
@@ -387,7 +387,7 @@ func (c *Context) setTeamURL(url string, valid bool) {
|
||||
}
|
||||
|
||||
func (c *Context) SetTeamURLFromSession() {
|
||||
if result := <-Srv.Store.Team().Get(c.T, c.Session.TeamId); result.Err == nil {
|
||||
if result := <-Srv.Store.Team().Get(c.Session.TeamId); result.Err == nil {
|
||||
c.setTeamURL(c.GetSiteURL()+"/"+result.Data.(*model.Team).Name, true)
|
||||
}
|
||||
}
|
||||
@@ -515,14 +515,14 @@ func Handle404(w http.ResponseWriter, r *http.Request) {
|
||||
RenderWebError(err, w, r)
|
||||
}
|
||||
|
||||
func GetSession(T goi18n.TranslateFunc, token string) *model.Session {
|
||||
func GetSession(token string) *model.Session {
|
||||
var session *model.Session
|
||||
if ts, ok := sessionCache.Get(token); ok {
|
||||
session = ts.(*model.Session)
|
||||
}
|
||||
|
||||
if session == nil {
|
||||
if sessionResult := <-Srv.Store.Session().Get(T, token); sessionResult.Err != nil {
|
||||
if sessionResult := <-Srv.Store.Session().Get(token); sessionResult.Err != nil {
|
||||
l4g.Error("Invalid session token=" + token + ", err=" + sessionResult.Err.DetailedError)
|
||||
} else {
|
||||
session = sessionResult.Data.(*model.Session)
|
||||
@@ -551,9 +551,9 @@ func GetMultiSessionCookieTokens(r *http.Request) []string {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
func FindMultiSessionForTeamId(T goi18n.TranslateFunc, r *http.Request, teamId string) (int64, *model.Session) {
|
||||
func FindMultiSessionForTeamId(r *http.Request, teamId string) (int64, *model.Session) {
|
||||
for index, token := range GetMultiSessionCookieTokens(r) {
|
||||
s := GetSession(T, token)
|
||||
s := GetSession(token)
|
||||
if s != nil && !s.IsExpired() && s.TeamId == teamId {
|
||||
return int64(index), s
|
||||
}
|
||||
|
||||
@@ -6,12 +6,10 @@ package api
|
||||
import (
|
||||
"archive/zip"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/mattermost/platform/model"
|
||||
"github.com/mattermost/platform/utils"
|
||||
goi18n "github.com/nicksnyder/go-i18n/i18n"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -53,19 +51,19 @@ func ExportOptionsFromJson(data io.Reader) *ExportOptions {
|
||||
return &o
|
||||
}
|
||||
|
||||
func ExportToFile(T goi18n.TranslateFunc, options *ExportOptions) (link string, err *model.AppError) {
|
||||
func ExportToFile(options *ExportOptions) (link string, err *model.AppError) {
|
||||
// Open file for export
|
||||
if file, err := openFileWriteStream(EXPORT_PATH + EXPORT_FILENAME); err != nil {
|
||||
return "", err
|
||||
} else {
|
||||
defer closeFileWriteStream(file)
|
||||
ExportToWriter(T, file, options)
|
||||
ExportToWriter(file, options)
|
||||
}
|
||||
|
||||
return "/api/v1/files/get_export", nil
|
||||
}
|
||||
|
||||
func ExportToWriter(T goi18n.TranslateFunc, w io.Writer, options *ExportOptions) *model.AppError {
|
||||
func ExportToWriter(w io.Writer, options *ExportOptions) *model.AppError {
|
||||
// Open a writer to write to zip file
|
||||
zipWriter := zip.NewWriter(w)
|
||||
defer zipWriter.Close()
|
||||
@@ -80,23 +78,23 @@ func ExportToWriter(T goi18n.TranslateFunc, w io.Writer, options *ExportOptions)
|
||||
}
|
||||
|
||||
// Export Teams
|
||||
ExportTeams(T, zipWriter, options)
|
||||
ExportTeams(zipWriter, options)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func ExportTeams(T goi18n.TranslateFunc, writer ExportWriter, options *ExportOptions) *model.AppError {
|
||||
func ExportTeams(writer ExportWriter, options *ExportOptions) *model.AppError {
|
||||
// Get the teams
|
||||
var teams []*model.Team
|
||||
if len(options.TeamsToExport) == 0 {
|
||||
if result := <-Srv.Store.Team().GetAll(T); result.Err != nil {
|
||||
if result := <-Srv.Store.Team().GetAll(); result.Err != nil {
|
||||
return result.Err
|
||||
} else {
|
||||
teams = result.Data.([]*model.Team)
|
||||
}
|
||||
} else {
|
||||
for _, teamId := range options.TeamsToExport {
|
||||
if result := <-Srv.Store.Team().Get(T, teamId); result.Err != nil {
|
||||
if result := <-Srv.Store.Team().Get(teamId); result.Err != nil {
|
||||
return result.Err
|
||||
} else {
|
||||
team := result.Data.(*model.Team)
|
||||
@@ -122,10 +120,10 @@ func ExportTeams(T goi18n.TranslateFunc, writer ExportWriter, options *ExportOpt
|
||||
|
||||
// Export the channels, local storage and users
|
||||
for _, team := range teams {
|
||||
if err := ExportChannels(T, writer, options, team.Id); err != nil {
|
||||
if err := ExportChannels(writer, options, team.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ExportUsers(T, writer, options, team.Id); err != nil {
|
||||
if err := ExportUsers(writer, options, team.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ExportLocalStorage(writer, options, team.Id); err != nil {
|
||||
@@ -136,18 +134,18 @@ func ExportTeams(T goi18n.TranslateFunc, writer ExportWriter, options *ExportOpt
|
||||
return nil
|
||||
}
|
||||
|
||||
func ExportChannels(T goi18n.TranslateFunc, writer ExportWriter, options *ExportOptions, teamId string) *model.AppError {
|
||||
func ExportChannels(writer ExportWriter, options *ExportOptions, teamId string) *model.AppError {
|
||||
// Get the channels
|
||||
var channels []*model.Channel
|
||||
if len(options.ChannelsToExport) == 0 {
|
||||
if result := <-Srv.Store.Channel().GetForExport(T, teamId); result.Err != nil {
|
||||
if result := <-Srv.Store.Channel().GetForExport(teamId); result.Err != nil {
|
||||
return result.Err
|
||||
} else {
|
||||
channels = result.Data.([]*model.Channel)
|
||||
}
|
||||
} else {
|
||||
for _, channelId := range options.ChannelsToExport {
|
||||
if result := <-Srv.Store.Channel().Get(T, channelId); result.Err != nil {
|
||||
if result := <-Srv.Store.Channel().Get(channelId); result.Err != nil {
|
||||
return result.Err
|
||||
} else {
|
||||
channel := result.Data.(*model.Channel)
|
||||
@@ -158,7 +156,7 @@ func ExportChannels(T goi18n.TranslateFunc, writer ExportWriter, options *Export
|
||||
|
||||
for i := range channels {
|
||||
// Get members
|
||||
mchan := Srv.Store.Channel().GetMembers(T, channels[i].Id)
|
||||
mchan := Srv.Store.Channel().GetMembers(channels[i].Id)
|
||||
|
||||
// Sanitize
|
||||
channels[i].PreExport()
|
||||
@@ -192,7 +190,7 @@ func ExportChannels(T goi18n.TranslateFunc, writer ExportWriter, options *Export
|
||||
}
|
||||
|
||||
for _, channel := range channels {
|
||||
if err := ExportPosts(T, writer, options, channel.Id); err != nil {
|
||||
if err := ExportPosts(writer, options, channel.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -200,10 +198,10 @@ func ExportChannels(T goi18n.TranslateFunc, writer ExportWriter, options *Export
|
||||
return nil
|
||||
}
|
||||
|
||||
func ExportPosts(T goi18n.TranslateFunc, writer ExportWriter, options *ExportOptions, channelId string) *model.AppError {
|
||||
func ExportPosts(writer ExportWriter, options *ExportOptions, channelId string) *model.AppError {
|
||||
// Get the posts
|
||||
var posts []*model.Post
|
||||
if result := <-Srv.Store.Post().GetForExport(T, channelId); result.Err != nil {
|
||||
if result := <-Srv.Store.Post().GetForExport(channelId); result.Err != nil {
|
||||
return result.Err
|
||||
} else {
|
||||
posts = result.Data.([]*model.Post)
|
||||
@@ -225,10 +223,10 @@ func ExportPosts(T goi18n.TranslateFunc, writer ExportWriter, options *ExportOpt
|
||||
return nil
|
||||
}
|
||||
|
||||
func ExportUsers(T goi18n.TranslateFunc, writer ExportWriter, options *ExportOptions, teamId string) *model.AppError {
|
||||
func ExportUsers(writer ExportWriter, options *ExportOptions, teamId string) *model.AppError {
|
||||
// Get the users
|
||||
var users []*model.User
|
||||
if result := <-Srv.Store.User().GetForExport(T, teamId); result.Err != nil {
|
||||
if result := <-Srv.Store.User().GetForExport(teamId); result.Err != nil {
|
||||
return result.Err
|
||||
} else {
|
||||
users = result.Data.([]*model.User)
|
||||
|
||||
@@ -101,7 +101,7 @@ func uploadFile(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.T, c.Session.TeamId, channelId, c.Session.UserId)
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.Session.TeamId, channelId, c.Session.UserId)
|
||||
|
||||
files := m.File["files"]
|
||||
|
||||
@@ -319,7 +319,7 @@ func getFileInfo(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.T, c.Session.TeamId, channelId, c.Session.UserId)
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.Session.TeamId, channelId, c.Session.UserId)
|
||||
|
||||
path := "teams/" + c.Session.TeamId + "/channels/" + channelId + "/users/" + userId + "/" + filename
|
||||
var info *model.FileInfo
|
||||
@@ -380,7 +380,7 @@ func getFile(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
data := r.URL.Query().Get("d")
|
||||
teamId := r.URL.Query().Get("t")
|
||||
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.T, c.Session.TeamId, channelId, c.Session.UserId)
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.Session.TeamId, channelId, c.Session.UserId)
|
||||
|
||||
path := ""
|
||||
if len(teamId) == 26 {
|
||||
@@ -477,7 +477,7 @@ func getPublicLink(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
userId := matches[0][2]
|
||||
filename = matches[0][3]
|
||||
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.T, c.Session.TeamId, channelId, c.Session.UserId)
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.Session.TeamId, channelId, c.Session.UserId)
|
||||
|
||||
newProps := make(map[string]string)
|
||||
newProps["filename"] = filename
|
||||
|
||||
@@ -29,7 +29,7 @@ func TestUploadFile(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -144,7 +144,7 @@ func TestGetFile(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -214,7 +214,7 @@ func TestGetFile(t *testing.T) {
|
||||
|
||||
user2 := &model.User{TeamId: team2.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
newProps := make(map[string]string)
|
||||
newProps["filename"] = filenames[0]
|
||||
@@ -322,11 +322,11 @@ func TestGetPublicLink(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ package api
|
||||
import (
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/mattermost/platform/model"
|
||||
goi18n "github.com/nicksnyder/go-i18n/i18n"
|
||||
)
|
||||
|
||||
//
|
||||
@@ -14,28 +13,28 @@ import (
|
||||
// some of the usual checks. (IsValid is still run)
|
||||
//
|
||||
|
||||
func ImportPost(T goi18n.TranslateFunc, post *model.Post) {
|
||||
func ImportPost(post *model.Post) {
|
||||
post.Hashtags, _ = model.ParseHashtags(post.Message)
|
||||
|
||||
if result := <-Srv.Store.Post().Save(T, post); result.Err != nil {
|
||||
if result := <-Srv.Store.Post().Save(post); result.Err != nil {
|
||||
l4g.Debug("Error saving post. user=" + post.UserId + ", message=" + post.Message)
|
||||
}
|
||||
}
|
||||
|
||||
func ImportUser(T goi18n.TranslateFunc, user *model.User) *model.User {
|
||||
func ImportUser(user *model.User) *model.User {
|
||||
user.MakeNonNil()
|
||||
|
||||
if result := <-Srv.Store.User().Save(T, user); result.Err != nil {
|
||||
if result := <-Srv.Store.User().Save(user); result.Err != nil {
|
||||
l4g.Error("Error saving user. err=%v", result.Err)
|
||||
return nil
|
||||
} else {
|
||||
ruser := result.Data.(*model.User)
|
||||
|
||||
if err := JoinDefaultChannels(T, ruser, ""); err != nil {
|
||||
if err := JoinDefaultChannels(ruser, ""); err != nil {
|
||||
l4g.Error("Encountered an issue joining default channels user_id=%s, team_id=%s, err=%v", ruser.Id, ruser.TeamId, err)
|
||||
}
|
||||
|
||||
if cresult := <-Srv.Store.User().VerifyEmail(T, ruser.Id); cresult.Err != nil {
|
||||
if cresult := <-Srv.Store.User().VerifyEmail(ruser.Id); cresult.Err != nil {
|
||||
l4g.Error("Failed to set email verified err=%v", cresult.Err)
|
||||
}
|
||||
|
||||
@@ -43,8 +42,8 @@ func ImportUser(T goi18n.TranslateFunc, user *model.User) *model.User {
|
||||
}
|
||||
}
|
||||
|
||||
func ImportChannel(T goi18n.TranslateFunc, channel *model.Channel) *model.Channel {
|
||||
if result := <-Srv.Store.Channel().Save(T, channel); result.Err != nil {
|
||||
func ImportChannel(channel *model.Channel) *model.Channel {
|
||||
if result := <-Srv.Store.Channel().Save(channel); result.Err != nil {
|
||||
return nil
|
||||
} else {
|
||||
sc := result.Data.(*model.Channel)
|
||||
|
||||
26
api/oauth.go
26
api/oauth.go
@@ -5,14 +5,12 @@ package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/mattermost/platform/model"
|
||||
"github.com/mattermost/platform/utils"
|
||||
goi18n "github.com/nicksnyder/go-i18n/i18n"
|
||||
"net/http"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
func InitOAuth(r *mux.Router) {
|
||||
@@ -43,7 +41,7 @@ func registerOAuthApp(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
app.ClientSecret = secret
|
||||
app.CreatorId = c.Session.UserId
|
||||
|
||||
if result := <-Srv.Store.OAuth().SaveApp(c.T, app); result.Err != nil {
|
||||
if result := <-Srv.Store.OAuth().SaveApp(app); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -92,7 +90,7 @@ func allowOAuth(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
state := r.URL.Query().Get("state")
|
||||
|
||||
var app *model.OAuthApp
|
||||
if result := <-Srv.Store.OAuth().GetApp(c.T, clientId); result.Err != nil {
|
||||
if result := <-Srv.Store.OAuth().GetApp(clientId); result.Err != nil {
|
||||
c.Err = model.NewAppError("allowOAuth", "server_error: Error accessing the database", "")
|
||||
return
|
||||
} else {
|
||||
@@ -114,7 +112,7 @@ func allowOAuth(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
authData := &model.AuthData{UserId: c.Session.UserId, ClientId: clientId, CreateAt: model.GetMillis(), RedirectUri: redirectUri, State: state, Scope: scope}
|
||||
authData.Code = model.HashPassword(fmt.Sprintf("%v:%v:%v:%v", clientId, redirectUri, authData.CreateAt, c.Session.UserId))
|
||||
|
||||
if result := <-Srv.Store.OAuth().SaveAuthData(c.T, authData); result.Err != nil {
|
||||
if result := <-Srv.Store.OAuth().SaveAuthData(authData); result.Err != nil {
|
||||
responseData["redirect"] = redirectUri + "?error=server_error&state=" + state
|
||||
w.Write([]byte(model.MapToJson(responseData)))
|
||||
return
|
||||
@@ -127,20 +125,20 @@ func allowOAuth(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte(model.MapToJson(responseData)))
|
||||
}
|
||||
|
||||
func RevokeAccessToken(T goi18n.TranslateFunc, token string) *model.AppError {
|
||||
func RevokeAccessToken(token string) *model.AppError {
|
||||
|
||||
schan := Srv.Store.Session().Remove(T, token)
|
||||
schan := Srv.Store.Session().Remove(token)
|
||||
sessionCache.Remove(token)
|
||||
|
||||
var accessData *model.AccessData
|
||||
if result := <-Srv.Store.OAuth().GetAccessData(T, token); result.Err != nil {
|
||||
if result := <-Srv.Store.OAuth().GetAccessData(token); result.Err != nil {
|
||||
return model.NewAppError("RevokeAccessToken", "Error getting access token from DB before deletion", "")
|
||||
} else {
|
||||
accessData = result.Data.(*model.AccessData)
|
||||
}
|
||||
|
||||
tchan := Srv.Store.OAuth().RemoveAccessData(T, token)
|
||||
cchan := Srv.Store.OAuth().RemoveAuthData(T, accessData.AuthCode)
|
||||
tchan := Srv.Store.OAuth().RemoveAccessData(token)
|
||||
cchan := Srv.Store.OAuth().RemoveAuthData(accessData.AuthCode)
|
||||
|
||||
if result := <-tchan; result.Err != nil {
|
||||
return model.NewAppError("RevokeAccessToken", "Error deleting access token from DB", "")
|
||||
@@ -157,8 +155,8 @@ func RevokeAccessToken(T goi18n.TranslateFunc, token string) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetAuthData(T goi18n.TranslateFunc, code string) *model.AuthData {
|
||||
if result := <-Srv.Store.OAuth().GetAuthData(T, code); result.Err != nil {
|
||||
func GetAuthData(code string) *model.AuthData {
|
||||
if result := <-Srv.Store.OAuth().GetAuthData(code); result.Err != nil {
|
||||
l4g.Error("Couldn't find auth code for code=%s", code)
|
||||
return nil
|
||||
} else {
|
||||
|
||||
@@ -20,7 +20,7 @@ func TestRegisterApp(t *testing.T) {
|
||||
|
||||
user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Password: "pwd"}
|
||||
ruser := Client.Must(Client.CreateUser(&user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, ruser.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(ruser.Id))
|
||||
|
||||
app := &model.OAuthApp{Name: "TestApp" + model.NewId(), Homepage: "https://nowhere.com", Description: "test", CallbackUrls: []string{"https://nowhere.com"}}
|
||||
|
||||
@@ -77,7 +77,7 @@ func TestAllowOAuth(t *testing.T) {
|
||||
|
||||
user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Password: "pwd"}
|
||||
ruser := Client.Must(Client.CreateUser(&user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, ruser.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(ruser.Id))
|
||||
|
||||
app := &model.OAuthApp{Name: "TestApp" + model.NewId(), Homepage: "https://nowhere.com", Description: "test", CallbackUrls: []string{"https://nowhere.com"}}
|
||||
|
||||
|
||||
92
api/post.go
92
api/post.go
@@ -5,6 +5,11 @@ package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/mattermost/platform/model"
|
||||
"github.com/mattermost/platform/store"
|
||||
"github.com/mattermost/platform/utils"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
@@ -12,13 +17,6 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/mattermost/platform/model"
|
||||
"github.com/mattermost/platform/store"
|
||||
"github.com/mattermost/platform/utils"
|
||||
goi18n "github.com/nicksnyder/go-i18n/i18n"
|
||||
)
|
||||
|
||||
func InitPost(r *mux.Router) {
|
||||
@@ -46,7 +44,7 @@ func createPost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// Create and save post object to channel
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.T, c.Session.TeamId, post.ChannelId, c.Session.UserId)
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.Session.TeamId, post.ChannelId, c.Session.UserId)
|
||||
|
||||
if !c.HasPermissionsToChannel(cchan, "createPost") {
|
||||
return
|
||||
@@ -61,7 +59,7 @@ func createPost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
return
|
||||
} else {
|
||||
if result := <-Srv.Store.Channel().UpdateLastViewedAt(c.T, post.ChannelId, c.Session.UserId); result.Err != nil {
|
||||
if result := <-Srv.Store.Channel().UpdateLastViewedAt(post.ChannelId, c.Session.UserId); result.Err != nil {
|
||||
l4g.Error("Encountered error updating last viewed, channel_id=%s, user_id=%s, err=%v", post.ChannelId, c.Session.UserId, result.Err)
|
||||
}
|
||||
|
||||
@@ -72,7 +70,7 @@ func createPost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
func CreatePost(c *Context, post *model.Post, triggerWebhooks bool) (*model.Post, *model.AppError) {
|
||||
var pchan store.StoreChannel
|
||||
if len(post.RootId) > 0 {
|
||||
pchan = Srv.Store.Post().Get(c.T, post.RootId)
|
||||
pchan = Srv.Store.Post().Get(post.RootId)
|
||||
}
|
||||
|
||||
// Verify the parent/child relationships are correct
|
||||
@@ -138,7 +136,7 @@ func CreatePost(c *Context, post *model.Post, triggerWebhooks bool) (*model.Post
|
||||
}
|
||||
|
||||
var rpost *model.Post
|
||||
if result := <-Srv.Store.Post().Save(c.T, post); result.Err != nil {
|
||||
if result := <-Srv.Store.Post().Save(post); result.Err != nil {
|
||||
return nil, result.Err
|
||||
} else {
|
||||
rpost = result.Data.(*model.Post)
|
||||
@@ -205,9 +203,9 @@ func CreateWebhookPost(c *Context, channelId, text, overrideUsername, overrideIc
|
||||
|
||||
func handlePostEventsAndForget(c *Context, post *model.Post, triggerWebhooks bool) {
|
||||
go func() {
|
||||
tchan := Srv.Store.Team().Get(c.T, c.Session.TeamId)
|
||||
cchan := Srv.Store.Channel().Get(c.T, post.ChannelId)
|
||||
uchan := Srv.Store.User().Get(c.T, post.UserId)
|
||||
tchan := Srv.Store.Team().Get(c.Session.TeamId)
|
||||
cchan := Srv.Store.Channel().Get(post.ChannelId)
|
||||
uchan := Srv.Store.User().Get(post.UserId)
|
||||
|
||||
var team *model.Team
|
||||
if result := <-tchan; result.Err != nil {
|
||||
@@ -240,14 +238,14 @@ func handlePostEventsAndForget(c *Context, post *model.Post, triggerWebhooks boo
|
||||
}
|
||||
|
||||
if channel.Type == model.CHANNEL_DIRECT {
|
||||
go makeDirectChannelVisible(c.T, c.Session.TeamId, post.ChannelId)
|
||||
go makeDirectChannelVisible(c.Session.TeamId, post.ChannelId)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func makeDirectChannelVisible(T goi18n.TranslateFunc, teamId string, channelId string) {
|
||||
func makeDirectChannelVisible(teamId string, channelId string) {
|
||||
var members []model.ChannelMember
|
||||
if result := <-Srv.Store.Channel().GetMembers(T, channelId); result.Err != nil {
|
||||
if result := <-Srv.Store.Channel().GetMembers(channelId); result.Err != nil {
|
||||
l4g.Error("Failed to get channel members channel_id=%v err=%v", channelId, result.Err.Message)
|
||||
return
|
||||
} else {
|
||||
@@ -263,7 +261,7 @@ func makeDirectChannelVisible(T goi18n.TranslateFunc, teamId string, channelId s
|
||||
for i, member := range members {
|
||||
otherUserId := members[1-i].UserId
|
||||
|
||||
if result := <-Srv.Store.Preference().Get(T, member.UserId, model.PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW, otherUserId); result.Err != nil {
|
||||
if result := <-Srv.Store.Preference().Get(member.UserId, model.PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW, otherUserId); result.Err != nil {
|
||||
// create a new preference since one doesn't exist yet
|
||||
preference := &model.Preference{
|
||||
UserId: member.UserId,
|
||||
@@ -272,7 +270,7 @@ func makeDirectChannelVisible(T goi18n.TranslateFunc, teamId string, channelId s
|
||||
Value: "true",
|
||||
}
|
||||
|
||||
if saveResult := <-Srv.Store.Preference().Save(T, &model.Preferences{*preference}); saveResult.Err != nil {
|
||||
if saveResult := <-Srv.Store.Preference().Save(&model.Preferences{*preference}); saveResult.Err != nil {
|
||||
l4g.Error("Failed to save direct channel preference user_id=%v other_user_id=%v err=%v", member.UserId, otherUserId, saveResult.Err.Message)
|
||||
} else {
|
||||
message := model.NewMessage(teamId, channelId, member.UserId, model.ACTION_PREFERENCE_CHANGED)
|
||||
@@ -287,7 +285,7 @@ func makeDirectChannelVisible(T goi18n.TranslateFunc, teamId string, channelId s
|
||||
// update the existing preference to make the channel visible
|
||||
preference.Value = "true"
|
||||
|
||||
if updateResult := <-Srv.Store.Preference().Save(T, &model.Preferences{preference}); updateResult.Err != nil {
|
||||
if updateResult := <-Srv.Store.Preference().Save(&model.Preferences{preference}); updateResult.Err != nil {
|
||||
l4g.Error("Failed to update direct channel preference user_id=%v other_user_id=%v err=%v", member.UserId, otherUserId, updateResult.Err.Message)
|
||||
} else {
|
||||
message := model.NewMessage(teamId, channelId, member.UserId, model.ACTION_PREFERENCE_CHANGED)
|
||||
@@ -310,7 +308,7 @@ func handleWebhookEventsAndForget(c *Context, post *model.Post, team *model.Team
|
||||
return
|
||||
}
|
||||
|
||||
hchan := Srv.Store.Webhook().GetOutgoingByTeam(c.T, c.Session.TeamId)
|
||||
hchan := Srv.Store.Webhook().GetOutgoingByTeam(c.Session.TeamId)
|
||||
|
||||
hooks := []*model.OutgoingWebhook{}
|
||||
|
||||
@@ -394,8 +392,8 @@ func sendNotificationsAndForget(c *Context, post *model.Post, team *model.Team,
|
||||
|
||||
go func() {
|
||||
// Get a list of user names (to be used as keywords) and ids for the given team
|
||||
uchan := Srv.Store.User().GetProfiles(c.T, c.Session.TeamId)
|
||||
echan := Srv.Store.Channel().GetMembers(c.T, post.ChannelId)
|
||||
uchan := Srv.Store.User().GetProfiles(c.Session.TeamId)
|
||||
echan := Srv.Store.Channel().GetMembers(post.ChannelId)
|
||||
|
||||
var channelName string
|
||||
var bodyText string
|
||||
@@ -542,7 +540,7 @@ func sendNotificationsAndForget(c *Context, post *model.Post, team *model.Team,
|
||||
}
|
||||
|
||||
for id := range toEmailMap {
|
||||
updateMentionCountAndForget(c.T, post.ChannelId, id)
|
||||
updateMentionCountAndForget(post.ChannelId, id)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -626,7 +624,7 @@ func sendNotificationsAndForget(c *Context, post *model.Post, team *model.Team,
|
||||
}
|
||||
|
||||
if *utils.Cfg.EmailSettings.SendPushNotifications {
|
||||
sessionChan := Srv.Store.Session().GetSessions(c.T, id)
|
||||
sessionChan := Srv.Store.Session().GetSessions(id)
|
||||
if result := <-sessionChan; result.Err != nil {
|
||||
l4g.Error("Failed to retrieve sessions in notifications id=%v, err=%v", id, result.Err)
|
||||
} else {
|
||||
@@ -694,9 +692,9 @@ func sendNotificationsAndForget(c *Context, post *model.Post, team *model.Team,
|
||||
}()
|
||||
}
|
||||
|
||||
func updateMentionCountAndForget(T goi18n.TranslateFunc, channelId, userId string) {
|
||||
func updateMentionCountAndForget(channelId, userId string) {
|
||||
go func() {
|
||||
if result := <-Srv.Store.Channel().IncrementMentionCount(T, channelId, userId); result.Err != nil {
|
||||
if result := <-Srv.Store.Channel().IncrementMentionCount(channelId, userId); result.Err != nil {
|
||||
l4g.Error("Failed to update mention count for user_id=%v on channel_id=%v err=%v", userId, channelId, result.Err)
|
||||
}
|
||||
}()
|
||||
@@ -710,8 +708,8 @@ func updatePost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.T, c.Session.TeamId, post.ChannelId, c.Session.UserId)
|
||||
pchan := Srv.Store.Post().Get(c.T, post.Id)
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.Session.TeamId, post.ChannelId, c.Session.UserId)
|
||||
pchan := Srv.Store.Post().Get(post.Id)
|
||||
|
||||
if !c.HasPermissionsToChannel(cchan, "updatePost") {
|
||||
return
|
||||
@@ -745,7 +743,7 @@ func updatePost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
hashtags, _ := model.ParseHashtags(post.Message)
|
||||
|
||||
if result := <-Srv.Store.Post().Update(c.T, oldPost, post.Message, hashtags); result.Err != nil {
|
||||
if result := <-Srv.Store.Post().Update(oldPost, post.Message, hashtags); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -781,8 +779,8 @@ func getPosts(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.T, c.Session.TeamId, id, c.Session.UserId)
|
||||
etagChan := Srv.Store.Post().GetEtag(c.T, id)
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.Session.TeamId, id, c.Session.UserId)
|
||||
etagChan := Srv.Store.Post().GetEtag(id)
|
||||
|
||||
if !c.HasPermissionsToChannel(cchan, "getPosts") {
|
||||
return
|
||||
@@ -794,7 +792,7 @@ func getPosts(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
pchan := Srv.Store.Post().GetPosts(c.T, id, offset, limit)
|
||||
pchan := Srv.Store.Post().GetPosts(id, offset, limit)
|
||||
|
||||
if result := <-pchan; result.Err != nil {
|
||||
c.Err = result.Err
|
||||
@@ -823,8 +821,8 @@ func getPostsSince(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.T, c.Session.TeamId, id, c.Session.UserId)
|
||||
pchan := Srv.Store.Post().GetPostsSince(c.T, id, time)
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.Session.TeamId, id, c.Session.UserId)
|
||||
pchan := Srv.Store.Post().GetPostsSince(id, time)
|
||||
|
||||
if !c.HasPermissionsToChannel(cchan, "getPostsSince") {
|
||||
return
|
||||
@@ -856,8 +854,8 @@ func getPost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.T, c.Session.TeamId, channelId, c.Session.UserId)
|
||||
pchan := Srv.Store.Post().Get(c.T, postId)
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.Session.TeamId, channelId, c.Session.UserId)
|
||||
pchan := Srv.Store.Post().Get(postId)
|
||||
|
||||
if !c.HasPermissionsToChannel(cchan, "getPost") {
|
||||
return
|
||||
@@ -891,7 +889,7 @@ func getPostById(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Post().Get(c.T, postId); result.Err != nil {
|
||||
if result := <-Srv.Store.Post().Get(postId); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -903,7 +901,7 @@ func getPostById(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
post := list.Posts[list.Order[0]]
|
||||
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.T, c.Session.TeamId, post.ChannelId, c.Session.UserId)
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.Session.TeamId, post.ChannelId, c.Session.UserId)
|
||||
if !c.HasPermissionsToChannel(cchan, "getPostById") {
|
||||
return
|
||||
}
|
||||
@@ -932,8 +930,8 @@ func deletePost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.T, c.Session.TeamId, channelId, c.Session.UserId)
|
||||
pchan := Srv.Store.Post().Get(c.T, postId)
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.Session.TeamId, channelId, c.Session.UserId)
|
||||
pchan := Srv.Store.Post().Get(postId)
|
||||
|
||||
if result := <-pchan; result.Err != nil {
|
||||
c.Err = result.Err
|
||||
@@ -963,7 +961,7 @@ func deletePost(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if dresult := <-Srv.Store.Post().Delete(c.T, postId, model.GetMillis()); dresult.Err != nil {
|
||||
if dresult := <-Srv.Store.Post().Delete(postId, model.GetMillis()); dresult.Err != nil {
|
||||
c.Err = dresult.Err
|
||||
return
|
||||
}
|
||||
@@ -1012,9 +1010,9 @@ func getPostsBeforeOrAfter(c *Context, w http.ResponseWriter, r *http.Request, b
|
||||
return
|
||||
}
|
||||
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.T, c.Session.TeamId, id, c.Session.UserId)
|
||||
cchan := Srv.Store.Channel().CheckPermissionsTo(c.Session.TeamId, id, c.Session.UserId)
|
||||
// We can do better than this etag in this situation
|
||||
etagChan := Srv.Store.Post().GetEtag(c.T, id)
|
||||
etagChan := Srv.Store.Post().GetEtag(id)
|
||||
|
||||
if !c.HasPermissionsToChannel(cchan, "getPostsBeforeOrAfter") {
|
||||
return
|
||||
@@ -1027,9 +1025,9 @@ func getPostsBeforeOrAfter(c *Context, w http.ResponseWriter, r *http.Request, b
|
||||
|
||||
var pchan store.StoreChannel
|
||||
if before {
|
||||
pchan = Srv.Store.Post().GetPostsBefore(c.T, id, postId, numPosts, offset)
|
||||
pchan = Srv.Store.Post().GetPostsBefore(id, postId, numPosts, offset)
|
||||
} else {
|
||||
pchan = Srv.Store.Post().GetPostsAfter(c.T, id, postId, numPosts, offset)
|
||||
pchan = Srv.Store.Post().GetPostsAfter(id, postId, numPosts, offset)
|
||||
}
|
||||
|
||||
if result := <-pchan; result.Err != nil {
|
||||
@@ -1057,7 +1055,7 @@ func searchPosts(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
for _, params := range paramsList {
|
||||
// don't allow users to search for everything
|
||||
if params.Terms != "*" {
|
||||
channels = append(channels, Srv.Store.Post().Search(c.T, c.Session.TeamId, c.Session.UserId, params))
|
||||
channels = append(channels, Srv.Store.Post().Search(c.Session.TeamId, c.Session.UserId, params))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ func TestCreatePost(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -105,7 +105,7 @@ func TestCreatePost(t *testing.T) {
|
||||
|
||||
user3 := &model.User{TeamId: team2.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user3 = Client.Must(Client.CreateUser(user3, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user3.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user3.Id))
|
||||
|
||||
Client.LoginByEmail(team2.Name, user3.Email, "pwd")
|
||||
|
||||
@@ -134,11 +134,11 @@ func TestUpdatePost(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -202,7 +202,7 @@ func TestGetPosts(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -267,7 +267,7 @@ func TestGetPostsSince(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -337,7 +337,7 @@ func TestGetPostsBeforeAfter(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -414,7 +414,7 @@ func TestSearchPosts(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -464,7 +464,7 @@ func TestSearchHashtagPosts(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -495,7 +495,7 @@ func TestSearchPostsInChannel(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -577,7 +577,7 @@ func TestSearchPostsFromUser(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -592,7 +592,7 @@ func TestSearchPostsFromUser(t *testing.T) {
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user2.Email, "pwd")
|
||||
Client.Must(Client.JoinChannel(channel1.Id))
|
||||
@@ -621,7 +621,7 @@ func TestSearchPostsFromUser(t *testing.T) {
|
||||
|
||||
user3 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user3 = Client.Must(Client.CreateUser(user3, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user3.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user3.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user3.Email, "pwd")
|
||||
Client.Must(Client.JoinChannel(channel1.Id))
|
||||
@@ -655,7 +655,7 @@ func TestGetPostsCache(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -704,11 +704,11 @@ func TestDeletePosts(t *testing.T) {
|
||||
|
||||
userAdmin := &model.User{TeamId: team.Id, Email: team.Email, Nickname: "Corey Hulen", Password: "pwd"}
|
||||
userAdmin = Client.Must(Client.CreateUser(userAdmin, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, userAdmin.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(userAdmin.Id))
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -765,7 +765,7 @@ func TestEmailMention(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: "corey+test@test.com", Nickname: "Bob Bobby", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -787,7 +787,7 @@ func TestFuzzyPosts(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -814,11 +814,11 @@ func TestMakeDirectChannelVisible(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
// user2 will be created with prefs created to show user1 in the sidebar so set that to false to get rid of it
|
||||
Client.LoginByEmail(team.Name, user2.Email, "pwd")
|
||||
@@ -837,7 +837,7 @@ func TestMakeDirectChannelVisible(t *testing.T) {
|
||||
|
||||
channel := Client.Must(Client.CreateDirectChannel(map[string]string{"user_id": user2.Id})).Data.(*model.Channel)
|
||||
|
||||
makeDirectChannelVisible(utils.T, team.Id, channel.Id)
|
||||
makeDirectChannelVisible(team.Id, channel.Id)
|
||||
|
||||
if result, err := Client.GetPreference(model.PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW, user2.Id); err != nil {
|
||||
t.Fatal("Errored trying to set direct channel to be visible for user1")
|
||||
|
||||
@@ -21,7 +21,7 @@ func InitPreference(r *mux.Router) {
|
||||
}
|
||||
|
||||
func getAllPreferences(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if result := <-Srv.Store.Preference().GetAll(c.T, c.Session.UserId); result.Err != nil {
|
||||
if result := <-Srv.Store.Preference().GetAll(c.Session.UserId); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
} else {
|
||||
data := result.Data.(model.Preferences)
|
||||
@@ -46,7 +46,7 @@ func savePreferences(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Preference().Save(c.T, &preferences); result.Err != nil {
|
||||
if result := <-Srv.Store.Preference().Save(&preferences); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
}
|
||||
@@ -58,7 +58,7 @@ func getPreferenceCategory(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
params := mux.Vars(r)
|
||||
category := params["category"]
|
||||
|
||||
if result := <-Srv.Store.Preference().GetCategory(c.T, c.Session.UserId, category); result.Err != nil {
|
||||
if result := <-Srv.Store.Preference().GetCategory(c.Session.UserId, category); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
} else {
|
||||
data := result.Data.(model.Preferences)
|
||||
@@ -72,7 +72,7 @@ func getPreference(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
category := params["category"]
|
||||
name := params["name"]
|
||||
|
||||
if result := <-Srv.Store.Preference().Get(c.T, c.Session.UserId, category, name); result.Err != nil {
|
||||
if result := <-Srv.Store.Preference().Get(c.Session.UserId, category, name); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
} else {
|
||||
data := result.Data.(model.Preference)
|
||||
|
||||
@@ -6,7 +6,6 @@ package api
|
||||
import (
|
||||
"github.com/mattermost/platform/model"
|
||||
"github.com/mattermost/platform/store"
|
||||
"github.com/mattermost/platform/utils"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -18,11 +17,11 @@ func TestGetAllPreferences(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
category := model.NewId()
|
||||
|
||||
@@ -71,7 +70,7 @@ func TestSetPreferences(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -102,7 +101,7 @@ func TestSetPreferences(t *testing.T) {
|
||||
// not able to update as a different user
|
||||
user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user2.Email, "pwd")
|
||||
|
||||
@@ -119,11 +118,11 @@ func TestGetPreferenceCategory(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
category := model.NewId()
|
||||
|
||||
@@ -175,7 +174,7 @@ func TestGetPreference(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
|
||||
@@ -7,14 +7,12 @@ import (
|
||||
"archive/zip"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/mattermost/platform/model"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/mattermost/platform/model"
|
||||
goi18n "github.com/nicksnyder/go-i18n/i18n"
|
||||
)
|
||||
|
||||
type SlackChannel struct {
|
||||
@@ -91,7 +89,7 @@ func SlackParsePosts(data io.Reader) []SlackPost {
|
||||
return posts
|
||||
}
|
||||
|
||||
func SlackAddUsers(T goi18n.TranslateFunc, teamId string, slackusers []SlackUser, log *bytes.Buffer) map[string]*model.User {
|
||||
func SlackAddUsers(teamId string, slackusers []SlackUser, log *bytes.Buffer) map[string]*model.User {
|
||||
// Log header
|
||||
log.WriteString("\r\n Users Created\r\n")
|
||||
log.WriteString("===============\r\n\r\n")
|
||||
@@ -118,7 +116,7 @@ func SlackAddUsers(T goi18n.TranslateFunc, teamId string, slackusers []SlackUser
|
||||
Password: password,
|
||||
}
|
||||
|
||||
if mUser := ImportUser(T, &newUser); mUser != nil {
|
||||
if mUser := ImportUser(&newUser); mUser != nil {
|
||||
addedUsers[sUser.Id] = mUser
|
||||
log.WriteString("Email, Password: " + newUser.Email + ", " + password + "\r\n")
|
||||
} else {
|
||||
@@ -129,7 +127,7 @@ func SlackAddUsers(T goi18n.TranslateFunc, teamId string, slackusers []SlackUser
|
||||
return addedUsers
|
||||
}
|
||||
|
||||
func SlackAddPosts(T goi18n.TranslateFunc, channel *model.Channel, posts []SlackPost, users map[string]*model.User) {
|
||||
func SlackAddPosts(channel *model.Channel, posts []SlackPost, users map[string]*model.User) {
|
||||
for _, sPost := range posts {
|
||||
switch {
|
||||
case sPost.Type == "message" && (sPost.SubType == "" || sPost.SubType == "file_share"):
|
||||
@@ -146,7 +144,7 @@ func SlackAddPosts(T goi18n.TranslateFunc, channel *model.Channel, posts []Slack
|
||||
Message: sPost.Text,
|
||||
CreateAt: SlackConvertTimeStamp(sPost.TimeStamp),
|
||||
}
|
||||
ImportPost(T, &newPost)
|
||||
ImportPost(&newPost)
|
||||
case sPost.Type == "message" && sPost.SubType == "file_comment":
|
||||
if sPost.Comment["user"] == "" {
|
||||
l4g.Debug("Message without user")
|
||||
@@ -161,7 +159,7 @@ func SlackAddPosts(T goi18n.TranslateFunc, channel *model.Channel, posts []Slack
|
||||
Message: sPost.Comment["comment"],
|
||||
CreateAt: SlackConvertTimeStamp(sPost.TimeStamp),
|
||||
}
|
||||
ImportPost(T, &newPost)
|
||||
ImportPost(&newPost)
|
||||
case sPost.Type == "message" && sPost.SubType == "bot_message":
|
||||
// In the future this will use the "Action Post" spec to post
|
||||
// a message without using a username. For now we just warn that we don't handle this case
|
||||
@@ -172,7 +170,7 @@ func SlackAddPosts(T goi18n.TranslateFunc, channel *model.Channel, posts []Slack
|
||||
}
|
||||
}
|
||||
|
||||
func SlackAddChannels(T goi18n.TranslateFunc, teamId string, slackchannels []SlackChannel, posts map[string][]SlackPost, users map[string]*model.User, log *bytes.Buffer) map[string]*model.Channel {
|
||||
func SlackAddChannels(teamId string, slackchannels []SlackChannel, posts map[string][]SlackPost, users map[string]*model.User, log *bytes.Buffer) map[string]*model.Channel {
|
||||
// Write Header
|
||||
log.WriteString("\r\n Channels Added \r\n")
|
||||
log.WriteString("=================\r\n\r\n")
|
||||
@@ -186,10 +184,10 @@ func SlackAddChannels(T goi18n.TranslateFunc, teamId string, slackchannels []Sla
|
||||
Name: SlackConvertChannelName(sChannel.Name),
|
||||
Purpose: sChannel.Topic["value"],
|
||||
}
|
||||
mChannel := ImportChannel(T, &newChannel)
|
||||
mChannel := ImportChannel(&newChannel)
|
||||
if mChannel == nil {
|
||||
// Maybe it already exists?
|
||||
if result := <-Srv.Store.Channel().GetByName(T, teamId, sChannel.Name); result.Err != nil {
|
||||
if result := <-Srv.Store.Channel().GetByName(teamId, sChannel.Name); result.Err != nil {
|
||||
l4g.Debug("Failed to import: %s", newChannel.DisplayName)
|
||||
log.WriteString("Failed to import: " + newChannel.DisplayName + "\r\n")
|
||||
continue
|
||||
@@ -200,13 +198,13 @@ func SlackAddChannels(T goi18n.TranslateFunc, teamId string, slackchannels []Sla
|
||||
}
|
||||
log.WriteString(newChannel.DisplayName + "\r\n")
|
||||
addedChannels[sChannel.Id] = mChannel
|
||||
SlackAddPosts(T, mChannel, posts[sChannel.Name], users)
|
||||
SlackAddPosts(mChannel, posts[sChannel.Name], users)
|
||||
}
|
||||
|
||||
return addedChannels
|
||||
}
|
||||
|
||||
func SlackImport(T goi18n.TranslateFunc, fileData multipart.File, fileSize int64, teamID string) (*model.AppError, *bytes.Buffer) {
|
||||
func SlackImport(fileData multipart.File, fileSize int64, teamID string) (*model.AppError, *bytes.Buffer) {
|
||||
zipreader, err := zip.NewReader(fileData, fileSize)
|
||||
if err != nil || zipreader.File == nil {
|
||||
return model.NewAppError("SlackImport", "Unable to open zip file", err.Error()), nil
|
||||
@@ -242,8 +240,8 @@ func SlackImport(T goi18n.TranslateFunc, fileData multipart.File, fileSize int64
|
||||
}
|
||||
}
|
||||
|
||||
addedUsers := SlackAddUsers(T, teamID, users, log)
|
||||
SlackAddChannels(T, teamID, channels, posts, addedUsers, log)
|
||||
addedUsers := SlackAddUsers(teamID, users, log)
|
||||
SlackAddChannels(teamID, channels, posts, addedUsers, log)
|
||||
|
||||
log.WriteString("\r\n Notes \r\n")
|
||||
log.WriteString("=======\r\n\r\n")
|
||||
|
||||
57
api/team.go
57
api/team.go
@@ -6,17 +6,16 @@ package api
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/mattermost/platform/model"
|
||||
"github.com/mattermost/platform/store"
|
||||
"github.com/mattermost/platform/utils"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func InitTeam(r *mux.Router) {
|
||||
@@ -128,7 +127,7 @@ func createTeamFromSSO(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Team().Save(c.T, team); result.Err != nil {
|
||||
if result := <-Srv.Store.Team().Save(team); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -209,7 +208,7 @@ func createTeamFromSignup(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Team().Save(c.T, &teamSignup.Team); result.Err != nil {
|
||||
if result := <-Srv.Store.Team().Save(&teamSignup.Team); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -223,7 +222,7 @@ func createTeamFromSignup(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
teamSignup.User.TeamId = rteam.Id
|
||||
teamSignup.User.EmailVerified = true
|
||||
|
||||
ruser, err := CreateUser(c.T, rteam, &teamSignup.User)
|
||||
ruser, err := CreateUser(rteam, &teamSignup.User)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
@@ -264,7 +263,7 @@ func CreateTeam(c *Context, team *model.Team) *model.Team {
|
||||
return nil
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Team().Save(c.T, team); result.Err != nil {
|
||||
if result := <-Srv.Store.Team().Save(team); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return nil
|
||||
} else {
|
||||
@@ -313,7 +312,7 @@ func getAll(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Team().GetAll(c.T); result.Err != nil {
|
||||
if result := <-Srv.Store.Team().GetAll(); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -331,7 +330,7 @@ func revokeAllSessions(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
props := model.MapFromJson(r.Body)
|
||||
id := props["id"]
|
||||
|
||||
if result := <-Srv.Store.Session().Get(c.T, id); result.Err != nil {
|
||||
if result := <-Srv.Store.Session().Get(id); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -340,11 +339,11 @@ func revokeAllSessions(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
c.LogAudit("revoked_all=" + id)
|
||||
|
||||
if session.IsOAuth {
|
||||
RevokeAccessToken(c.T, session.Token)
|
||||
RevokeAccessToken(session.Token)
|
||||
} else {
|
||||
sessionCache.Remove(session.Token)
|
||||
|
||||
if result := <-Srv.Store.Session().Remove(c.T, session.Id); result.Err != nil {
|
||||
if result := <-Srv.Store.Session().Remove(session.Id); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -382,7 +381,7 @@ func FindTeamByName(c *Context, name string, all string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Team().GetByName(c.T, name); result.Err != nil {
|
||||
if result := <-Srv.Store.Team().GetByName(name); result.Err != nil {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
@@ -402,7 +401,7 @@ func findTeams(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Team().GetTeamsForEmail(c.T, email); result.Err != nil {
|
||||
if result := <-Srv.Store.Team().GetTeamsForEmail(email); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -433,7 +432,7 @@ func emailTeams(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
bodyPage := NewServerTemplatePage("find_teams_body")
|
||||
bodyPage.ClientCfg["SiteURL"] = c.GetSiteURL()
|
||||
|
||||
if result := <-Srv.Store.Team().GetTeamsForEmail(c.T, email); result.Err != nil {
|
||||
if result := <-Srv.Store.Team().GetTeamsForEmail(email); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
} else {
|
||||
teams := result.Data.([]*model.Team)
|
||||
@@ -461,8 +460,8 @@ func inviteMembers(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
tchan := Srv.Store.Team().Get(c.T, c.Session.TeamId)
|
||||
uchan := Srv.Store.User().Get(c.T, c.Session.UserId)
|
||||
tchan := Srv.Store.Team().Get(c.Session.TeamId)
|
||||
uchan := Srv.Store.User().Get(c.Session.UserId)
|
||||
|
||||
var team *model.Team
|
||||
if result := <-tchan; result.Err != nil {
|
||||
@@ -482,7 +481,7 @@ func inviteMembers(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var invNum int64 = 0
|
||||
for i, invite := range invites.Invites {
|
||||
if result := <-Srv.Store.User().GetByEmail(c.T, c.Session.TeamId, invite["email"]); result.Err == nil || result.Err.Message != store.MISSING_ACCOUNT_ERROR {
|
||||
if result := <-Srv.Store.User().GetByEmail(c.Session.TeamId, invite["email"]); result.Err == nil || result.Err.Message != store.MISSING_ACCOUNT_ERROR {
|
||||
invNum = int64(i)
|
||||
c.Err = model.NewAppError("invite_members", "This person is already on your team", strconv.FormatInt(invNum, 10))
|
||||
return
|
||||
@@ -561,7 +560,7 @@ func updateTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
var oldTeam *model.Team
|
||||
if result := <-Srv.Store.Team().Get(c.T, team.Id); result.Err != nil {
|
||||
if result := <-Srv.Store.Team().Get(team.Id); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -576,7 +575,7 @@ func updateTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
oldTeam.AllowedDomains = team.AllowedDomains
|
||||
//oldTeam.Type = team.Type
|
||||
|
||||
if result := <-Srv.Store.Team().Update(c.T, oldTeam); result.Err != nil {
|
||||
if result := <-Srv.Store.Team().Update(oldTeam); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
}
|
||||
@@ -592,11 +591,11 @@ func PermanentDeleteTeam(c *Context, team *model.Team) *model.AppError {
|
||||
c.LogAuditWithUserId("", fmt.Sprintf("attempt teamId=%v", team.Id))
|
||||
|
||||
team.DeleteAt = model.GetMillis()
|
||||
if result := <-Srv.Store.Team().Update(c.T, team); result.Err != nil {
|
||||
if result := <-Srv.Store.Team().Update(team); result.Err != nil {
|
||||
return result.Err
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.User().GetForExport(c.T, team.Id); result.Err != nil {
|
||||
if result := <-Srv.Store.User().GetForExport(team.Id); result.Err != nil {
|
||||
return result.Err
|
||||
} else {
|
||||
users := result.Data.([]*model.User)
|
||||
@@ -605,11 +604,11 @@ func PermanentDeleteTeam(c *Context, team *model.Team) *model.AppError {
|
||||
}
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Channel().PermanentDeleteByTeam(c.T, team.Id); result.Err != nil {
|
||||
if result := <-Srv.Store.Channel().PermanentDeleteByTeam(team.Id); result.Err != nil {
|
||||
return result.Err
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Team().PermanentDelete(c.T, team.Id); result.Err != nil {
|
||||
if result := <-Srv.Store.Team().PermanentDelete(team.Id); result.Err != nil {
|
||||
return result.Err
|
||||
}
|
||||
|
||||
@@ -625,7 +624,7 @@ func getMyTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Team().Get(c.T, c.Session.TeamId); result.Err != nil {
|
||||
if result := <-Srv.Store.Team().Get(c.Session.TeamId); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else if HandleEtag(result.Data.(*model.Team).Etag(), w, r) {
|
||||
@@ -694,7 +693,7 @@ func importTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
switch importFrom {
|
||||
case "slack":
|
||||
var err *model.AppError
|
||||
if err, log = SlackImport(c.T, fileData, fileSize, c.Session.TeamId); err != nil {
|
||||
if err, log = SlackImport(fileData, fileSize, c.Session.TeamId); err != nil {
|
||||
c.Err = err
|
||||
c.Err.StatusCode = http.StatusBadRequest
|
||||
}
|
||||
@@ -714,7 +713,7 @@ func exportTeam(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
options := ExportOptionsFromJson(r.Body)
|
||||
|
||||
if link, err := ExportToFile(c.T, options); err != nil {
|
||||
if link, err := ExportToFile(options); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
} else {
|
||||
|
||||
@@ -79,7 +79,7 @@ func TestCreateTeam(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: rteam.Data.(*model.Team).Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -116,7 +116,7 @@ func TestFindTeamByEmail(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
if r1, err := Client.FindTeams(user.Email); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -143,7 +143,7 @@ func TestGetAllTeams(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -176,7 +176,7 @@ func TestTeamPermDelete(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -219,7 +219,7 @@ func TestFindTeamByDomain(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
if r1, err := Client.FindTeamByDomain(team.Name, false); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -259,7 +259,7 @@ func TestFindTeamByEmailSend(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
if _, err := Client.FindTeamsSendEmail(user.Email); err != nil {
|
||||
@@ -284,7 +284,7 @@ func TestInviteMembers(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -313,11 +313,11 @@ func TestUpdateTeamDisplayName(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: "test@nowhere.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user2.Email, "pwd")
|
||||
|
||||
@@ -370,7 +370,7 @@ func TestGetMyTeam(t *testing.T) {
|
||||
|
||||
user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
ruser, _ := Client.CreateUser(&user, "")
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, ruser.Data.(*model.User).Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(ruser.Data.(*model.User).Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, user.Password)
|
||||
|
||||
|
||||
192
api/user.go
192
api/user.go
@@ -7,6 +7,15 @@ import (
|
||||
"bytes"
|
||||
b64 "encoding/base64"
|
||||
"fmt"
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/disintegration/imaging"
|
||||
"github.com/golang/freetype"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/mattermost/platform/einterfaces"
|
||||
"github.com/mattermost/platform/model"
|
||||
"github.com/mattermost/platform/store"
|
||||
"github.com/mattermost/platform/utils"
|
||||
"github.com/mssola/user_agent"
|
||||
"hash/fnv"
|
||||
"image"
|
||||
"image/color"
|
||||
@@ -20,17 +29,6 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
"github.com/disintegration/imaging"
|
||||
"github.com/golang/freetype"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/mattermost/platform/einterfaces"
|
||||
"github.com/mattermost/platform/model"
|
||||
"github.com/mattermost/platform/store"
|
||||
"github.com/mattermost/platform/utils"
|
||||
"github.com/mssola/user_agent"
|
||||
goi18n "github.com/nicksnyder/go-i18n/i18n"
|
||||
)
|
||||
|
||||
func InitUser(r *mux.Router) {
|
||||
@@ -84,7 +82,7 @@ func createUser(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var team *model.Team
|
||||
|
||||
if result := <-Srv.Store.Team().Get(c.T, user.TeamId); result.Err != nil {
|
||||
if result := <-Srv.Store.Team().Get(user.TeamId); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -129,14 +127,14 @@ func createUser(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
ruser, err := CreateUser(c.T, team, user)
|
||||
ruser, err := CreateUser(team, user)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
|
||||
if sendWelcomeEmail {
|
||||
sendWelcomeEmailAndForget(c.T, ruser.Id, ruser.Email, team.Name, team.DisplayName, c.GetSiteURL(), c.GetTeamURLFromTeam(team), ruser.EmailVerified)
|
||||
sendWelcomeEmailAndForget(ruser.Id, ruser.Email, team.Name, team.DisplayName, c.GetSiteURL(), c.GetTeamURLFromTeam(team), ruser.EmailVerified)
|
||||
}
|
||||
|
||||
w.Write([]byte(ruser.ToJson()))
|
||||
@@ -185,7 +183,7 @@ func IsVerifyHashRequired(user *model.User, team *model.Team, hash string) bool
|
||||
return shouldVerifyHash
|
||||
}
|
||||
|
||||
func CreateUser(T goi18n.TranslateFunc, team *model.Team, user *model.User) (*model.User, *model.AppError) {
|
||||
func CreateUser(team *model.Team, user *model.User) (*model.User, *model.AppError) {
|
||||
|
||||
channelRole := ""
|
||||
if team.Email == user.Email {
|
||||
@@ -194,7 +192,7 @@ func CreateUser(T goi18n.TranslateFunc, team *model.Team, user *model.User) (*mo
|
||||
|
||||
// Below is a speical case where the first user in the entire
|
||||
// system is granted the system_admin role instead of admin
|
||||
if result := <-Srv.Store.User().GetTotalUsersCount(T); result.Err != nil {
|
||||
if result := <-Srv.Store.User().GetTotalUsersCount(); result.Err != nil {
|
||||
return nil, result.Err
|
||||
} else {
|
||||
count := result.Data.(int64)
|
||||
@@ -209,27 +207,27 @@ func CreateUser(T goi18n.TranslateFunc, team *model.Team, user *model.User) (*mo
|
||||
|
||||
user.MakeNonNil()
|
||||
|
||||
if result := <-Srv.Store.User().Save(T, user); result.Err != nil {
|
||||
if result := <-Srv.Store.User().Save(user); result.Err != nil {
|
||||
l4g.Error("Couldn't save the user err=%v", result.Err)
|
||||
return nil, result.Err
|
||||
} else {
|
||||
ruser := result.Data.(*model.User)
|
||||
|
||||
// Soft error if there is an issue joining the default channels
|
||||
if err := JoinDefaultChannels(T, ruser, channelRole); err != nil {
|
||||
if err := JoinDefaultChannels(ruser, channelRole); err != nil {
|
||||
l4g.Error("Encountered an issue joining default channels user_id=%s, team_id=%s, err=%v", ruser.Id, ruser.TeamId, err)
|
||||
}
|
||||
|
||||
addDirectChannelsAndForget(T, ruser)
|
||||
addDirectChannelsAndForget(ruser)
|
||||
|
||||
if user.EmailVerified {
|
||||
if cresult := <-Srv.Store.User().VerifyEmail(T, ruser.Id); cresult.Err != nil {
|
||||
if cresult := <-Srv.Store.User().VerifyEmail(ruser.Id); cresult.Err != nil {
|
||||
l4g.Error("Failed to set email verified err=%v", cresult.Err)
|
||||
}
|
||||
}
|
||||
|
||||
pref := model.Preference{UserId: ruser.Id, Category: model.PREFERENCE_CATEGORY_TUTORIAL_STEPS, Name: ruser.Id, Value: "0"}
|
||||
if presult := <-Srv.Store.Preference().Save(T, &model.Preferences{pref}); presult.Err != nil {
|
||||
if presult := <-Srv.Store.Preference().Save(&model.Preferences{pref}); presult.Err != nil {
|
||||
l4g.Error("Encountered error saving tutorial preference, err=%v", presult.Err.Message)
|
||||
}
|
||||
|
||||
@@ -259,12 +257,12 @@ func CreateOAuthUser(c *Context, w http.ResponseWriter, r *http.Request, service
|
||||
return nil
|
||||
}
|
||||
|
||||
suchan := Srv.Store.User().GetByAuth(c.T, team.Id, user.AuthData, service)
|
||||
euchan := Srv.Store.User().GetByEmail(c.T, team.Id, user.Email)
|
||||
suchan := Srv.Store.User().GetByAuth(team.Id, user.AuthData, service)
|
||||
euchan := Srv.Store.User().GetByEmail(team.Id, user.Email)
|
||||
|
||||
if team.Email == "" {
|
||||
team.Email = user.Email
|
||||
if result := <-Srv.Store.Team().Update(c.T, team); result.Err != nil {
|
||||
if result := <-Srv.Store.Team().Update(team); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return nil
|
||||
}
|
||||
@@ -272,7 +270,7 @@ func CreateOAuthUser(c *Context, w http.ResponseWriter, r *http.Request, service
|
||||
found := true
|
||||
count := 0
|
||||
for found {
|
||||
if found = IsUsernameTaken(c.T, user.Username, team.Id); c.Err != nil {
|
||||
if found = IsUsernameTaken(user.Username, team.Id); c.Err != nil {
|
||||
return nil
|
||||
} else if found {
|
||||
user.Username = user.Username + strconv.Itoa(count)
|
||||
@@ -294,7 +292,7 @@ func CreateOAuthUser(c *Context, w http.ResponseWriter, r *http.Request, service
|
||||
user.TeamId = team.Id
|
||||
user.EmailVerified = true
|
||||
|
||||
ruser, err := CreateUser(c.T, team, user)
|
||||
ruser, err := CreateUser(team, user)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return nil
|
||||
@@ -308,7 +306,7 @@ func CreateOAuthUser(c *Context, w http.ResponseWriter, r *http.Request, service
|
||||
return ruser
|
||||
}
|
||||
|
||||
func sendWelcomeEmailAndForget(T goi18n.TranslateFunc, userId, email, teamName, teamDisplayName, siteURL, teamURL string, verified bool) {
|
||||
func sendWelcomeEmailAndForget(userId, email, teamName, teamDisplayName, siteURL, teamURL string, verified bool) {
|
||||
go func() {
|
||||
|
||||
subjectPage := NewServerTemplatePage("welcome_subject")
|
||||
@@ -328,10 +326,10 @@ func sendWelcomeEmailAndForget(T goi18n.TranslateFunc, userId, email, teamName,
|
||||
}()
|
||||
}
|
||||
|
||||
func addDirectChannelsAndForget(T goi18n.TranslateFunc, user *model.User) {
|
||||
func addDirectChannelsAndForget(user *model.User) {
|
||||
go func() {
|
||||
var profiles map[string]*model.User
|
||||
if result := <-Srv.Store.User().GetProfiles(T, user.TeamId); result.Err != nil {
|
||||
if result := <-Srv.Store.User().GetProfiles(user.TeamId); result.Err != nil {
|
||||
l4g.Error("Failed to add direct channel preferences for user user_id=%s, team_id=%s, err=%v", user.Id, user.TeamId, result.Err.Error())
|
||||
return
|
||||
} else {
|
||||
@@ -361,7 +359,7 @@ func addDirectChannelsAndForget(T goi18n.TranslateFunc, user *model.User) {
|
||||
}
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Preference().Save(T, &preferences); result.Err != nil {
|
||||
if result := <-Srv.Store.Preference().Save(&preferences); result.Err != nil {
|
||||
l4g.Error("Failed to add direct channel preferences for new user user_id=%s, eam_id=%s, err=%v", user.Id, user.TeamId, result.Err.Error())
|
||||
}
|
||||
}()
|
||||
@@ -387,7 +385,7 @@ func SendVerifyEmailAndForget(userId, userEmail, teamName, teamDisplayName, site
|
||||
}
|
||||
|
||||
func LoginById(c *Context, w http.ResponseWriter, r *http.Request, userId, password, deviceId string) *model.User {
|
||||
if result := <-Srv.Store.User().Get(c.T, userId); result.Err != nil {
|
||||
if result := <-Srv.Store.User().Get(userId); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return nil
|
||||
} else {
|
||||
@@ -404,14 +402,14 @@ func LoginById(c *Context, w http.ResponseWriter, r *http.Request, userId, passw
|
||||
func LoginByEmail(c *Context, w http.ResponseWriter, r *http.Request, email, name, password, deviceId string) *model.User {
|
||||
var team *model.Team
|
||||
|
||||
if result := <-Srv.Store.Team().GetByName(c.T, name); result.Err != nil {
|
||||
if result := <-Srv.Store.Team().GetByName(name); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return nil
|
||||
} else {
|
||||
team = result.Data.(*model.Team)
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.User().GetByEmail(c.T, team.Id, email); result.Err != nil {
|
||||
if result := <-Srv.Store.User().GetByEmail(team.Id, email); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
c.Err.StatusCode = http.StatusForbidden
|
||||
return nil
|
||||
@@ -448,7 +446,7 @@ func LoginByOAuth(c *Context, w http.ResponseWriter, r *http.Request, service st
|
||||
}
|
||||
|
||||
var user *model.User
|
||||
if result := <-Srv.Store.User().GetByAuth(c.T, team.Id, authData, service); result.Err != nil {
|
||||
if result := <-Srv.Store.User().GetByAuth(team.Id, authData, service); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return nil
|
||||
} else {
|
||||
@@ -476,13 +474,13 @@ func checkUserPassword(c *Context, user *model.User, password string) bool {
|
||||
c.Err = model.NewAppError("checkUserPassword", "Login failed because of invalid password", "user_id="+user.Id)
|
||||
c.Err.StatusCode = http.StatusForbidden
|
||||
|
||||
if result := <-Srv.Store.User().UpdateFailedPasswordAttempts(c.T, user.Id, user.FailedAttempts+1); result.Err != nil {
|
||||
if result := <-Srv.Store.User().UpdateFailedPasswordAttempts(user.Id, user.FailedAttempts+1); result.Err != nil {
|
||||
c.LogError(result.Err)
|
||||
}
|
||||
|
||||
return false
|
||||
} else {
|
||||
if result := <-Srv.Store.User().UpdateFailedPasswordAttempts(c.T, user.Id, 0); result.Err != nil {
|
||||
if result := <-Srv.Store.User().UpdateFailedPasswordAttempts(user.Id, 0); result.Err != nil {
|
||||
c.LogError(result.Err)
|
||||
}
|
||||
|
||||
@@ -516,7 +514,7 @@ func Login(c *Context, w http.ResponseWriter, r *http.Request, user *model.User,
|
||||
maxAge = *utils.Cfg.ServiceSettings.SessionLengthMobileInDays * 60 * 60 * 24
|
||||
|
||||
// A special case where we logout of all other sessions with the same Id
|
||||
if result := <-Srv.Store.Session().GetSessions(c.T, user.Id); result.Err != nil {
|
||||
if result := <-Srv.Store.Session().GetSessions(user.Id); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
c.Err.StatusCode = http.StatusForbidden
|
||||
return
|
||||
@@ -563,7 +561,7 @@ func Login(c *Context, w http.ResponseWriter, r *http.Request, user *model.User,
|
||||
session.AddProp(model.SESSION_PROP_OS, os)
|
||||
session.AddProp(model.SESSION_PROP_BROWSER, fmt.Sprintf("%v/%v", bname, bversion))
|
||||
|
||||
if result := <-Srv.Store.Session().Save(c.T, session); result.Err != nil {
|
||||
if result := <-Srv.Store.Session().Save(session); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
c.Err.StatusCode = http.StatusForbidden
|
||||
return
|
||||
@@ -579,7 +577,7 @@ func Login(c *Context, w http.ResponseWriter, r *http.Request, user *model.User,
|
||||
seen := make(map[string]string)
|
||||
seen[session.TeamId] = session.TeamId
|
||||
for _, token := range tokens {
|
||||
s := GetSession(c.T, token)
|
||||
s := GetSession(token)
|
||||
if s != nil && !s.IsExpired() && seen[s.TeamId] == "" {
|
||||
multiToken += " " + token
|
||||
seen[s.TeamId] = s.TeamId
|
||||
@@ -659,7 +657,7 @@ func loginLdap(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
teamc := Srv.Store.Team().GetByName(c.T, teamName)
|
||||
teamc := Srv.Store.Team().GetByName(teamName)
|
||||
|
||||
ldapInterface := einterfaces.GetLdapInterface()
|
||||
if ldapInterface == nil {
|
||||
@@ -706,18 +704,18 @@ func revokeSession(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func RevokeSessionById(c *Context, sessionId string) {
|
||||
if result := <-Srv.Store.Session().Get(c.T, sessionId); result.Err != nil {
|
||||
if result := <-Srv.Store.Session().Get(sessionId); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
} else {
|
||||
session := result.Data.(*model.Session)
|
||||
c.LogAudit("session_id=" + session.Id)
|
||||
|
||||
if session.IsOAuth {
|
||||
RevokeAccessToken(c.T, session.Token)
|
||||
RevokeAccessToken(session.Token)
|
||||
} else {
|
||||
sessionCache.Remove(session.Token)
|
||||
|
||||
if result := <-Srv.Store.Session().Remove(c.T, session.Id); result.Err != nil {
|
||||
if result := <-Srv.Store.Session().Remove(session.Id); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
}
|
||||
}
|
||||
@@ -725,7 +723,7 @@ func RevokeSessionById(c *Context, sessionId string) {
|
||||
}
|
||||
|
||||
func RevokeAllSession(c *Context, userId string) {
|
||||
if result := <-Srv.Store.Session().GetSessions(c.T, userId); result.Err != nil {
|
||||
if result := <-Srv.Store.Session().GetSessions(userId); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -734,10 +732,10 @@ func RevokeAllSession(c *Context, userId string) {
|
||||
for _, session := range sessions {
|
||||
c.LogAuditWithUserId(userId, "session_id="+session.Id)
|
||||
if session.IsOAuth {
|
||||
RevokeAccessToken(c.T, session.Token)
|
||||
RevokeAccessToken(session.Token)
|
||||
} else {
|
||||
sessionCache.Remove(session.Token)
|
||||
if result := <-Srv.Store.Session().Remove(c.T, session.Id); result.Err != nil {
|
||||
if result := <-Srv.Store.Session().Remove(session.Id); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
}
|
||||
@@ -755,7 +753,7 @@ func getSessions(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Session().GetSessions(c.T, id); result.Err != nil {
|
||||
if result := <-Srv.Store.Session().GetSessions(id); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -781,7 +779,7 @@ func logout(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
func Logout(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
c.LogAudit("")
|
||||
c.RemoveSessionCookie(w, r)
|
||||
if result := <-Srv.Store.Session().Remove(c.T, c.Session.Id); result.Err != nil {
|
||||
if result := <-Srv.Store.Session().Remove(c.Session.Id); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
}
|
||||
@@ -793,7 +791,7 @@ func getMe(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.User().Get(c.T, c.Session.UserId); result.Err != nil {
|
||||
if result := <-Srv.Store.User().Get(c.Session.UserId); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
c.RemoveSessionCookie(w, r)
|
||||
l4g.Error("Error in getting users profile for id=%v forcing logout", c.Session.UserId)
|
||||
@@ -817,7 +815,7 @@ func getUser(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.User().Get(c.T, id); result.Err != nil {
|
||||
if result := <-Srv.Store.User().Get(id); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else if HandleEtag(result.Data.(*model.User).Etag(), w, r) {
|
||||
@@ -845,12 +843,12 @@ func getProfiles(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
id = c.Session.TeamId
|
||||
}
|
||||
|
||||
etag := (<-Srv.Store.User().GetEtagForProfiles(c.T, id)).Data.(string)
|
||||
etag := (<-Srv.Store.User().GetEtagForProfiles(id)).Data.(string)
|
||||
if HandleEtag(etag, w, r) {
|
||||
return
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.User().GetProfiles(c.T, id); result.Err != nil {
|
||||
if result := <-Srv.Store.User().GetProfiles(id); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -884,8 +882,8 @@ func getAudits(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
userChan := Srv.Store.User().Get(c.T, id)
|
||||
auditChan := Srv.Store.Audit().Get(c.T, id, 20)
|
||||
userChan := Srv.Store.User().Get(id)
|
||||
auditChan := Srv.Store.Audit().Get(id, 20)
|
||||
|
||||
if c.Err = (<-userChan).Err; c.Err != nil {
|
||||
return
|
||||
@@ -990,7 +988,7 @@ func getProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
params := mux.Vars(r)
|
||||
id := params["id"]
|
||||
|
||||
if result := <-Srv.Store.User().Get(c.T, id); result.Err != nil {
|
||||
if result := <-Srv.Store.User().Get(id); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -1105,7 +1103,7 @@ func uploadProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
Srv.Store.User().UpdateLastPictureUpdate(c.T, c.Session.UserId)
|
||||
Srv.Store.User().UpdateLastPictureUpdate(c.Session.UserId)
|
||||
|
||||
c.LogAudit("")
|
||||
|
||||
@@ -1125,7 +1123,7 @@ func updateUser(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.User().Update(c.T, user, false); result.Err != nil {
|
||||
if result := <-Srv.Store.User().Update(user, false); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -1134,7 +1132,7 @@ func updateUser(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
rusers := result.Data.([2]*model.User)
|
||||
|
||||
if rusers[0].Email != rusers[1].Email {
|
||||
if tresult := <-Srv.Store.Team().Get(c.T, rusers[1].TeamId); tresult.Err != nil {
|
||||
if tresult := <-Srv.Store.Team().Get(rusers[1].TeamId); tresult.Err != nil {
|
||||
l4g.Error(tresult.Err.Message)
|
||||
} else {
|
||||
team := tresult.Data.(*model.Team)
|
||||
@@ -1182,7 +1180,7 @@ func updatePassword(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var result store.StoreResult
|
||||
|
||||
if result = <-Srv.Store.User().Get(c.T, userId); result.Err != nil {
|
||||
if result = <-Srv.Store.User().Get(userId); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
}
|
||||
@@ -1195,7 +1193,7 @@ func updatePassword(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
user := result.Data.(*model.User)
|
||||
|
||||
tchan := Srv.Store.Team().Get(c.T, user.TeamId)
|
||||
tchan := Srv.Store.Team().Get(user.TeamId)
|
||||
|
||||
if user.AuthData != "" {
|
||||
c.LogAudit("failed - tried to update user password who was logged in through oauth")
|
||||
@@ -1210,7 +1208,7 @@ func updatePassword(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if uresult := <-Srv.Store.User().UpdatePassword(c.T, c.Session.UserId, model.HashPassword(newPassword)); uresult.Err != nil {
|
||||
if uresult := <-Srv.Store.User().UpdatePassword(c.Session.UserId, model.HashPassword(newPassword)); uresult.Err != nil {
|
||||
c.Err = model.NewAppError("updatePassword", "Update password failed", uresult.Err.Error())
|
||||
c.Err.StatusCode = http.StatusForbidden
|
||||
return
|
||||
@@ -1252,7 +1250,7 @@ func updateRoles(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
var user *model.User
|
||||
if result := <-Srv.Store.User().Get(c.T, user_id); result.Err != nil {
|
||||
if result := <-Srv.Store.User().Get(user_id); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -1280,8 +1278,8 @@ func updateRoles(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
uchan := Srv.Store.Session().UpdateRoles(c.T, user.Id, new_roles)
|
||||
gchan := Srv.Store.Session().GetSessions(c.T, user.Id)
|
||||
uchan := Srv.Store.Session().UpdateRoles(user.Id, new_roles)
|
||||
gchan := Srv.Store.Session().GetSessions(user.Id)
|
||||
|
||||
if result := <-uchan; result.Err != nil {
|
||||
// soft error since the user roles were still updated
|
||||
@@ -1309,7 +1307,7 @@ func UpdateRoles(c *Context, user *model.User, roles string) *model.User {
|
||||
|
||||
if !model.IsInRole(roles, model.ROLE_SYSTEM_ADMIN) {
|
||||
if model.IsInRole(user.Roles, model.ROLE_TEAM_ADMIN) && !model.IsInRole(roles, model.ROLE_TEAM_ADMIN) {
|
||||
if result := <-Srv.Store.User().GetProfiles(c.T, user.TeamId); result.Err != nil {
|
||||
if result := <-Srv.Store.User().GetProfiles(user.TeamId); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return nil
|
||||
} else {
|
||||
@@ -1332,7 +1330,7 @@ func UpdateRoles(c *Context, user *model.User, roles string) *model.User {
|
||||
user.Roles = roles
|
||||
|
||||
var ruser *model.User
|
||||
if result := <-Srv.Store.User().Update(c.T, user, true); result.Err != nil {
|
||||
if result := <-Srv.Store.User().Update(user, true); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return nil
|
||||
} else {
|
||||
@@ -1355,7 +1353,7 @@ func updateActive(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
active := props["active"] == "true"
|
||||
|
||||
var user *model.User
|
||||
if result := <-Srv.Store.User().Get(c.T, user_id); result.Err != nil {
|
||||
if result := <-Srv.Store.User().Get(user_id); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -1374,7 +1372,7 @@ func updateActive(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// make sure there is at least 1 other active admin
|
||||
if !active && model.IsInRole(user.Roles, model.ROLE_TEAM_ADMIN) {
|
||||
if result := <-Srv.Store.User().GetProfiles(c.T, user.TeamId); result.Err != nil {
|
||||
if result := <-Srv.Store.User().GetProfiles(user.TeamId); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -1407,7 +1405,7 @@ func UpdateActive(c *Context, user *model.User, active bool) *model.User {
|
||||
user.DeleteAt = model.GetMillis()
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.User().Update(c.T, user, true); result.Err != nil {
|
||||
if result := <-Srv.Store.User().Update(user, true); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return nil
|
||||
} else {
|
||||
@@ -1436,39 +1434,39 @@ func PermanentDeleteUser(c *Context, user *model.User) *model.AppError {
|
||||
|
||||
UpdateActive(c, user, false)
|
||||
|
||||
if result := <-Srv.Store.Session().PermanentDeleteSessionsByUser(c.T, user.Id); result.Err != nil {
|
||||
if result := <-Srv.Store.Session().PermanentDeleteSessionsByUser(user.Id); result.Err != nil {
|
||||
return result.Err
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.OAuth().PermanentDeleteAuthDataByUser(c.T, user.Id); result.Err != nil {
|
||||
if result := <-Srv.Store.OAuth().PermanentDeleteAuthDataByUser(user.Id); result.Err != nil {
|
||||
return result.Err
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Webhook().PermanentDeleteIncomingByUser(c.T, user.Id); result.Err != nil {
|
||||
if result := <-Srv.Store.Webhook().PermanentDeleteIncomingByUser(user.Id); result.Err != nil {
|
||||
return result.Err
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Webhook().PermanentDeleteOutgoingByUser(c.T, user.Id); result.Err != nil {
|
||||
if result := <-Srv.Store.Webhook().PermanentDeleteOutgoingByUser(user.Id); result.Err != nil {
|
||||
return result.Err
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Preference().PermanentDeleteByUser(c.T, user.Id); result.Err != nil {
|
||||
if result := <-Srv.Store.Preference().PermanentDeleteByUser(user.Id); result.Err != nil {
|
||||
return result.Err
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Channel().PermanentDeleteMembersByUser(c.T, user.Id); result.Err != nil {
|
||||
if result := <-Srv.Store.Channel().PermanentDeleteMembersByUser(user.Id); result.Err != nil {
|
||||
return result.Err
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Post().PermanentDeleteByUser(c.T, user.Id); result.Err != nil {
|
||||
if result := <-Srv.Store.Post().PermanentDeleteByUser(user.Id); result.Err != nil {
|
||||
return result.Err
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.User().PermanentDelete(c.T, user.Id); result.Err != nil {
|
||||
if result := <-Srv.Store.User().PermanentDelete(user.Id); result.Err != nil {
|
||||
return result.Err
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Audit().PermanentDeleteByUser(c.T, user.Id); result.Err != nil {
|
||||
if result := <-Srv.Store.Audit().PermanentDeleteByUser(user.Id); result.Err != nil {
|
||||
return result.Err
|
||||
}
|
||||
|
||||
@@ -1494,7 +1492,7 @@ func sendPasswordReset(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
var team *model.Team
|
||||
if result := <-Srv.Store.Team().GetByName(c.T, name); result.Err != nil {
|
||||
if result := <-Srv.Store.Team().GetByName(name); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -1502,7 +1500,7 @@ func sendPasswordReset(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
var user *model.User
|
||||
if result := <-Srv.Store.User().GetByEmail(c.T, team.Id, email); result.Err != nil {
|
||||
if result := <-Srv.Store.User().GetByEmail(team.Id, email); result.Err != nil {
|
||||
c.Err = model.NewAppError("sendPasswordReset", "We couldn’t find an account with that address.", "email="+email+" team_id="+team.Id)
|
||||
return
|
||||
} else {
|
||||
@@ -1583,7 +1581,7 @@ func resetPassword(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
c.LogAuditWithUserId(userId, "attempt")
|
||||
|
||||
var team *model.Team
|
||||
if result := <-Srv.Store.Team().GetByName(c.T, name); result.Err != nil {
|
||||
if result := <-Srv.Store.Team().GetByName(name); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -1591,7 +1589,7 @@ func resetPassword(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
var user *model.User
|
||||
if result := <-Srv.Store.User().Get(c.T, userId); result.Err != nil {
|
||||
if result := <-Srv.Store.User().Get(userId); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -1622,7 +1620,7 @@ func resetPassword(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.User().UpdatePassword(c.T, userId, model.HashPassword(newPassword)); result.Err != nil {
|
||||
if result := <-Srv.Store.User().UpdatePassword(userId, model.HashPassword(newPassword)); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -1701,7 +1699,7 @@ func updateUserNotify(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
uchan := Srv.Store.User().Get(c.T, user_id)
|
||||
uchan := Srv.Store.User().Get(user_id)
|
||||
|
||||
if !c.HasPermissionsToUser(user_id, "updateUserNotify") {
|
||||
return
|
||||
@@ -1737,7 +1735,7 @@ func updateUserNotify(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
user.NotifyProps = props
|
||||
|
||||
if result := <-Srv.Store.User().Update(c.T, user, false); result.Err != nil {
|
||||
if result := <-Srv.Store.User().Update(user, false); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -1758,7 +1756,7 @@ func getStatuses(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.User().GetProfiles(c.T, c.Session.TeamId); result.Err != nil {
|
||||
if result := <-Srv.Store.User().GetProfiles(c.Session.TeamId); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -1822,7 +1820,7 @@ func GetAuthorizationCode(c *Context, service, teamName string, props map[string
|
||||
return authUrl, nil
|
||||
}
|
||||
|
||||
func AuthorizeOAuthUser(T goi18n.TranslateFunc, service, code, state, redirectUri string) (io.ReadCloser, *model.Team, map[string]string, *model.AppError) {
|
||||
func AuthorizeOAuthUser(service, code, state, redirectUri string) (io.ReadCloser, *model.Team, map[string]string, *model.AppError) {
|
||||
sso := utils.Cfg.GetSSOService(service)
|
||||
if sso == nil || !sso.Enable {
|
||||
return nil, nil, nil, model.NewAppError("AuthorizeOAuthUser", "Unsupported OAuth service provider", "service="+service)
|
||||
@@ -1847,7 +1845,7 @@ func AuthorizeOAuthUser(T goi18n.TranslateFunc, service, code, state, redirectUr
|
||||
return nil, nil, nil, model.NewAppError("AuthorizeOAuthUser", "Invalid state; missing team name", "")
|
||||
}
|
||||
|
||||
tchan := Srv.Store.Team().GetByName(T, teamName)
|
||||
tchan := Srv.Store.Team().GetByName(teamName)
|
||||
|
||||
p := url.Values{}
|
||||
p.Set("client_id", sso.Id)
|
||||
@@ -1900,13 +1898,13 @@ func AuthorizeOAuthUser(T goi18n.TranslateFunc, service, code, state, redirectUr
|
||||
|
||||
}
|
||||
|
||||
func IsUsernameTaken(T goi18n.TranslateFunc, name string, teamId string) bool {
|
||||
func IsUsernameTaken(name string, teamId string) bool {
|
||||
|
||||
if !model.IsValidUsername(name) {
|
||||
return false
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.User().GetByUsername(T, teamId, name); result.Err != nil {
|
||||
if result := <-Srv.Store.User().GetByUsername(teamId, name); result.Err != nil {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
@@ -1945,7 +1943,7 @@ func switchToSSO(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
c.LogAudit("attempt")
|
||||
|
||||
var team *model.Team
|
||||
if result := <-Srv.Store.Team().GetByName(c.T, teamName); result.Err != nil {
|
||||
if result := <-Srv.Store.Team().GetByName(teamName); result.Err != nil {
|
||||
c.LogAudit("fail - couldn't get team")
|
||||
c.Err = result.Err
|
||||
return
|
||||
@@ -1954,7 +1952,7 @@ func switchToSSO(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
var user *model.User
|
||||
if result := <-Srv.Store.User().GetByEmail(c.T, team.Id, email); result.Err != nil {
|
||||
if result := <-Srv.Store.User().GetByEmail(team.Id, email); result.Err != nil {
|
||||
c.LogAudit("fail - couldn't get user")
|
||||
c.Err = result.Err
|
||||
return
|
||||
@@ -2005,7 +2003,7 @@ func CompleteSwitchWithOAuth(c *Context, w http.ResponseWriter, r *http.Request,
|
||||
}
|
||||
|
||||
var user *model.User
|
||||
if result := <-Srv.Store.User().GetByEmail(c.T, team.Id, email); result.Err != nil {
|
||||
if result := <-Srv.Store.User().GetByEmail(team.Id, email); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -2017,7 +2015,7 @@ func CompleteSwitchWithOAuth(c *Context, w http.ResponseWriter, r *http.Request,
|
||||
return
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.User().UpdateAuthData(c.T, user.Id, service, authData); result.Err != nil {
|
||||
if result := <-Srv.Store.User().UpdateAuthData(user.Id, service, authData); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
}
|
||||
@@ -2049,7 +2047,7 @@ func switchToEmail(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
c.LogAudit("attempt")
|
||||
|
||||
var team *model.Team
|
||||
if result := <-Srv.Store.Team().GetByName(c.T, teamName); result.Err != nil {
|
||||
if result := <-Srv.Store.Team().GetByName(teamName); result.Err != nil {
|
||||
c.LogAudit("fail - couldn't get team")
|
||||
c.Err = result.Err
|
||||
return
|
||||
@@ -2058,7 +2056,7 @@ func switchToEmail(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
var user *model.User
|
||||
if result := <-Srv.Store.User().GetByEmail(c.T, team.Id, email); result.Err != nil {
|
||||
if result := <-Srv.Store.User().GetByEmail(team.Id, email); result.Err != nil {
|
||||
c.LogAudit("fail - couldn't get user")
|
||||
c.Err = result.Err
|
||||
return
|
||||
@@ -2073,7 +2071,7 @@ func switchToEmail(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.User().UpdatePassword(c.T, c.Session.UserId, model.HashPassword(password)); result.Err != nil {
|
||||
if result := <-Srv.Store.User().UpdatePassword(c.Session.UserId, model.HashPassword(password)); result.Err != nil {
|
||||
c.LogAudit("fail - database issue")
|
||||
c.Err = result.Err
|
||||
return
|
||||
|
||||
@@ -101,7 +101,7 @@ func TestLogin(t *testing.T) {
|
||||
|
||||
user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
ruser, _ := Client.CreateUser(&user, "")
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, ruser.Data.(*model.User).Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(ruser.Data.(*model.User).Id))
|
||||
|
||||
if result, err := Client.LoginById(ruser.Data.(*model.User).Id, user.Password); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -170,7 +170,7 @@ func TestLoginWithDeviceId(t *testing.T) {
|
||||
|
||||
user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
ruser := Client.Must(Client.CreateUser(&user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, ruser.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(ruser.Id))
|
||||
|
||||
deviceId := model.NewId()
|
||||
if result, err := Client.LoginByEmailWithDevice(team.Name, user.Email, user.Password, deviceId); err != nil {
|
||||
@@ -186,7 +186,7 @@ func TestLoginWithDeviceId(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if sresult := <-Srv.Store.Session().Get(utils.T, sessions[0].Id); sresult.Err == nil {
|
||||
if sresult := <-Srv.Store.Session().Get(sessions[0].Id); sresult.Err == nil {
|
||||
t.Fatal("session should have been removed")
|
||||
}
|
||||
}
|
||||
@@ -201,7 +201,7 @@ func TestSessions(t *testing.T) {
|
||||
|
||||
user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
ruser := Client.Must(Client.CreateUser(&user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, ruser.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(ruser.Id))
|
||||
|
||||
deviceId := model.NewId()
|
||||
Client.LoginByEmailWithDevice(team.Name, user.Email, user.Password, deviceId)
|
||||
@@ -253,18 +253,18 @@ func TestGetUser(t *testing.T) {
|
||||
|
||||
user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
ruser, _ := Client.CreateUser(&user, "")
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, ruser.Data.(*model.User).Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(ruser.Data.(*model.User).Id))
|
||||
|
||||
user2 := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
ruser2, _ := Client.CreateUser(&user2, "")
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, ruser2.Data.(*model.User).Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(ruser2.Data.(*model.User).Id))
|
||||
|
||||
team2 := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
|
||||
rteam2, _ := Client.CreateTeam(&team2)
|
||||
|
||||
user3 := model.User{TeamId: rteam2.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
ruser3, _ := Client.CreateUser(&user3, "")
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, ruser3.Data.(*model.User).Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(ruser3.Data.(*model.User).Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, user.Password)
|
||||
|
||||
@@ -345,7 +345,7 @@ func TestGetAudits(t *testing.T) {
|
||||
|
||||
user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
ruser, _ := Client.CreateUser(&user, "")
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, ruser.Data.(*model.User).Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(ruser.Data.(*model.User).Id))
|
||||
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
@@ -398,7 +398,7 @@ func TestUserCreateImage(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -432,7 +432,7 @@ func TestUserUploadProfileImage(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
if utils.Cfg.FileSettings.DriverName != "" {
|
||||
|
||||
@@ -538,7 +538,7 @@ func TestUserUpdate(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd", LastActivityAt: time1, LastPingAt: time1, Roles: ""}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
if _, err := Client.UpdateUser(user); err == nil {
|
||||
t.Fatal("Should have errored")
|
||||
@@ -594,7 +594,7 @@ func TestUserUpdate(t *testing.T) {
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user2.Email, "pwd")
|
||||
|
||||
@@ -613,7 +613,7 @@ func TestUserUpdatePassword(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
if _, err := Client.UpdateUserPassword(user.Id, "pwd", "newpwd"); err == nil {
|
||||
t.Fatal("Should have errored")
|
||||
@@ -672,11 +672,11 @@ func TestUserUpdateRoles(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: "test@nowhere.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
data := make(map[string]string)
|
||||
data["user_id"] = user.Id
|
||||
@@ -697,7 +697,7 @@ func TestUserUpdateRoles(t *testing.T) {
|
||||
|
||||
user3 := &model.User{TeamId: team2.Id, Email: "test@nowhere.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user3 = Client.Must(Client.CreateUser(user3, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user3.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user3.Id))
|
||||
|
||||
Client.LoginByEmail(team2.Name, user3.Email, "pwd")
|
||||
|
||||
@@ -742,11 +742,11 @@ func TestUserUpdateActive(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: "test@nowhere.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
if _, err := Client.UpdateActive(user.Id, false); err == nil {
|
||||
t.Fatal("Should have errored, not logged in")
|
||||
@@ -763,7 +763,7 @@ func TestUserUpdateActive(t *testing.T) {
|
||||
|
||||
user3 := &model.User{TeamId: team2.Id, Email: "test@nowhere.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user3 = Client.Must(Client.CreateUser(user3, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user3.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user3.Id))
|
||||
|
||||
Client.LoginByEmail(team2.Name, user3.Email, "pwd")
|
||||
|
||||
@@ -806,7 +806,7 @@ func TestUserPermDelete(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
@@ -845,7 +845,7 @@ func TestSendPasswordReset(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
data := make(map[string]string)
|
||||
data["email"] = user.Email
|
||||
@@ -878,7 +878,7 @@ func TestSendPasswordReset(t *testing.T) {
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", AuthData: "1", AuthService: "random"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
data["email"] = user2.Email
|
||||
data["name"] = team.Name
|
||||
@@ -895,7 +895,7 @@ func TestResetPassword(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
data := make(map[string]string)
|
||||
data["new_password"] = "newpwd"
|
||||
@@ -972,7 +972,7 @@ func TestResetPassword(t *testing.T) {
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", AuthData: "1", AuthService: "random"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
|
||||
data["new_password"] = "newpwd"
|
||||
props["user_id"] = user2.Id
|
||||
@@ -993,7 +993,7 @@ func TestUserUpdateNotify(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd", Roles: ""}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
data := make(map[string]string)
|
||||
data["user_id"] = user.Id
|
||||
@@ -1088,11 +1088,11 @@ func TestStatuses(t *testing.T) {
|
||||
|
||||
user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
ruser := Client.Must(Client.CreateUser(&user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, ruser.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(ruser.Id))
|
||||
|
||||
user2 := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
ruser2 := Client.Must(Client.CreateUser(&user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, ruser2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(ruser2.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, user.Password)
|
||||
|
||||
@@ -1125,7 +1125,7 @@ func TestSwitchToSSO(t *testing.T) {
|
||||
|
||||
user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
ruser := Client.Must(Client.CreateUser(&user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, ruser.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(ruser.Id))
|
||||
|
||||
m := map[string]string{}
|
||||
if _, err := Client.SwitchToSSO(m); err == nil {
|
||||
@@ -1174,11 +1174,11 @@ func TestSwitchToEmail(t *testing.T) {
|
||||
|
||||
user := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
ruser := Client.Must(Client.CreateUser(&user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, ruser.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(ruser.Id))
|
||||
|
||||
user2 := model.User{TeamId: rteam.Data.(*model.Team).Id, Email: strings.ToLower(model.NewId()) + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
ruser2 := Client.Must(Client.CreateUser(&user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, ruser2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(ruser2.Id))
|
||||
|
||||
m := map[string]string{}
|
||||
if _, err := Client.SwitchToSSO(m); err == nil {
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/mattermost/platform/model"
|
||||
"github.com/mattermost/platform/store"
|
||||
"github.com/mattermost/platform/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -30,8 +29,8 @@ type WebConn struct {
|
||||
|
||||
func NewWebConn(ws *websocket.Conn, teamId string, userId string, sessionId string) *WebConn {
|
||||
go func() {
|
||||
achan := Srv.Store.User().UpdateUserAndSessionActivity(utils.T, userId, sessionId, model.GetMillis())
|
||||
pchan := Srv.Store.User().UpdateLastPingAt(utils.T, userId, model.GetMillis())
|
||||
achan := Srv.Store.User().UpdateUserAndSessionActivity(userId, sessionId, model.GetMillis())
|
||||
pchan := Srv.Store.User().UpdateLastPingAt(userId, model.GetMillis())
|
||||
|
||||
if result := <-achan; result.Err != nil {
|
||||
l4g.Error("Failed to update LastActivityAt for user_id=%v and session_id=%v, err=%v", userId, sessionId, result.Err)
|
||||
@@ -56,7 +55,7 @@ func (c *WebConn) readPump() {
|
||||
c.WebSocket.SetReadDeadline(time.Now().Add(PONG_WAIT))
|
||||
|
||||
go func() {
|
||||
if result := <-Srv.Store.User().UpdateLastPingAt(utils.T, c.UserId, model.GetMillis()); result.Err != nil {
|
||||
if result := <-Srv.Store.User().UpdateLastPingAt(c.UserId, model.GetMillis()); result.Err != nil {
|
||||
l4g.Error("Failed to updated LastPingAt for user_id=%v, err=%v", c.UserId, result.Err)
|
||||
}
|
||||
}()
|
||||
@@ -108,7 +107,7 @@ func (c *WebConn) writePump() {
|
||||
}
|
||||
|
||||
func (c *WebConn) updateChannelAccessCache(channelId string) bool {
|
||||
allowed := hasPermissionsToChannel(Srv.Store.Channel().CheckPermissionsTo(utils.T, c.TeamId, channelId, c.UserId))
|
||||
allowed := hasPermissionsToChannel(Srv.Store.Channel().CheckPermissionsTo(c.TeamId, channelId, c.UserId))
|
||||
c.ChannelAccessCache[channelId] = allowed
|
||||
|
||||
return allowed
|
||||
|
||||
@@ -22,7 +22,7 @@ func TestSocket(t *testing.T) {
|
||||
|
||||
user1 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user1 = Client.Must(Client.CreateUser(user1, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user1.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user1.Id))
|
||||
Client.LoginByEmail(team.Name, user1.Email, "pwd")
|
||||
|
||||
channel1 := &model.Channel{DisplayName: "Test Web Scoket 1", Name: "a" + model.NewId() + "a", Type: model.CHANNEL_OPEN, TeamId: team.Id}
|
||||
@@ -41,7 +41,7 @@ func TestSocket(t *testing.T) {
|
||||
|
||||
user2 := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user2.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user2.Id))
|
||||
Client.LoginByEmail(team.Name, user2.Email, "pwd")
|
||||
|
||||
header2 := http.Header{}
|
||||
|
||||
@@ -41,8 +41,8 @@ func createIncomingHook(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
cchan := Srv.Store.Channel().Get(c.T, hook.ChannelId)
|
||||
pchan := Srv.Store.Channel().CheckPermissionsTo(c.T, c.Session.TeamId, hook.ChannelId, c.Session.UserId)
|
||||
cchan := Srv.Store.Channel().Get(hook.ChannelId)
|
||||
pchan := Srv.Store.Channel().CheckPermissionsTo(c.Session.TeamId, hook.ChannelId, c.Session.UserId)
|
||||
|
||||
hook.UserId = c.Session.UserId
|
||||
hook.TeamId = c.Session.TeamId
|
||||
@@ -62,7 +62,7 @@ func createIncomingHook(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Webhook().SaveIncoming(c.T, hook); result.Err != nil {
|
||||
if result := <-Srv.Store.Webhook().SaveIncoming(hook); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -89,7 +89,7 @@ func deleteIncomingHook(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Webhook().GetIncoming(c.T, id); result.Err != nil {
|
||||
if result := <-Srv.Store.Webhook().GetIncoming(id); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -100,7 +100,7 @@ func deleteIncomingHook(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
if err := (<-Srv.Store.Webhook().DeleteIncoming(c.T, id, model.GetMillis())).Err; err != nil {
|
||||
if err := (<-Srv.Store.Webhook().DeleteIncoming(id, model.GetMillis())).Err; err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
@@ -116,7 +116,7 @@ func getIncomingHooks(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Webhook().GetIncomingByUser(c.T, c.Session.UserId); result.Err != nil {
|
||||
if result := <-Srv.Store.Webhook().GetIncomingByUser(c.Session.UserId); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -145,8 +145,8 @@ func createOutgoingHook(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
hook.TeamId = c.Session.TeamId
|
||||
|
||||
if len(hook.ChannelId) != 0 {
|
||||
cchan := Srv.Store.Channel().Get(c.T, hook.ChannelId)
|
||||
pchan := Srv.Store.Channel().CheckPermissionsTo(c.T, c.Session.TeamId, hook.ChannelId, c.Session.UserId)
|
||||
cchan := Srv.Store.Channel().Get(hook.ChannelId)
|
||||
pchan := Srv.Store.Channel().CheckPermissionsTo(c.Session.TeamId, hook.ChannelId, c.Session.UserId)
|
||||
|
||||
var channel *model.Channel
|
||||
if result := <-cchan; result.Err != nil {
|
||||
@@ -171,7 +171,7 @@ func createOutgoingHook(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Webhook().SaveOutgoing(c.T, hook); result.Err != nil {
|
||||
if result := <-Srv.Store.Webhook().SaveOutgoing(hook); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -188,7 +188,7 @@ func getOutgoingHooks(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Webhook().GetOutgoingByCreator(c.T, c.Session.UserId); result.Err != nil {
|
||||
if result := <-Srv.Store.Webhook().GetOutgoingByCreator(c.Session.UserId); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -214,7 +214,7 @@ func deleteOutgoingHook(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if result := <-Srv.Store.Webhook().GetOutgoing(c.T, id); result.Err != nil {
|
||||
if result := <-Srv.Store.Webhook().GetOutgoing(id); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -225,7 +225,7 @@ func deleteOutgoingHook(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
if err := (<-Srv.Store.Webhook().DeleteOutgoing(c.T, id, model.GetMillis())).Err; err != nil {
|
||||
if err := (<-Srv.Store.Webhook().DeleteOutgoing(id, model.GetMillis())).Err; err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
@@ -252,7 +252,7 @@ func regenOutgoingHookToken(c *Context, w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
|
||||
var hook *model.OutgoingWebhook
|
||||
if result := <-Srv.Store.Webhook().GetOutgoing(c.T, id); result.Err != nil {
|
||||
if result := <-Srv.Store.Webhook().GetOutgoing(id); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
@@ -267,7 +267,7 @@ func regenOutgoingHookToken(c *Context, w http.ResponseWriter, r *http.Request)
|
||||
|
||||
hook.Token = model.NewId()
|
||||
|
||||
if result := <-Srv.Store.Webhook().UpdateOutgoing(c.T, hook); result.Err != nil {
|
||||
if result := <-Srv.Store.Webhook().UpdateOutgoing(hook); result.Err != nil {
|
||||
c.Err = result.Err
|
||||
return
|
||||
} else {
|
||||
|
||||
@@ -19,7 +19,7 @@ func TestCreateIncomingHook(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -82,7 +82,7 @@ func TestListIncomingHooks(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -120,7 +120,7 @@ func TestDeleteIncomingHook(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -160,7 +160,7 @@ func TestCreateOutgoingHook(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -223,7 +223,7 @@ func TestListOutgoingHooks(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -261,7 +261,7 @@ func TestDeleteOutgoingHook(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
@@ -301,7 +301,7 @@ func TestRegenOutgoingHookToken(t *testing.T) {
|
||||
|
||||
user := &model.User{TeamId: team.Id, Email: model.NewId() + "corey+test@test.com", Nickname: "Corey Hulen", Password: "pwd"}
|
||||
user = Client.Must(Client.CreateUser(user, "")).Data.(*model.User)
|
||||
store.Must(Srv.Store.User().VerifyEmail(utils.T, user.Id))
|
||||
store.Must(Srv.Store.User().VerifyEmail(user.Id))
|
||||
|
||||
Client.LoginByEmail(team.Name, user.Email, "pwd")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user