Этот коммит содержится в:
Alex Sahin
2019-06-26 16:27:30 +01:00
коммит произвёл Maria A Nunez
родитель 6ff393527e
Коммит cb7c549c7b
4 изменённых файлов: 22 добавлений и 17 удалений

Просмотреть файл

@@ -1841,8 +1841,8 @@ func (a *App) MarkChannelsAsViewed(channelIds []string, userId string, currentSe
notify = user.NotifyProps[model.PUSH_NOTIFY_PROP] notify = user.NotifyProps[model.PUSH_NOTIFY_PROP]
} }
if notify == model.USER_NOTIFY_ALL { if notify == model.USER_NOTIFY_ALL {
if result := <-a.Srv.Store.User().GetAnyUnreadPostCountForChannel(userId, channelId); result.Err == nil { if count, err := a.Srv.Store.User().GetAnyUnreadPostCountForChannel(userId, channelId); err == nil {
if result.Data.(int64) > 0 { if count > 0 {
channelsToClearPushNotifications = append(channelsToClearPushNotifications, channelId) channelsToClearPushNotifications = append(channelsToClearPushNotifications, channelId)
} }
} }

Просмотреть файл

@@ -1214,14 +1214,12 @@ func (us SqlUserStore) GetUnreadCountForChannel(userId string, channelId string)
}) })
} }
func (us SqlUserStore) GetAnyUnreadPostCountForChannel(userId string, channelId string) store.StoreChannel { func (us SqlUserStore) GetAnyUnreadPostCountForChannel(userId string, channelId string) (int64, *model.AppError) {
return store.Do(func(result *store.StoreResult) { count, err := us.GetReplica().SelectInt("SELECT SUM(c.TotalMsgCount - cm.MsgCount) FROM Channels c INNER JOIN ChannelMembers cm ON c.Id = cm.ChannelId AND cm.ChannelId = :ChannelId AND cm.UserId = :UserId", map[string]interface{}{"ChannelId": channelId, "UserId": userId})
if count, err := us.GetReplica().SelectInt("SELECT SUM(c.TotalMsgCount - cm.MsgCount) FROM Channels c INNER JOIN ChannelMembers cm ON c.Id = cm.ChannelId AND cm.ChannelId = :ChannelId AND cm.UserId = :UserId", map[string]interface{}{"ChannelId": channelId, "UserId": userId}); err != nil { if err != nil {
result.Err = model.NewAppError("SqlUserStore.GetMentionCountForChannel", "store.sql_user.get_unread_count_for_channel.app_error", nil, err.Error(), http.StatusInternalServerError) return count, model.NewAppError("SqlUserStore.GetMentionCountForChannel", "store.sql_user.get_unread_count_for_channel.app_error", nil, err.Error(), http.StatusInternalServerError)
} else { }
result.Data = count return count, nil
}
})
} }
func (us SqlUserStore) Search(teamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) { func (us SqlUserStore) Search(teamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) {

Просмотреть файл

@@ -285,7 +285,7 @@ type UserStore interface {
AnalyticsActiveCount(time int64) StoreChannel AnalyticsActiveCount(time int64) StoreChannel
GetUnreadCount(userId string) (int64, error) GetUnreadCount(userId string) (int64, error)
GetUnreadCountForChannel(userId string, channelId string) StoreChannel GetUnreadCountForChannel(userId string, channelId string) StoreChannel
GetAnyUnreadPostCountForChannel(userId string, channelId string) StoreChannel GetAnyUnreadPostCountForChannel(userId string, channelId string) (int64, *model.AppError)
GetRecentlyActiveUsersForTeam(teamId string, offset, limit int, viewRestrictions *model.ViewUsersRestrictions) StoreChannel GetRecentlyActiveUsersForTeam(teamId string, offset, limit int, viewRestrictions *model.ViewUsersRestrictions) StoreChannel
GetNewUsersForTeam(teamId string, offset, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError) GetNewUsersForTeam(teamId string, offset, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
Search(teamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError) Search(teamId string, term string, options *model.UserSearchOptions) ([]*model.User, *model.AppError)

Просмотреть файл

@@ -220,19 +220,26 @@ func (_m *UserStore) GetAllUsingAuthService(authService string) ([]*model.User,
} }
// GetAnyUnreadPostCountForChannel provides a mock function with given fields: userId, channelId // GetAnyUnreadPostCountForChannel provides a mock function with given fields: userId, channelId
func (_m *UserStore) GetAnyUnreadPostCountForChannel(userId string, channelId string) store.StoreChannel { func (_m *UserStore) GetAnyUnreadPostCountForChannel(userId string, channelId string) (int64, *model.AppError) {
ret := _m.Called(userId, channelId) ret := _m.Called(userId, channelId)
var r0 store.StoreChannel var r0 int64
if rf, ok := ret.Get(0).(func(string, string) store.StoreChannel); ok { if rf, ok := ret.Get(0).(func(string, string) int64); ok {
r0 = rf(userId, channelId) r0 = rf(userId, channelId)
} else { } else {
if ret.Get(0) != nil { r0 = ret.Get(0).(int64)
r0 = ret.Get(0).(store.StoreChannel) }
var r1 *model.AppError
if rf, ok := ret.Get(1).(func(string, string) *model.AppError); ok {
r1 = rf(userId, channelId)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*model.AppError)
} }
} }
return r0 return r0, r1
} }
// GetByAuth provides a mock function with given fields: authData, authService // GetByAuth provides a mock function with given fields: authData, authService