PLT-340
Этот коммит содержится в:
@@ -23,6 +23,7 @@ func NewSqlTeamStore(sqlStore *SqlStore) TeamStore {
|
||||
table.ColMap("Email").SetMaxSize(128)
|
||||
table.ColMap("CompanyName").SetMaxSize(64)
|
||||
table.ColMap("AllowedDomains").SetMaxSize(500)
|
||||
table.ColMap("InviteId").SetMaxSize(32)
|
||||
}
|
||||
|
||||
return s
|
||||
@@ -38,6 +39,7 @@ func (s SqlTeamStore) UpgradeSchemaIfNeeded() {
|
||||
|
||||
func (s SqlTeamStore) CreateIndexesIfNotExists() {
|
||||
s.CreateIndexIfNotExists("idx_teams_name", "Teams", "Name")
|
||||
s.CreateIndexIfNotExists("idx_teams_invite_id", "Teams", "InviteId")
|
||||
}
|
||||
|
||||
func (s SqlTeamStore) Save(team *model.Team) StoreChannel {
|
||||
@@ -101,6 +103,7 @@ func (s SqlTeamStore) Update(team *model.Team) StoreChannel {
|
||||
} else {
|
||||
oldTeam := oldResult.(*model.Team)
|
||||
team.CreateAt = oldTeam.CreateAt
|
||||
team.UpdateAt = model.GetMillis()
|
||||
team.Name = oldTeam.Name
|
||||
|
||||
if count, err := s.GetMaster().Update(team); err != nil {
|
||||
@@ -150,7 +153,12 @@ func (s SqlTeamStore) Get(id string) StoreChannel {
|
||||
} else if obj == nil {
|
||||
result.Err = model.NewAppError("SqlTeamStore.Get", "We couldn't find the existing team", "id="+id)
|
||||
} else {
|
||||
result.Data = obj.(*model.Team)
|
||||
team := obj.(*model.Team)
|
||||
if len(team.InviteId) == 0 {
|
||||
team.InviteId = team.Id
|
||||
}
|
||||
|
||||
result.Data = team
|
||||
}
|
||||
|
||||
storeChannel <- result
|
||||
@@ -160,6 +168,35 @@ func (s SqlTeamStore) Get(id string) StoreChannel {
|
||||
return storeChannel
|
||||
}
|
||||
|
||||
func (s SqlTeamStore) GetByInviteId(inviteId string) StoreChannel {
|
||||
storeChannel := make(StoreChannel)
|
||||
|
||||
go func() {
|
||||
result := StoreResult{}
|
||||
|
||||
team := model.Team{}
|
||||
|
||||
if err := s.GetReplica().SelectOne(&team, "SELECT * FROM Teams WHERE Id = :InviteId OR InviteId = :InviteId", map[string]interface{}{"InviteId": inviteId}); err != nil {
|
||||
result.Err = model.NewAppError("SqlTeamStore.GetByInviteId", "We couldn't find the existing team", "inviteId="+inviteId+", "+err.Error())
|
||||
}
|
||||
|
||||
if len(team.InviteId) == 0 {
|
||||
team.InviteId = team.Id
|
||||
}
|
||||
|
||||
if len(inviteId) == 0 || team.InviteId != inviteId {
|
||||
result.Err = model.NewAppError("SqlTeamStore.GetByInviteId", "We couldn't find the existing team", "inviteId="+inviteId)
|
||||
}
|
||||
|
||||
result.Data = &team
|
||||
|
||||
storeChannel <- result
|
||||
close(storeChannel)
|
||||
}()
|
||||
|
||||
return storeChannel
|
||||
}
|
||||
|
||||
func (s SqlTeamStore) GetByName(name string) StoreChannel {
|
||||
storeChannel := make(StoreChannel)
|
||||
|
||||
@@ -172,6 +209,10 @@ func (s SqlTeamStore) GetByName(name string) StoreChannel {
|
||||
result.Err = model.NewAppError("SqlTeamStore.GetByName", "We couldn't find the existing team", "name="+name+", "+err.Error())
|
||||
}
|
||||
|
||||
if len(team.InviteId) == 0 {
|
||||
team.InviteId = team.Id
|
||||
}
|
||||
|
||||
result.Data = &team
|
||||
|
||||
storeChannel <- result
|
||||
@@ -192,6 +233,12 @@ func (s SqlTeamStore) GetTeamsForEmail(email string) StoreChannel {
|
||||
result.Err = model.NewAppError("SqlTeamStore.GetTeamsForEmail", "We encounted a problem when looking up teams", "email="+email+", "+err.Error())
|
||||
}
|
||||
|
||||
for _, team := range data {
|
||||
if len(team.InviteId) == 0 {
|
||||
team.InviteId = team.Id
|
||||
}
|
||||
}
|
||||
|
||||
result.Data = data
|
||||
|
||||
storeChannel <- result
|
||||
@@ -212,6 +259,38 @@ func (s SqlTeamStore) GetAll() StoreChannel {
|
||||
result.Err = model.NewAppError("SqlTeamStore.GetAllTeams", "We could not get all teams", err.Error())
|
||||
}
|
||||
|
||||
for _, team := range data {
|
||||
if len(team.InviteId) == 0 {
|
||||
team.InviteId = team.Id
|
||||
}
|
||||
}
|
||||
|
||||
result.Data = data
|
||||
|
||||
storeChannel <- result
|
||||
close(storeChannel)
|
||||
}()
|
||||
|
||||
return storeChannel
|
||||
}
|
||||
|
||||
func (s SqlTeamStore) GetAllTeamListing() StoreChannel {
|
||||
storeChannel := make(StoreChannel)
|
||||
|
||||
go func() {
|
||||
result := StoreResult{}
|
||||
|
||||
var data []*model.Team
|
||||
if _, err := s.GetReplica().Select(&data, "SELECT * FROM Teams WHERE AllowTeamListing = 1"); err != nil {
|
||||
result.Err = model.NewAppError("SqlTeamStore.GetAllTeams", "We could not get all teams", err.Error())
|
||||
}
|
||||
|
||||
for _, team := range data {
|
||||
if len(team.InviteId) == 0 {
|
||||
team.InviteId = team.Id
|
||||
}
|
||||
}
|
||||
|
||||
result.Data = data
|
||||
|
||||
storeChannel <- result
|
||||
|
||||
Ссылка в новой задаче
Block a user