MM-30558 - Add unreadReplies and unreadMentions to thread membership (#16304)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
cd9185fa23
Коммит
86e228b6c6
@@ -7756,7 +7756,7 @@ func (s *OpenTracingLayerThreadStore) GetMembershipForUser(userId string, postId
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerThreadStore) GetMembershipsForUser(userId string) ([]*model.ThreadMembership, error) {
|
||||
func (s *OpenTracingLayerThreadStore) GetMembershipsForUser(userId string, teamId string) ([]*model.ThreadMembership, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ThreadStore.GetMembershipsForUser")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -7765,7 +7765,7 @@ func (s *OpenTracingLayerThreadStore) GetMembershipsForUser(userId string) ([]*m
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
result, err := s.ThreadStore.GetMembershipsForUser(userId)
|
||||
result, err := s.ThreadStore.GetMembershipsForUser(userId, teamId)
|
||||
if err != nil {
|
||||
span.LogFields(spanlog.Error(err))
|
||||
ext.Error.Set(span, true)
|
||||
@@ -7792,7 +7792,7 @@ func (s *OpenTracingLayerThreadStore) GetPosts(threadId string, since int64) ([]
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerThreadStore) GetThreadsForUser(userId string, opts model.GetUserThreadsOpts) (*model.Threads, error) {
|
||||
func (s *OpenTracingLayerThreadStore) GetThreadsForUser(userId string, teamId string, opts model.GetUserThreadsOpts) (*model.Threads, error) {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ThreadStore.GetThreadsForUser")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -7801,7 +7801,7 @@ func (s *OpenTracingLayerThreadStore) GetThreadsForUser(userId string, opts mode
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
result, err := s.ThreadStore.GetThreadsForUser(userId, opts)
|
||||
result, err := s.ThreadStore.GetThreadsForUser(userId, teamId, opts)
|
||||
if err != nil {
|
||||
span.LogFields(spanlog.Error(err))
|
||||
ext.Error.Set(span, true)
|
||||
@@ -7810,7 +7810,7 @@ func (s *OpenTracingLayerThreadStore) GetThreadsForUser(userId string, opts mode
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *OpenTracingLayerThreadStore) MarkAllAsRead(userId string, timestamp int64) error {
|
||||
func (s *OpenTracingLayerThreadStore) MarkAllAsRead(userId string, teamId string) error {
|
||||
origCtx := s.Root.Store.Context()
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(s.Root.Store.Context(), "ThreadStore.MarkAllAsRead")
|
||||
s.Root.Store.SetContext(newCtx)
|
||||
@@ -7819,7 +7819,7 @@ func (s *OpenTracingLayerThreadStore) MarkAllAsRead(userId string, timestamp int
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
err := s.ThreadStore.MarkAllAsRead(userId, timestamp)
|
||||
err := s.ThreadStore.MarkAllAsRead(userId, teamId)
|
||||
if err != nil {
|
||||
span.LogFields(spanlog.Error(err))
|
||||
ext.Error.Set(span, true)
|
||||
|
||||
@@ -8418,11 +8418,11 @@ func (s *RetryLayerThreadStore) GetMembershipForUser(userId string, postId strin
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerThreadStore) GetMembershipsForUser(userId string) ([]*model.ThreadMembership, error) {
|
||||
func (s *RetryLayerThreadStore) GetMembershipsForUser(userId string, teamId string) ([]*model.ThreadMembership, error) {
|
||||
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.ThreadStore.GetMembershipsForUser(userId)
|
||||
result, err := s.ThreadStore.GetMembershipsForUser(userId, teamId)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
@@ -8458,11 +8458,11 @@ func (s *RetryLayerThreadStore) GetPosts(threadId string, since int64) ([]*model
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerThreadStore) GetThreadsForUser(userId string, opts model.GetUserThreadsOpts) (*model.Threads, error) {
|
||||
func (s *RetryLayerThreadStore) GetThreadsForUser(userId string, teamId string, opts model.GetUserThreadsOpts) (*model.Threads, error) {
|
||||
|
||||
tries := 0
|
||||
for {
|
||||
result, err := s.ThreadStore.GetThreadsForUser(userId, opts)
|
||||
result, err := s.ThreadStore.GetThreadsForUser(userId, teamId, opts)
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
@@ -8478,11 +8478,11 @@ func (s *RetryLayerThreadStore) GetThreadsForUser(userId string, opts model.GetU
|
||||
|
||||
}
|
||||
|
||||
func (s *RetryLayerThreadStore) MarkAllAsRead(userId string, timestamp int64) error {
|
||||
func (s *RetryLayerThreadStore) MarkAllAsRead(userId string, teamId string) error {
|
||||
|
||||
tries := 0
|
||||
for {
|
||||
err := s.ThreadStore.MarkAllAsRead(userId, timestamp)
|
||||
err := s.ThreadStore.MarkAllAsRead(userId, teamId)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -108,44 +108,119 @@ func (s *SqlThreadStore) Get(id string) (*model.Thread, error) {
|
||||
return &thread, nil
|
||||
}
|
||||
|
||||
func (s *SqlThreadStore) GetThreadsForUser(userId string, opts model.GetUserThreadsOpts) (*model.Threads, error) {
|
||||
func (s *SqlThreadStore) GetThreadsForUser(userId, teamId string, opts model.GetUserThreadsOpts) (*model.Threads, error) {
|
||||
type JoinedThread struct {
|
||||
PostId string
|
||||
ReplyCount int64
|
||||
LastReplyAt int64
|
||||
LastViewedAt int64
|
||||
Participants model.StringArray
|
||||
PostId string
|
||||
ReplyCount int64
|
||||
LastReplyAt int64
|
||||
LastViewedAt int64
|
||||
UnreadReplies int64
|
||||
UnreadMentions int64
|
||||
Participants model.StringArray
|
||||
model.Post
|
||||
}
|
||||
var threads []*JoinedThread
|
||||
|
||||
unreadRepliesQuery := "SELECT COUNT(Posts.Id) From Posts Where Posts.RootId=ThreadMemberships.PostId AND Posts.UpdateAt >= ThreadMemberships.LastViewed AND Posts.DeleteAt=0"
|
||||
fetchConditions := sq.And{
|
||||
sq.Or{sq.Eq{"Channels.TeamId": teamId}, sq.Eq{"Channels.TeamId": ""}},
|
||||
sq.Eq{"ThreadMemberships.UserId": userId},
|
||||
sq.Eq{"ThreadMemberships.Following": true},
|
||||
}
|
||||
if !opts.Deleted {
|
||||
fetchConditions = sq.And{fetchConditions, sq.Eq{"Posts.DeleteAt": 0}}
|
||||
}
|
||||
if opts.Since > 0 {
|
||||
fetchConditions = sq.And{fetchConditions, sq.GtOrEq{"Threads.LastReplyAt": opts.Since}}
|
||||
}
|
||||
|
||||
pageSize := uint64(30)
|
||||
if opts.PageSize == 0 {
|
||||
pageSize = opts.PageSize
|
||||
}
|
||||
query, args, _ := s.getQueryBuilder().
|
||||
Select("Threads.*, Posts.*, ThreadMemberships.LastViewed as LastViewedAt").
|
||||
From("Threads").
|
||||
LeftJoin("Posts ON Posts.Id = Threads.PostId").
|
||||
LeftJoin("ThreadMemberships ON ThreadMemberships.PostId = Threads.PostId").
|
||||
OrderBy("Threads.LastReplyAt DESC").
|
||||
Offset(pageSize * opts.Page).
|
||||
Limit(pageSize).
|
||||
Where(fetchConditions).ToSql()
|
||||
_, err := s.GetReplica().Select(&threads, query, args...)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to get threads for user id=%s", userId)
|
||||
|
||||
totalUnreadRepliesChan := make(chan store.StoreResult, 1)
|
||||
totalCountChan := make(chan store.StoreResult, 1)
|
||||
totalUnreadMentionsChan := make(chan store.StoreResult, 1)
|
||||
threadsChan := make(chan store.StoreResult, 1)
|
||||
go func() {
|
||||
repliesQuery, repliesQueryArgs, _ := s.getQueryBuilder().
|
||||
Select("COUNT(Posts.Id)").
|
||||
From("Posts").
|
||||
LeftJoin("ThreadMemberships ON Posts.RootId = ThreadMemberships.PostId").
|
||||
LeftJoin("Channels ON Posts.ChannelId = Channels.Id").
|
||||
Where(fetchConditions).
|
||||
Where("Posts.UpdateAt >= ThreadMemberships.LastViewed").ToSql()
|
||||
|
||||
totalUnreadReplies, err := s.GetMaster().SelectInt(repliesQuery, repliesQueryArgs...)
|
||||
totalUnreadRepliesChan <- store.StoreResult{Data: totalUnreadReplies, NErr: errors.Wrapf(err, "failed to get count replies on threads for user id=%s", userId)}
|
||||
close(totalUnreadRepliesChan)
|
||||
}()
|
||||
go func() {
|
||||
threadsQuery, threadsQueryArgs, _ := s.getQueryBuilder().
|
||||
Select("COUNT(ThreadMemberships.PostId)").
|
||||
LeftJoin("Threads ON Threads.PostId = ThreadMemberships.PostId").
|
||||
LeftJoin("Channels ON Threads.ChannelId = Channels.Id").
|
||||
From("ThreadMemberships").
|
||||
Where(fetchConditions).ToSql()
|
||||
|
||||
totalCount, err := s.GetMaster().SelectInt(threadsQuery, threadsQueryArgs...)
|
||||
totalCountChan <- store.StoreResult{Data: totalCount, NErr: err}
|
||||
close(totalCountChan)
|
||||
}()
|
||||
go func() {
|
||||
mentionsQuery, mentionsQueryArgs, _ := s.getQueryBuilder().
|
||||
Select("COALESCE(SUM(ThreadMemberships.UnreadMentions),0)").
|
||||
From("ThreadMemberships").
|
||||
LeftJoin("Threads ON Threads.PostId = ThreadMemberships.PostId").
|
||||
LeftJoin("Channels ON Threads.ChannelId = Channels.Id").
|
||||
Where(fetchConditions).ToSql()
|
||||
totalUnreadMentions, err := s.GetMaster().SelectInt(mentionsQuery, mentionsQueryArgs...)
|
||||
totalUnreadMentionsChan <- store.StoreResult{Data: totalUnreadMentions, NErr: err}
|
||||
close(totalUnreadMentionsChan)
|
||||
}()
|
||||
go func() {
|
||||
newFetchConditions := fetchConditions
|
||||
if !opts.Deleted {
|
||||
newFetchConditions = sq.And{fetchConditions, sq.Eq{"Posts.DeleteAt": 0}}
|
||||
}
|
||||
if opts.Since > 0 {
|
||||
newFetchConditions = sq.And{newFetchConditions, sq.GtOrEq{"Threads.LastReplyAt": opts.Since}}
|
||||
}
|
||||
|
||||
var threads []*JoinedThread
|
||||
query, args, _ := s.getQueryBuilder().
|
||||
Select("Threads.*, Posts.*, ThreadMemberships.LastViewed as LastViewedAt, ThreadMemberships.UnreadMentions as UnreadMentions").
|
||||
From("Threads").
|
||||
Column(sq.Alias(sq.Expr(unreadRepliesQuery), "UnreadReplies")).
|
||||
LeftJoin("Posts ON Posts.Id = Threads.PostId").
|
||||
LeftJoin("Channels ON Posts.ChannelId = Channels.Id").
|
||||
LeftJoin("ThreadMemberships ON ThreadMemberships.PostId = Threads.PostId").
|
||||
Where(newFetchConditions).
|
||||
OrderBy("Threads.LastReplyAt DESC").
|
||||
Offset(pageSize * opts.Page).
|
||||
Limit(pageSize).ToSql()
|
||||
_, err := s.GetReplica().Select(&threads, query, args...)
|
||||
threadsChan <- store.StoreResult{Data: threads, NErr: err}
|
||||
close(threadsChan)
|
||||
}()
|
||||
|
||||
threadsResult := <-threadsChan
|
||||
if threadsResult.NErr != nil {
|
||||
return nil, threadsResult.NErr
|
||||
}
|
||||
threads := threadsResult.Data.([]*JoinedThread)
|
||||
|
||||
totalUnreadMentionsResult := <-totalUnreadMentionsChan
|
||||
if totalUnreadMentionsResult.NErr != nil {
|
||||
return nil, totalUnreadMentionsResult.NErr
|
||||
}
|
||||
totalUnreadMentions := totalUnreadMentionsResult.Data.(int64)
|
||||
|
||||
totalCountResult := <-totalCountChan
|
||||
if totalCountResult.NErr != nil {
|
||||
return nil, totalCountResult.NErr
|
||||
}
|
||||
totalCount := totalCountResult.Data.(int64)
|
||||
|
||||
totalUnreadRepliesResult := <-totalUnreadRepliesChan
|
||||
if totalUnreadRepliesResult.NErr != nil {
|
||||
return nil, totalUnreadRepliesResult.NErr
|
||||
}
|
||||
totalUnreadReplies := totalUnreadRepliesResult.Data.(int64)
|
||||
|
||||
var userIds []string
|
||||
userIdMap := map[string]bool{}
|
||||
@@ -159,9 +234,8 @@ func (s *SqlThreadStore) GetThreadsForUser(userId string, opts model.GetUserThre
|
||||
}
|
||||
var users []*model.User
|
||||
if opts.Extended {
|
||||
query, args, _ = s.getQueryBuilder().Select("*").From("Users").Where(sq.Eq{"Id": userIds}).ToSql()
|
||||
_, err = s.GetReplica().Select(&users, query, args...)
|
||||
if err != nil {
|
||||
query, args, _ := s.getQueryBuilder().Select("*").From("Users").Where(sq.Eq{"Id": userIds}).ToSql()
|
||||
if _, err := s.GetReplica().Select(&users, query, args...); err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to get threads for user id=%s", userId)
|
||||
}
|
||||
} else {
|
||||
@@ -171,8 +245,10 @@ func (s *SqlThreadStore) GetThreadsForUser(userId string, opts model.GetUserThre
|
||||
}
|
||||
|
||||
result := &model.Threads{
|
||||
Total: 0,
|
||||
Threads: nil,
|
||||
Total: totalCount,
|
||||
Threads: nil,
|
||||
TotalUnreadMentions: totalUnreadMentions,
|
||||
TotalUnreadReplies: totalUnreadReplies,
|
||||
}
|
||||
|
||||
for _, thread := range threads {
|
||||
@@ -191,20 +267,37 @@ func (s *SqlThreadStore) GetThreadsForUser(userId string, opts model.GetUserThre
|
||||
participants = append(participants, participant)
|
||||
}
|
||||
result.Threads = append(result.Threads, &model.ThreadResponse{
|
||||
PostId: thread.PostId,
|
||||
ReplyCount: thread.ReplyCount,
|
||||
LastReplyAt: thread.LastReplyAt,
|
||||
LastViewedAt: thread.LastViewedAt,
|
||||
Participants: participants,
|
||||
Post: &thread.Post,
|
||||
PostId: thread.PostId,
|
||||
ReplyCount: thread.ReplyCount,
|
||||
LastReplyAt: thread.LastReplyAt,
|
||||
LastViewedAt: thread.LastViewedAt,
|
||||
UnreadReplies: thread.UnreadReplies,
|
||||
UnreadMentions: thread.UnreadMentions,
|
||||
Participants: participants,
|
||||
Post: &thread.Post,
|
||||
})
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *SqlThreadStore) MarkAllAsRead(userId string, timestamp int64) error {
|
||||
query, args, _ := s.getQueryBuilder().Update("ThreadMemberships").Where(sq.Eq{"UserId": userId}).Set("LastViewed", timestamp).ToSql()
|
||||
func (s *SqlThreadStore) MarkAllAsRead(userId, teamId string) error {
|
||||
memberships, err := s.GetMembershipsForUser(userId, teamId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var membershipIds []string
|
||||
for _, m := range memberships {
|
||||
membershipIds = append(membershipIds, m.PostId)
|
||||
}
|
||||
timestamp := model.GetMillis()
|
||||
query, args, _ := s.getQueryBuilder().
|
||||
Update("ThreadMemberships").
|
||||
Where(sq.Eq{"PostId": membershipIds}).
|
||||
Where(sq.Eq{"UserId": userId}).
|
||||
Set("LastViewed", timestamp).
|
||||
Set("UnreadMentions", 0).
|
||||
ToSql()
|
||||
if _, err := s.GetMaster().Exec(query, args...); err != nil {
|
||||
return errors.Wrapf(err, "failed to update thread read state for user id=%s", userId)
|
||||
}
|
||||
@@ -212,7 +305,11 @@ func (s *SqlThreadStore) MarkAllAsRead(userId string, timestamp int64) error {
|
||||
}
|
||||
|
||||
func (s *SqlThreadStore) MarkAsRead(userId, threadId string, timestamp int64) error {
|
||||
query, args, _ := s.getQueryBuilder().Update("ThreadMemberships").Where(sq.Eq{"UserId": userId}, sq.Eq{"PostId": threadId}).Set("LastViewed", timestamp).ToSql()
|
||||
query, args, _ := s.getQueryBuilder().
|
||||
Update("ThreadMemberships").
|
||||
Where(sq.Eq{"UserId": userId}, sq.Eq{"PostId": threadId}).
|
||||
Set("LastViewed", timestamp).
|
||||
ToSql()
|
||||
if _, err := s.GetMaster().Exec(query, args...); err != nil {
|
||||
return errors.Wrapf(err, "failed to update thread read state for user id=%s thread_id=%v", userId, threadId)
|
||||
}
|
||||
@@ -244,9 +341,19 @@ func (s *SqlThreadStore) UpdateMembership(membership *model.ThreadMembership) (*
|
||||
return membership, nil
|
||||
}
|
||||
|
||||
func (s *SqlThreadStore) GetMembershipsForUser(userId string) ([]*model.ThreadMembership, error) {
|
||||
func (s *SqlThreadStore) GetMembershipsForUser(userId, teamId string) ([]*model.ThreadMembership, error) {
|
||||
var memberships []*model.ThreadMembership
|
||||
_, err := s.GetReplica().Select(&memberships, "SELECT * from ThreadMemberships WHERE UserId = :UserId", map[string]interface{}{"UserId": userId})
|
||||
|
||||
query, args, _ := s.getQueryBuilder().
|
||||
Select("ThreadMemberships.*").
|
||||
Join("Threads ON Threads.PostId = ThreadMemberships.PostId").
|
||||
Join("Channels ON Threads.ChannelId = Channels.Id").
|
||||
From("ThreadMemberships").
|
||||
Where(sq.Or{sq.Eq{"Channels.TeamId": teamId}, sq.Eq{"Channels.TeamId": ""}}).
|
||||
Where(sq.Eq{"ThreadMemberships.UserId": userId}).
|
||||
ToSql()
|
||||
|
||||
_, err := s.GetReplica().Select(&memberships, query, args...)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to get thread membership with userid=%s", userId)
|
||||
}
|
||||
|
||||
@@ -251,16 +251,16 @@ type ThreadStore interface {
|
||||
Save(thread *model.Thread) (*model.Thread, error)
|
||||
Update(thread *model.Thread) (*model.Thread, error)
|
||||
Get(id string) (*model.Thread, error)
|
||||
GetThreadsForUser(userId string, opts model.GetUserThreadsOpts) (*model.Threads, error)
|
||||
GetThreadsForUser(userId, teamId string, opts model.GetUserThreadsOpts) (*model.Threads, error)
|
||||
Delete(postId string) error
|
||||
GetPosts(threadId string, since int64) ([]*model.Post, error)
|
||||
|
||||
MarkAllAsRead(userId string, timestamp int64) error
|
||||
MarkAllAsRead(userId, teamId string) error
|
||||
MarkAsRead(userId, threadId string, timestamp int64) error
|
||||
|
||||
SaveMembership(membership *model.ThreadMembership) (*model.ThreadMembership, error)
|
||||
UpdateMembership(membership *model.ThreadMembership) (*model.ThreadMembership, error)
|
||||
GetMembershipsForUser(userId string) ([]*model.ThreadMembership, error)
|
||||
GetMembershipsForUser(userId, teamId string) ([]*model.ThreadMembership, error)
|
||||
GetMembershipForUser(userId, postId string) (*model.ThreadMembership, error)
|
||||
DeleteMembershipForUser(userId, postId string) error
|
||||
CreateMembershipIfNeeded(userId, postId string, following, incrementMentions, updateFollowing bool) error
|
||||
|
||||
@@ -125,13 +125,13 @@ func (_m *ThreadStore) GetMembershipForUser(userId string, postId string) (*mode
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetMembershipsForUser provides a mock function with given fields: userId
|
||||
func (_m *ThreadStore) GetMembershipsForUser(userId string) ([]*model.ThreadMembership, error) {
|
||||
ret := _m.Called(userId)
|
||||
// GetMembershipsForUser provides a mock function with given fields: userId, teamId
|
||||
func (_m *ThreadStore) GetMembershipsForUser(userId string, teamId string) ([]*model.ThreadMembership, error) {
|
||||
ret := _m.Called(userId, teamId)
|
||||
|
||||
var r0 []*model.ThreadMembership
|
||||
if rf, ok := ret.Get(0).(func(string) []*model.ThreadMembership); ok {
|
||||
r0 = rf(userId)
|
||||
if rf, ok := ret.Get(0).(func(string, string) []*model.ThreadMembership); ok {
|
||||
r0 = rf(userId, teamId)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*model.ThreadMembership)
|
||||
@@ -139,8 +139,8 @@ func (_m *ThreadStore) GetMembershipsForUser(userId string) ([]*model.ThreadMemb
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = rf(userId)
|
||||
if rf, ok := ret.Get(1).(func(string, string) error); ok {
|
||||
r1 = rf(userId, teamId)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
@@ -171,13 +171,13 @@ func (_m *ThreadStore) GetPosts(threadId string, since int64) ([]*model.Post, er
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetThreadsForUser provides a mock function with given fields: userId, opts
|
||||
func (_m *ThreadStore) GetThreadsForUser(userId string, opts model.GetUserThreadsOpts) (*model.Threads, error) {
|
||||
ret := _m.Called(userId, opts)
|
||||
// GetThreadsForUser provides a mock function with given fields: userId, teamId, opts
|
||||
func (_m *ThreadStore) GetThreadsForUser(userId string, teamId string, opts model.GetUserThreadsOpts) (*model.Threads, error) {
|
||||
ret := _m.Called(userId, teamId, opts)
|
||||
|
||||
var r0 *model.Threads
|
||||
if rf, ok := ret.Get(0).(func(string, model.GetUserThreadsOpts) *model.Threads); ok {
|
||||
r0 = rf(userId, opts)
|
||||
if rf, ok := ret.Get(0).(func(string, string, model.GetUserThreadsOpts) *model.Threads); ok {
|
||||
r0 = rf(userId, teamId, opts)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.Threads)
|
||||
@@ -185,8 +185,8 @@ func (_m *ThreadStore) GetThreadsForUser(userId string, opts model.GetUserThread
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, model.GetUserThreadsOpts) error); ok {
|
||||
r1 = rf(userId, opts)
|
||||
if rf, ok := ret.Get(1).(func(string, string, model.GetUserThreadsOpts) error); ok {
|
||||
r1 = rf(userId, teamId, opts)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
@@ -194,13 +194,13 @@ func (_m *ThreadStore) GetThreadsForUser(userId string, opts model.GetUserThread
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MarkAllAsRead provides a mock function with given fields: userId, timestamp
|
||||
func (_m *ThreadStore) MarkAllAsRead(userId string, timestamp int64) error {
|
||||
ret := _m.Called(userId, timestamp)
|
||||
// MarkAllAsRead provides a mock function with given fields: userId, teamId
|
||||
func (_m *ThreadStore) MarkAllAsRead(userId string, teamId string) error {
|
||||
ret := _m.Called(userId, teamId)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(string, int64) error); ok {
|
||||
r0 = rf(userId, timestamp)
|
||||
if rf, ok := ret.Get(0).(func(string, string) error); ok {
|
||||
r0 = rf(userId, teamId)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
@@ -7000,10 +7000,10 @@ func (s *TimerLayerThreadStore) GetMembershipForUser(userId string, postId strin
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerThreadStore) GetMembershipsForUser(userId string) ([]*model.ThreadMembership, error) {
|
||||
func (s *TimerLayerThreadStore) GetMembershipsForUser(userId string, teamId string) ([]*model.ThreadMembership, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.ThreadStore.GetMembershipsForUser(userId)
|
||||
result, err := s.ThreadStore.GetMembershipsForUser(userId, teamId)
|
||||
|
||||
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
||||
if s.Root.Metrics != nil {
|
||||
@@ -7032,10 +7032,10 @@ func (s *TimerLayerThreadStore) GetPosts(threadId string, since int64) ([]*model
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerThreadStore) GetThreadsForUser(userId string, opts model.GetUserThreadsOpts) (*model.Threads, error) {
|
||||
func (s *TimerLayerThreadStore) GetThreadsForUser(userId string, teamId string, opts model.GetUserThreadsOpts) (*model.Threads, error) {
|
||||
start := timemodule.Now()
|
||||
|
||||
result, err := s.ThreadStore.GetThreadsForUser(userId, opts)
|
||||
result, err := s.ThreadStore.GetThreadsForUser(userId, teamId, opts)
|
||||
|
||||
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
||||
if s.Root.Metrics != nil {
|
||||
@@ -7048,10 +7048,10 @@ func (s *TimerLayerThreadStore) GetThreadsForUser(userId string, opts model.GetU
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (s *TimerLayerThreadStore) MarkAllAsRead(userId string, timestamp int64) error {
|
||||
func (s *TimerLayerThreadStore) MarkAllAsRead(userId string, teamId string) error {
|
||||
start := timemodule.Now()
|
||||
|
||||
err := s.ThreadStore.MarkAllAsRead(userId, timestamp)
|
||||
err := s.ThreadStore.MarkAllAsRead(userId, teamId)
|
||||
|
||||
elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second)
|
||||
if s.Root.Metrics != nil {
|
||||
|
||||
Ссылка в новой задаче
Block a user