Migrates Channel.GetMembersForUser to sync by default (#11236)
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
1f6aedcdf3
Коммит
d17bdc6764
@@ -1301,11 +1301,7 @@ func (a *App) GetChannelMembersByIds(channelId string, userIds []string) (*model
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) GetChannelMembersForUser(teamId string, userId string) (*model.ChannelMembers, *model.AppError) {
|
func (a *App) GetChannelMembersForUser(teamId string, userId string) (*model.ChannelMembers, *model.AppError) {
|
||||||
result := <-a.Srv.Store.Channel().GetMembersForUser(teamId, userId)
|
return a.Srv.Store.Channel().GetMembersForUser(teamId, userId)
|
||||||
if result.Err != nil {
|
|
||||||
return nil, result.Err
|
|
||||||
}
|
|
||||||
return result.Data.(*model.ChannelMembers), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) GetChannelMembersForUserWithPagination(teamId, userId string, page, perPage int) ([]*model.ChannelMember, *model.AppError) {
|
func (a *App) GetChannelMembersForUserWithPagination(teamId, userId string, page, perPage int) ([]*model.ChannelMember, *model.AppError) {
|
||||||
|
|||||||
@@ -152,19 +152,17 @@ func (job *EmailBatchingJob) checkPendingNotifications(now time.Time, handler fu
|
|||||||
|
|
||||||
// if the user has viewed any channels in this team since the notification was queued, delete
|
// if the user has viewed any channels in this team since the notification was queued, delete
|
||||||
// all queued notifications
|
// all queued notifications
|
||||||
result := <-job.server.Store.Channel().GetMembersForUser(inspectedTeamNames[notification.teamName], userId)
|
channelMembers, err := job.server.Store.Channel().GetMembersForUser(inspectedTeamNames[notification.teamName], userId)
|
||||||
if result.Err != nil {
|
if err != nil {
|
||||||
mlog.Error(fmt.Sprint("Unable to find ChannelMembers for user", result.Err))
|
mlog.Error(fmt.Sprint("Unable to find ChannelMembers for user", err))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if channelMembers, ok := result.Data.(*model.ChannelMembers); ok {
|
for _, channelMember := range *channelMembers {
|
||||||
for _, channelMember := range *channelMembers {
|
if channelMember.LastViewedAt >= batchStartTime {
|
||||||
if channelMember.LastViewedAt >= batchStartTime {
|
mlog.Debug(fmt.Sprintf("Deleted notifications for user %s", userId), mlog.String("user_id", userId))
|
||||||
mlog.Debug(fmt.Sprintf("Deleted notifications for user %s", userId), mlog.String("user_id", userId))
|
delete(job.pendingNotifications, userId)
|
||||||
delete(job.pendingNotifications, userId)
|
break
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2198,13 +2198,13 @@ func (a *App) GetViewUsersRestrictionsForTeam(userId string, teamId string) ([]s
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
result := <-a.Srv.Store.Channel().GetMembersForUser(teamId, userId)
|
members, err := a.Srv.Store.Channel().GetMembersForUser(teamId, userId)
|
||||||
if result.Err != nil {
|
if err != nil {
|
||||||
return nil, result.Err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
channelIds := []string{}
|
channelIds := []string{}
|
||||||
for _, membership := range *result.Data.(*model.ChannelMembers) {
|
for _, membership := range *members {
|
||||||
channelIds = append(channelIds, membership.ChannelId)
|
channelIds = append(channelIds, membership.ChannelId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1904,18 +1904,15 @@ func (s SqlChannelStore) AnalyticsDeletedTypeCount(teamId string, channelType st
|
|||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) GetMembersForUser(teamId string, userId string) store.StoreChannel {
|
func (s SqlChannelStore) GetMembersForUser(teamId string, userId string) (*model.ChannelMembers, *model.AppError) {
|
||||||
return store.Do(func(result *store.StoreResult) {
|
var dbMembers channelMemberWithSchemeRolesList
|
||||||
var dbMembers channelMemberWithSchemeRolesList
|
_, err := s.GetReplica().Select(&dbMembers, CHANNEL_MEMBERS_WITH_SCHEME_SELECT_QUERY+"WHERE ChannelMembers.UserId = :UserId", map[string]interface{}{"TeamId": teamId, "UserId": userId})
|
||||||
_, err := s.GetReplica().Select(&dbMembers, CHANNEL_MEMBERS_WITH_SCHEME_SELECT_QUERY+"WHERE ChannelMembers.UserId = :UserId", map[string]interface{}{"TeamId": teamId, "UserId": userId})
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
result.Err = model.NewAppError("SqlChannelStore.GetMembersForUser", "store.sql_channel.get_members.app_error", nil, "teamId="+teamId+", userId="+userId+", err="+err.Error(), http.StatusInternalServerError)
|
return nil, model.NewAppError("SqlChannelStore.GetMembersForUser", "store.sql_channel.get_members.app_error", nil, "teamId="+teamId+", userId="+userId+", err="+err.Error(), http.StatusInternalServerError)
|
||||||
return
|
}
|
||||||
}
|
|
||||||
|
|
||||||
result.Data = dbMembers.ToModel()
|
return dbMembers.ToModel(), nil
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SqlChannelStore) GetMembersForUserWithPagination(teamId, userId string, page, perPage int) store.StoreChannel {
|
func (s SqlChannelStore) GetMembersForUserWithPagination(teamId, userId string, page, perPage int) store.StoreChannel {
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ type ChannelStore interface {
|
|||||||
UpdateLastViewedAt(channelIds []string, userId string) StoreChannel
|
UpdateLastViewedAt(channelIds []string, userId string) StoreChannel
|
||||||
IncrementMentionCount(channelId string, userId string) *model.AppError
|
IncrementMentionCount(channelId string, userId string) *model.AppError
|
||||||
AnalyticsTypeCount(teamId string, channelType string) (int64, *model.AppError)
|
AnalyticsTypeCount(teamId string, channelType string) (int64, *model.AppError)
|
||||||
GetMembersForUser(teamId string, userId string) StoreChannel
|
GetMembersForUser(teamId string, userId string) (*model.ChannelMembers, *model.AppError)
|
||||||
GetMembersForUserWithPagination(teamId, userId string, page, perPage int) StoreChannel
|
GetMembersForUserWithPagination(teamId, userId string, page, perPage int) StoreChannel
|
||||||
AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError)
|
AutocompleteInTeam(teamId string, term string, includeDeleted bool) (*model.ChannelList, *model.AppError)
|
||||||
AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) StoreChannel
|
AutocompleteInTeamForSearch(teamId string, userId string, term string, includeDeleted bool) StoreChannel
|
||||||
|
|||||||
@@ -1597,8 +1597,8 @@ func testChannelStoreGetMembersForUser(t *testing.T, ss store.Store) {
|
|||||||
m2.NotifyProps = model.GetDefaultChannelNotifyProps()
|
m2.NotifyProps = model.GetDefaultChannelNotifyProps()
|
||||||
store.Must(ss.Channel().SaveMember(&m2))
|
store.Must(ss.Channel().SaveMember(&m2))
|
||||||
|
|
||||||
cresult := <-ss.Channel().GetMembersForUser(o1.TeamId, m1.UserId)
|
members, err := ss.Channel().GetMembersForUser(o1.TeamId, m1.UserId)
|
||||||
members := cresult.Data.(*model.ChannelMembers)
|
require.Nil(t, err)
|
||||||
|
|
||||||
// no unread messages
|
// no unread messages
|
||||||
if len(*members) != 2 {
|
if len(*members) != 2 {
|
||||||
|
|||||||
@@ -855,19 +855,28 @@ func (_m *ChannelStore) GetMembersByIds(channelId string, userIds []string) (*mo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetMembersForUser provides a mock function with given fields: teamId, userId
|
// GetMembersForUser provides a mock function with given fields: teamId, userId
|
||||||
func (_m *ChannelStore) GetMembersForUser(teamId string, userId string) store.StoreChannel {
|
func (_m *ChannelStore) GetMembersForUser(teamId string, userId string) (*model.ChannelMembers, *model.AppError) {
|
||||||
ret := _m.Called(teamId, userId)
|
ret := _m.Called(teamId, userId)
|
||||||
|
|
||||||
var r0 store.StoreChannel
|
var r0 *model.ChannelMembers
|
||||||
if rf, ok := ret.Get(0).(func(string, string) store.StoreChannel); ok {
|
if rf, ok := ret.Get(0).(func(string, string) *model.ChannelMembers); ok {
|
||||||
r0 = rf(teamId, userId)
|
r0 = rf(teamId, userId)
|
||||||
} else {
|
} else {
|
||||||
if ret.Get(0) != nil {
|
if ret.Get(0) != nil {
|
||||||
r0 = ret.Get(0).(store.StoreChannel)
|
r0 = ret.Get(0).(*model.ChannelMembers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r0
|
var r1 *model.AppError
|
||||||
|
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
|
||||||
|
r1 = rf(teamId, userId)
|
||||||
|
} else {
|
||||||
|
if ret.Get(1) != nil {
|
||||||
|
r1 = ret.Get(1).(*model.AppError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMembersForUserWithPagination provides a mock function with given fields: teamId, userId, page, perPage
|
// GetMembersForUserWithPagination provides a mock function with given fields: teamId, userId, page, perPage
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user