[MM-16171] Migrate "Team.GetByInviteId" to Sync by default (#11137)
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
c78b769c2e
Коммит
7d77420962
@@ -274,22 +274,18 @@ func (s SqlTeamStore) Get(id string) (*model.Team, *model.AppError) {
|
||||
return obj.(*model.Team), nil
|
||||
}
|
||||
|
||||
func (s SqlTeamStore) GetByInviteId(inviteId string) store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
team := model.Team{}
|
||||
func (s SqlTeamStore) GetByInviteId(inviteId string) (*model.Team, *model.AppError) {
|
||||
team := model.Team{}
|
||||
|
||||
if err := s.GetReplica().SelectOne(&team, "SELECT * FROM Teams WHERE InviteId = :InviteId", map[string]interface{}{"InviteId": inviteId}); err != nil {
|
||||
result.Err = model.NewAppError("SqlTeamStore.GetByInviteId", "store.sql_team.get_by_invite_id.finding.app_error", nil, "inviteId="+inviteId+", "+err.Error(), http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
err := s.GetReplica().SelectOne(&team, "SELECT * FROM Teams WHERE InviteId = :InviteId", map[string]interface{}{"InviteId": inviteId})
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SqlTeamStore.GetByInviteId", "store.sql_team.get_by_invite_id.finding.app_error", nil, "inviteId="+inviteId+", "+err.Error(), http.StatusNotFound)
|
||||
}
|
||||
|
||||
if len(inviteId) == 0 || team.InviteId != inviteId {
|
||||
result.Err = model.NewAppError("SqlTeamStore.GetByInviteId", "store.sql_team.get_by_invite_id.find.app_error", nil, "inviteId="+inviteId, http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
result.Data = &team
|
||||
})
|
||||
if len(inviteId) == 0 || team.InviteId != inviteId {
|
||||
return nil, model.NewAppError("SqlTeamStore.GetByInviteId", "store.sql_team.get_by_invite_id.find.app_error", nil, "inviteId="+inviteId, http.StatusNotFound)
|
||||
}
|
||||
return &team, nil
|
||||
}
|
||||
|
||||
func (s SqlTeamStore) GetByName(name string) (*model.Team, *model.AppError) {
|
||||
|
||||
@@ -97,7 +97,7 @@ type TeamStore interface {
|
||||
GetAllTeamListing() StoreChannel
|
||||
GetAllTeamPageListing(offset int, limit int) StoreChannel
|
||||
GetTeamsByUserId(userId string) StoreChannel
|
||||
GetByInviteId(inviteId string) StoreChannel
|
||||
GetByInviteId(inviteId string) (*model.Team, *model.AppError)
|
||||
PermanentDelete(teamId string) StoreChannel
|
||||
AnalyticsTeamCount() StoreChannel
|
||||
SaveMember(member *model.TeamMember, maxUsersPerTeam int) StoreChannel
|
||||
|
||||
@@ -229,19 +229,28 @@ func (_m *TeamStore) GetAllTeamPageListing(offset int, limit int) store.StoreCha
|
||||
}
|
||||
|
||||
// GetByInviteId provides a mock function with given fields: inviteId
|
||||
func (_m *TeamStore) GetByInviteId(inviteId string) store.StoreChannel {
|
||||
func (_m *TeamStore) GetByInviteId(inviteId string) (*model.Team, *model.AppError) {
|
||||
ret := _m.Called(inviteId)
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func(string) store.StoreChannel); ok {
|
||||
var r0 *model.Team
|
||||
if rf, ok := ret.Get(0).(func(string) *model.Team); ok {
|
||||
r0 = rf(inviteId)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
r0 = ret.Get(0).(*model.Team)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
|
||||
r1 = rf(inviteId)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetByName provides a mock function with given fields: name
|
||||
|
||||
@@ -406,15 +406,15 @@ func testTeamStoreGetByInviteId(t *testing.T, ss store.Store) {
|
||||
o2.Email = MakeEmail()
|
||||
o2.Type = model.TEAM_OPEN
|
||||
|
||||
if r1 := <-ss.Team().GetByInviteId(save1.InviteId); r1.Err != nil {
|
||||
t.Fatal(r1.Err)
|
||||
if r1, err := ss.Team().GetByInviteId(save1.InviteId); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
if r1.Data.(*model.Team).ToJson() != o1.ToJson() {
|
||||
if r1.ToJson() != o1.ToJson() {
|
||||
t.Fatal("invalid returned team")
|
||||
}
|
||||
}
|
||||
|
||||
if err := (<-ss.Team().GetByInviteId("")).Err; err == nil {
|
||||
if _, err := ss.Team().GetByInviteId(""); err == nil {
|
||||
t.Fatal("Missing id should have failed")
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user