Commit aefbb541 authored by Corey Hulen's avatar Corey Hulen

Revert " PLT-7 adding loc for db calls"

parent 0b1aff3b
......@@ -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
}
......
......@@ -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))