Commit fd619247 authored by Chris's avatar Chris Committed by Joram Wilander

refactor max users per team (#7691)

parent d39a722a
......@@ -52,7 +52,7 @@ func (a *App) CreateBasicUser(client *model.Client) *model.AppError {
}
ruser := result.Data.(*model.User)
store.Must(a.Srv.Store.User().VerifyEmail(ruser.Id))
store.Must(a.Srv.Store.Team().SaveMember(&model.TeamMember{TeamId: basicteam.Id, UserId: ruser.Id}))
store.Must(a.Srv.Store.Team().SaveMember(&model.TeamMember{TeamId: basicteam.Id, UserId: ruser.Id}, *a.Config().TeamSettings.MaxUsersPerTeam))
}
return nil
}
......
......@@ -304,7 +304,7 @@ func (a *App) joinUserToTeam(team *model.Team, user *model.User) (*model.TeamMem
}
} else {
// Membership appears to be missing. Lets try to add.
if tmr := <-a.Srv.Store.Team().SaveMember(tm); tmr.Err != nil {
if tmr := <-a.Srv.Store.Team().SaveMember(tm, *a.Config().TeamSettings.MaxUsersPerTeam); tmr.Err != nil {
return nil, false, tmr.Err
} else {
return tmr.Data.(*model.TeamMember), false, nil
......
......@@ -101,7 +101,7 @@ func manualTest(c *api.Context, w http.ResponseWriter, r *http.Request) {
}
<-c.App.Srv.Store.User().VerifyEmail(result.Data.(*model.User).Id)
<-c.App.Srv.Store.Team().SaveMember(&model.TeamMember{TeamId: teamID, UserId: result.Data.(*model.User).Id})
<-c.App.Srv.Store.Team().SaveMember(&model.TeamMember{TeamId: teamID, UserId: result.Data.(*model.User).Id}, *c.App.Config().TeamSettings.MaxUsersPerTeam)
newuser := result.Data.(*model.User)
userID = newuser.Id
......
......@@ -10,7 +10,6 @@ import (
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/store"
"github.com/mattermost/mattermost-server/utils"
)
const (
......@@ -326,30 +325,32 @@ func (s SqlTeamStore) AnalyticsTeamCount() store.StoreChannel {
})
}
func (s SqlTeamStore) SaveMember(member *model.TeamMember) store.StoreChannel {
func (s SqlTeamStore) SaveMember(member *model.TeamMember, maxUsersPerTeam int) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
if result.Err = member.IsValid(); result.Err != nil {
return
}
if count, err := s.GetMaster().SelectInt(
`SELECT
COUNT(0)
FROM
TeamMembers
INNER JOIN
Users
ON
TeamMembers.UserId = Users.Id
WHERE
TeamId = :TeamId
AND TeamMembers.DeleteAt = 0
AND Users.DeleteAt = 0`, map[string]interface{}{"TeamId": member.TeamId}); err != nil {
result.Err = model.NewAppError("SqlUserStore.Save", "store.sql_user.save.member_count.app_error", nil, "teamId="+member.TeamId+", "+err.Error(), http.StatusInternalServerError)
return
} else if int(count) >= *utils.Cfg.TeamSettings.MaxUsersPerTeam {
result.Err = model.NewAppError("SqlUserStore.Save", "store.sql_user.save.max_accounts.app_error", nil, "teamId="+member.TeamId, http.StatusBadRequest)
return
if maxUsersPerTeam >= 0 {
if count, err := s.GetMaster().SelectInt(
`SELECT
COUNT(0)
FROM
TeamMembers
INNER JOIN
Users
ON
TeamMembers.UserId = Users.Id
WHERE
TeamId = :TeamId
AND TeamMembers.DeleteAt = 0
AND Users.DeleteAt = 0`, map[string]interface{}{"TeamId": member.TeamId}); err != nil {
result.Err = model.NewAppError("SqlUserStore.Save", "store.sql_user.save.member_count.app_error", nil, "teamId="+member.TeamId+", "+err.Error(), http.StatusInternalServerError)
return
} else if count >= int64(maxUsersPerTeam) {
result.Err = model.NewAppError("SqlUserStore.Save", "store.sql_user.save.max_accounts.app_error", nil, "teamId="+member.TeamId, http.StatusBadRequest)
return
}
}
if err := s.GetMaster().Insert(member); err != nil {
......
......@@ -88,7 +88,7 @@ type TeamStore interface {
GetByInviteId(inviteId string) StoreChannel
PermanentDelete(teamId string) StoreChannel
AnalyticsTeamCount() StoreChannel
SaveMember(member *model.TeamMember) StoreChannel
SaveMember(member *model.TeamMember, maxUsersPerTeam int) StoreChannel
UpdateMember(member *model.TeamMember) StoreChannel
GetMember(teamId string, userId string) StoreChannel
GetMembers(teamId string, offset int, limit int) StoreChannel
......
......@@ -92,13 +92,13 @@ func testChannelStoreSaveDirectChannel(t *testing.T, ss store.Store) {
u1.Email = model.NewId()
u1.Nickname = model.NewId()
store.Must(ss.User().Save(u1))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}, -1))
u2 := &model.User{}
u2.Email = model.NewId()
u2.Nickname = model.NewId()
store.Must(ss.User().Save(u2))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id}))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id}, -1))
m1 := model.ChannelMember{}
m1.ChannelId = o1.Id
......@@ -153,13 +153,13 @@ func testChannelStoreCreateDirectChannel(t *testing.T, ss store.Store) {
u1.Email = model.NewId()
u1.Nickname = model.NewId()
store.Must(ss.User().Save(u1))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}, -1))
u2 := &model.User{}
u2.Email = model.NewId()
u2.Nickname = model.NewId()
store.Must(ss.User().Save(u2))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id}))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id}, -1))
res := <-ss.Channel().CreateDirectChannel(u1.Id, u2.Id)
if res.Err != nil {
......@@ -218,8 +218,8 @@ func testGetChannelUnread(t *testing.T, ss store.Store) {
uid := model.NewId()
m1 := &model.TeamMember{TeamId: teamId1, UserId: uid}
m2 := &model.TeamMember{TeamId: teamId2, UserId: uid}
store.Must(ss.Team().SaveMember(m1))
store.Must(ss.Team().SaveMember(m2))
store.Must(ss.Team().SaveMember(m1, -1))
store.Must(ss.Team().SaveMember(m2, -1))
notifyPropsModel := model.GetDefaultChannelNotifyProps()
// Setup Channel 1
......@@ -307,13 +307,13 @@ func testChannelStoreGet(t *testing.T, ss store.Store) {
u1.Email = model.NewId()
u1.Nickname = model.NewId()
store.Must(ss.User().Save(u1))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}, -1))
u2 := model.User{}
u2.Email = model.NewId()
u2.Nickname = model.NewId()
store.Must(ss.User().Save(&u2))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id}))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id}, -1))
o2 := model.Channel{}
o2.TeamId = model.NewId()
......@@ -652,13 +652,13 @@ func testChannelMemberStore(t *testing.T, ss store.Store) {
u1.Email = model.NewId()
u1.Nickname = model.NewId()
store.Must(ss.User().Save(&u1))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}, -1))
u2 := model.User{}
u2.Email = model.NewId()
u2.Nickname = model.NewId()
store.Must(ss.User().Save(&u2))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id}))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id}, -1))
o1 := model.ChannelMember{}
o1.ChannelId = c1.Id
......@@ -747,13 +747,13 @@ func testChannelDeleteMemberStore(t *testing.T, ss store.Store) {
u1.Email = model.NewId()
u1.Nickname = model.NewId()
store.Must(ss.User().Save(&u1))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u1.Id}, -1))
u2 := model.User{}
u2.Email = model.NewId()
u2.Nickname = model.NewId()
store.Must(ss.User().Save(&u2))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id}))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: model.NewId(), UserId: u2.Id}, -1))
o1 := model.ChannelMember{}
o1.ChannelId = c1.Id
......@@ -1494,7 +1494,7 @@ func testGetMemberCount(t *testing.T, ss store.Store) {
DeleteAt: 0,
}
store.Must(ss.User().Save(u1))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1))
m1 := model.ChannelMember{
ChannelId: c1.Id,
......@@ -1514,7 +1514,7 @@ func testGetMemberCount(t *testing.T, ss store.Store) {
DeleteAt: 0,
}
store.Must(ss.User().Save(&u2))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id}))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u2.Id}, -1))
m2 := model.ChannelMember{
ChannelId: c1.Id,
......@@ -1535,7 +1535,7 @@ func testGetMemberCount(t *testing.T, ss store.Store) {
DeleteAt: 0,
}
store.Must(ss.User().Save(&u3))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u3.Id}))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u3.Id}, -1))
m3 := model.ChannelMember{
ChannelId: c2.Id,
......@@ -1556,7 +1556,7 @@ func testGetMemberCount(t *testing.T, ss store.Store) {
DeleteAt: 10000,
}
store.Must(ss.User().Save(u4))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u4.Id}))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u4.Id}, -1))
m4 := model.ChannelMember{
ChannelId: c1.Id,
......@@ -1596,7 +1596,7 @@ func testUpdateExtrasByUser(t *testing.T, ss store.Store) {
DeleteAt: 0,
}
store.Must(ss.User().Save(u1))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: teamId, UserId: u1.Id}, -1))
m1 := model.ChannelMember{
ChannelId: c1.Id,
......
......@@ -81,13 +81,13 @@ func testComplianceExport(t *testing.T, ss store.Store) {
u1.Email = model.NewId()
u1.Username = model.NewId()
u1 = store.Must(ss.User().Save(u1)).(*model.User)
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: t1.Id, UserId: u1.Id}))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: t1.Id, UserId: u1.Id}, -1))
u2 := &model.User{}
u2.Email = model.NewId()
u2.Username = model.NewId()
u2 = store.Must(ss.User().Save(u2)).(*model.User)
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: t1.Id, UserId: u2.Id}))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: t1.Id, UserId: u2.Id}, -1))
c1 := &model.Channel{}
c1.TeamId = t1.Id
......@@ -243,13 +243,13 @@ func testComplianceExportDirectMessages(t *testing.T, ss store.Store) {
u1.Email = model.NewId()
u1.Username = model.NewId()
u1 = store.Must(ss.User().Save(u1)).(*model.User)
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: t1.Id, UserId: u1.Id}))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: t1.Id, UserId: u1.Id}, -1))
u2 := &model.User{}
u2.Email = model.NewId()
u2.Username = model.NewId()
u2 = store.Must(ss.User().Save(u2)).(*model.User)
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: t1.Id, UserId: u2.Id}))
store.Must(ss.Team().SaveMember(&model.TeamMember{TeamId: t1.Id, UserId: u2.Id}, -1))
c1 := &model.Channel{}
c1.TeamId = t1.Id
......
......@@ -9,7 +9,6 @@ import (
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/store"
"github.com/mattermost/mattermost-server/utils"
)
func TestTeamStore(t *testing.T, ss store.Store) {
......@@ -367,7 +366,7 @@ func testTeamStoreByUserId(t *testing.T, ss store.Store) {
o1 = store.Must(ss.Team().Save(o1)).(*model.Team)
m1 := &model.TeamMember{TeamId: o1.Id, UserId: model.NewId()}
store.Must(ss.Team().SaveMember(m1))
store.Must(ss.Team().SaveMember(m1, -1))
if r1 := <-ss.Team().GetTeamsByUserId(m1.UserId); r1.Err != nil {
t.Fatal(r1.Err)
......@@ -569,12 +568,12 @@ func testTeamMembers(t *testing.T, ss store.Store) {
m2 := &model.TeamMember{TeamId: teamId1, UserId: model.NewId()}
m3 := &model.TeamMember{TeamId: teamId2, UserId: model.NewId()}
if r1 := <-ss.Team().SaveMember(m1); r1.Err != nil {
if r1 := <-ss.Team().SaveMember(m1, -1); r1.Err != nil {
t.Fatal(r1.Err)
}
store.Must(ss.Team().SaveMember(m2))
store.Must(ss.Team().SaveMember(m3))
store.Must(ss.Team().SaveMember(m2, -1))
store.Must(ss.Team().SaveMember(m3, -1))
if r1 := <-ss.Team().GetMembers(teamId1, 0, 100); r1.Err != nil {
t.Fatal(r1.Err)
......@@ -635,7 +634,7 @@ func testTeamMembers(t *testing.T, ss store.Store) {
}
}
store.Must(ss.Team().SaveMember(m1))
store.Must(ss.Team().SaveMember(m1, -1))
if r1 := <-ss.Team().RemoveAllMembersByTeam(teamId1); r1.Err != nil {
t.Fatal(r1.Err)
......@@ -654,8 +653,8 @@ func testTeamMembers(t *testing.T, ss store.Store) {
uid := model.NewId()
m4 := &model.TeamMember{TeamId: teamId1, UserId: uid}
m5 := &model.TeamMember{TeamId: teamId2, UserId: uid}
store.Must(ss.Team().SaveMember(m4))
store.Must(ss.Team().SaveMember(m5))
store.Must(ss.Team().SaveMember(m4, -1))
store.Must(ss.Team().SaveMember(m5, -1))
if r1 := <-ss.Team().GetTeamsForUser(uid); r1.Err != nil {
t.Fatal(r1.Err)
......@@ -683,11 +682,7 @@ func testTeamMembers(t *testing.T, ss store.Store) {
}
func testSaveTeamMemberMaxMembers(t *testing.T, ss store.Store) {
MaxUsersPerTeam := *utils.Cfg.TeamSettings.MaxUsersPerTeam
defer func() {
*utils.Cfg.TeamSettings.MaxUsersPerTeam = MaxUsersPerTeam
}()
*utils.Cfg.TeamSettings.MaxUsersPerTeam = 5
maxUsersPerTeam := 5
team := store.Must(ss.Team().Save(&model.Team{
DisplayName: "DisplayName",
......@@ -698,9 +693,9 @@ func testSaveTeamMemberMaxMembers(t *testing.T, ss store.Store) {
<-ss.Team().PermanentDelete(team.Id)
}()
userIds := make([]string, *utils.Cfg.TeamSettings.MaxUsersPerTeam)
userIds := make([]string, maxUsersPerTeam)
for i := 0; i < *utils.Cfg.TeamSettings.MaxUsersPerTeam; i++ {
for i := 0; i < maxUsersPerTeam; i++ {
userIds[i] = store.Must(ss.User().Save(&model.User{
Username: model.NewId(),
Email: model.NewId(),
......@@ -713,7 +708,7 @@ func testSaveTeamMemberMaxMembers(t *testing.T, ss store.Store) {
store.Must(ss.Team().SaveMember(&model.TeamMember{
TeamId: team.Id,
UserId: userIds[i],
}))
}, maxUsersPerTeam))
defer func(userId string) {
<-ss.Team().RemoveMember(team.Id, userId)
......@@ -722,7 +717,7 @@ func testSaveTeamMemberMaxMembers(t *testing.T, ss store.Store) {
if result := <-ss.Team().GetTotalMemberCount(team.Id); result.Err != nil {
t.Fatal(result.Err)
} else if count := result.Data.(int64); int(count) != *utils.Cfg.TeamSettings.MaxUsersPerTeam {
} else if count := result.Data.(int64); int(count) != maxUsersPerTeam {
t.Fatalf("should start with 5 team members, had %v instead", count)
}
......@@ -737,13 +732,13 @@ func testSaveTeamMemberMaxMembers(t *testing.T, ss store.Store) {
if result := <-ss.Team().SaveMember(&model.TeamMember{
TeamId: team.Id,
UserId: newUserId,
}); result.Err == nil {
}, maxUsersPerTeam); result.Err == nil {
t.Fatal("shouldn't be able to save member when at maximum members per team")
}
if result := <-ss.Team().GetTotalMemberCount(team.Id); result.Err != nil {
t.Fatal(result.Err)
} else if count := result.Data.(int64); int(count) != *utils.Cfg.TeamSettings.MaxUsersPerTeam {
} else if count := result.Data.(int64); int(count) != maxUsersPerTeam {
t.Fatalf("should still have 5 team members, had %v instead", count)
}
......@@ -756,11 +751,11 @@ func testSaveTeamMemberMaxMembers(t *testing.T, ss store.Store) {
if result := <-ss.Team().GetTotalMemberCount(team.Id); result.Err != nil {
t.Fatal(result.Err)
} else if count := result.Data.(int64); int(count) != *utils.Cfg.TeamSettings.MaxUsersPerTeam-1 {
} else if count := result.Data.(int64); int(count) != maxUsersPerTeam-1 {
t.Fatalf("should now only have 4 team members, had %v instead", count)
}
if result := <-ss.Team().SaveMember(&model.TeamMember{TeamId: team.Id, UserId: newUserId}); result.Err != nil {
if result := <-ss.Team().SaveMember(&model.TeamMember{TeamId: team.Id, UserId: newUserId}, maxUsersPerTeam); result.Err != nil {
t.Fatal("should've been able to save new member after deleting one", result.Err)
} else {
defer func(userId string) {
......@@ -770,7 +765,7 @@ func testSaveTeamMemberMaxMembers(t *testing.T, ss store.Store) {
if result := <-ss.Team().GetTotalMemberCount(team.Id); result.Err != nil {
t.Fatal(result.Err)
} else if count := result.Data.(int64); int(count) != *utils.Cfg.TeamSettings.MaxUsersPerTeam {
} else if count := result.Data.(int64); int(count) != maxUsersPerTeam {
t.Fatalf("should have 5 team members again, had %v instead", count)
}
......@@ -783,7 +778,7 @@ func testSaveTeamMemberMaxMembers(t *testing.T, ss store.Store) {
Username: model.NewId(),
Email: model.NewId(),
})).(*model.User).Id
if result := <-ss.Team().SaveMember(&model.TeamMember{TeamId: team.Id, UserId: newUserId2}); result.Err != nil {
if result := <-ss.Team().SaveMember(&model.TeamMember{TeamId: team.Id, UserId: newUserId2}, maxUsersPerTeam); result.Err != nil {
t.Fatal("should've been able to save new member after deleting one", result.Err)
} else {
defer func(userId string) {
......@@ -796,7 +791,7 @@ func testGetTeamMember(t *testing.T, ss store.Store) {
teamId1 := model.NewId()
m1 := &model.TeamMember{TeamId: teamId1, UserId: model.NewId()}
store.Must(ss.Team().SaveMember(m1))
store.Must(ss.Team().SaveMember(m1, -1))
if r := <-ss.Team().GetMember(m1.TeamId, m1.UserId); r.Err != nil {
t.Fatal(r.Err)
......@@ -825,7 +820,7 @@ func testGetTeamMembersByIds(t *testing.T, ss store.Store) {
teamId1 := model.NewId()
m1 := &model.TeamMember{TeamId: teamId1, UserId: model.NewId()}
store.Must(ss.Team().SaveMember(m1))
store.Must(ss.Team().SaveMember(m1, -1))
if r := <-ss.Team().GetMembersByIds(m1.TeamId, []string{m1.UserId}); r.Err != nil {
t.Fatal(r.Err)
......@@ -842,7 +837,7 @@ func testGetTeamMembersByIds(t *testing.T, ss store.Store) {
}
m2 := &model.TeamMember{TeamId: teamId1, UserId: model.NewId()}
store.Must(ss.Team().SaveMember(m2))
store.Must(ss.Team().SaveMember(m2, -1))
if r := <-ss.Team().GetMembersByIds(m1.TeamId, []string{m1.UserId, m2.UserId, model.NewId()}); r.Err != nil {
t.Fatal(r.Err)
......@@ -871,10 +866,10 @@ func testTeamStoreMemberCount(t *testing.T, ss store.Store) {
teamId1 := model.NewId()
m1 := &model.TeamMember{TeamId: teamId1, UserId: u1.Id}
store.Must(ss.Team().SaveMember(m1))
store.Must(ss.Team().SaveMember(m1, -1))
m2 := &model.TeamMember{TeamId: teamId1, UserId: u2.Id}
store.Must(ss.Team().SaveMember(m2))
store.Must(ss.Team().SaveMember(m2, -1))
if result := <-ss.Team().GetTotalMemberCount(teamId1); result.Err != nil {
t.Fatal(result.Err)
......@@ -893,7 +888,7 @@ func testTeamStoreMemberCount(t *testing.T, ss store.Store) {
}
m3 := &model.TeamMember{TeamId: teamId1, UserId: model.NewId()}
store.Must(ss.Team().SaveMember(m3))
store.Must(ss.Team().SaveMember(m3, -1))
if result := <-ss.Team().GetTotalMemberCount(teamId1); result.Err != nil {
t.Fatal(result.Err)
......@@ -919,8 +914,8 @@ func testGetChannelUnreadsForAllTeams(t *testing.T, ss store.Store) {
uid := model.NewId()
m1 := &model.TeamMember{TeamId: teamId1, UserId: uid}
m2 := &model.TeamMember{TeamId: teamId2, UserId: uid}
store.Must(ss.Team().SaveMember(m1))
store.Must(ss.Team().SaveMember(m2))
store.Must(ss.Team().SaveMember(m1, -1))
store.Must(ss.Team().SaveMember(m2, -1))
c1 := &model.Channel{TeamId: m1.TeamId, Name: model.NewId(), DisplayName: "Town Square", Type: model.CHANNEL_OPEN, TotalMsgCount: 100}
store.Must(ss.Channel().Save(c1, -1))
......@@ -983,7 +978,7 @@ func testGetChannelUnreadsForTeam(t *testing.T, ss store.Store) {
uid := model.NewId()
m1 := &model.TeamMember{TeamId: teamId1, UserId: uid}
store.Must(ss.Team().SaveMember(m1))
store.Must(ss.Team().SaveMember(m1, -1))
c1 := &model.Channel{TeamId: m1.TeamId, Name: model.NewId(), DisplayName: "Town Square", Type: model.CHANNEL_OPEN, TotalMsgCount: 100}
store.Must(ss.Channel().Save(c1, -1))
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment