Simplify thread_store/GetThreadForUser (#21588)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
534a9bcbf0
Коммит
b9d00a1f28
@@ -787,7 +787,7 @@ type AppIface interface {
|
||||
GetTeamsUnreadForUser(excludeTeamId string, userID string, includeCollapsedThreads bool) ([]*model.TeamUnread, *model.AppError)
|
||||
GetTeamsUsage() (*model.TeamsUsage, *model.AppError)
|
||||
GetTermsOfService(id string) (*model.TermsOfService, *model.AppError)
|
||||
GetThreadForUser(teamID string, threadMembership *model.ThreadMembership, extended bool) (*model.ThreadResponse, *model.AppError)
|
||||
GetThreadForUser(threadMembership *model.ThreadMembership, extended bool) (*model.ThreadResponse, *model.AppError)
|
||||
GetThreadMembershipForUser(userId, threadId string) (*model.ThreadMembership, *model.AppError)
|
||||
GetThreadMembershipsForUser(userID, teamID string) ([]*model.ThreadMembership, error)
|
||||
GetThreadsForUser(userID, teamID string, options model.GetUserThreadsOpts) (*model.Threads, *model.AppError)
|
||||
|
||||
@@ -2709,7 +2709,7 @@ func (a *App) markChannelAsUnreadFromPostCRTUnsupported(c request.CTX, postID st
|
||||
if mErr != nil {
|
||||
return nil, model.NewAppError("MarkChannelAsUnreadFromPost", "app.channel.update_last_viewed_at_post.app_error", nil, "", http.StatusInternalServerError).Wrap(mErr)
|
||||
}
|
||||
thread, mErr := a.Srv().Store().Thread().GetThreadForUser(channel.TeamId, threadMembership, true)
|
||||
thread, mErr := a.Srv().Store().Thread().GetThreadForUser(threadMembership, true)
|
||||
if mErr != nil {
|
||||
return nil, model.NewAppError("MarkChannelAsUnreadFromPost", "app.channel.update_last_viewed_at_post.app_error", nil, "", http.StatusInternalServerError).Wrap(mErr)
|
||||
}
|
||||
|
||||
@@ -2263,7 +2263,7 @@ func TestMarkChannelAsUnreadFromPostCollapsedThreadsTurnedOff(t *testing.T) {
|
||||
|
||||
threadMembership, err := th.App.GetThreadMembershipForUser(th.BasicUser.Id, rootPost1.Id)
|
||||
require.Nil(t, err)
|
||||
thread, err := th.App.GetThreadForUser(th.BasicTeam.Id, threadMembership, false)
|
||||
thread, err := th.App.GetThreadForUser(threadMembership, false)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, int64(2), thread.UnreadMentions)
|
||||
require.Equal(t, int64(3), thread.UnreadReplies)
|
||||
|
||||
@@ -596,7 +596,7 @@ func (a *App) SendNotifications(c request.CTX, post *model.Post, team *model.Tea
|
||||
}
|
||||
threadMembership = tm
|
||||
}
|
||||
userThread, err := a.Srv().Store().Thread().GetThreadForUser(channel.TeamId, threadMembership, true)
|
||||
userThread, err := a.Srv().Store().Thread().GetThreadForUser(threadMembership, true)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "cannot get thread %q for user %q", post.RootId, uid)
|
||||
}
|
||||
|
||||
@@ -2769,7 +2769,7 @@ func TestReplyPostNotificationsWithCRT(t *testing.T) {
|
||||
|
||||
threadMembership, appErr := th.App.GetThreadMembershipForUser(u2.Id, rpost.Id)
|
||||
require.Nil(t, appErr)
|
||||
thread, appErr := th.App.GetThreadForUser(c1.TeamId, threadMembership, false)
|
||||
thread, appErr := th.App.GetThreadForUser(threadMembership, false)
|
||||
require.Nil(t, appErr)
|
||||
// Then: with notifications set to "all" we should
|
||||
// not see a mention badge
|
||||
|
||||
@@ -9799,7 +9799,7 @@ func (a *OpenTracingAppLayer) GetTermsOfService(id string) (*model.TermsOfServic
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetThreadForUser(teamID string, threadMembership *model.ThreadMembership, extended bool) (*model.ThreadResponse, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetThreadForUser(threadMembership *model.ThreadMembership, extended bool) (*model.ThreadResponse, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetThreadForUser")
|
||||
|
||||
@@ -9811,7 +9811,7 @@ func (a *OpenTracingAppLayer) GetThreadForUser(teamID string, threadMembership *
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1 := a.app.GetThreadForUser(teamID, threadMembership, extended)
|
||||
resultVar0, resultVar1 := a.app.GetThreadForUser(threadMembership, extended)
|
||||
|
||||
if resultVar1 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar1))
|
||||
|
||||
@@ -2327,7 +2327,7 @@ func TestFollowThreadSkipsParticipants(t *testing.T) {
|
||||
|
||||
threadMembership, err := th.App.GetThreadMembershipForUser(user.Id, p1.Id)
|
||||
require.Nil(t, err)
|
||||
thread, err := th.App.GetThreadForUser(th.BasicTeam.Id, threadMembership, false)
|
||||
thread, err := th.App.GetThreadForUser(threadMembership, false)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, thread.Participants, 1) // length should be 1, the original poster, since sysadmin was just mentioned but didn't post
|
||||
|
||||
@@ -2336,7 +2336,7 @@ func TestFollowThreadSkipsParticipants(t *testing.T) {
|
||||
|
||||
threadMembership, err = th.App.GetThreadMembershipForUser(user.Id, p1.Id)
|
||||
require.Nil(t, err)
|
||||
thread, err = th.App.GetThreadForUser(th.BasicTeam.Id, threadMembership, false)
|
||||
thread, err = th.App.GetThreadForUser(threadMembership, false)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, thread.Participants, 2) // length should be 2, the original poster and sysadmin, since sysadmin participated now
|
||||
|
||||
@@ -2345,7 +2345,7 @@ func TestFollowThreadSkipsParticipants(t *testing.T) {
|
||||
|
||||
threadMembership, err = th.App.GetThreadMembershipForUser(user2.Id, p1.Id)
|
||||
require.Nil(t, err)
|
||||
thread, err = th.App.GetThreadForUser(th.BasicTeam.Id, threadMembership, false)
|
||||
thread, err = th.App.GetThreadForUser(threadMembership, false)
|
||||
require.Nil(t, err)
|
||||
require.Len(t, thread.Participants, 2) // length should be 2, since follow shouldn't update participant list, only user1 and sysadmin are participants
|
||||
for _, p := range thread.Participants {
|
||||
|
||||
@@ -2468,8 +2468,8 @@ func (a *App) GetThreadMembershipForUser(userId, threadId string) (*model.Thread
|
||||
return threadMembership, nil
|
||||
}
|
||||
|
||||
func (a *App) GetThreadForUser(teamID string, threadMembership *model.ThreadMembership, extended bool) (*model.ThreadResponse, *model.AppError) {
|
||||
thread, err := a.Srv().Store().Thread().GetThreadForUser(teamID, threadMembership, extended)
|
||||
func (a *App) GetThreadForUser(threadMembership *model.ThreadMembership, extended bool) (*model.ThreadResponse, *model.AppError) {
|
||||
thread, err := a.Srv().Store().Thread().GetThreadForUser(threadMembership, extended)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetThreadForUser", "app.user.get_threads_for_user.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
@@ -2551,7 +2551,7 @@ func (a *App) UpdateThreadFollowForUserFromChannelAdd(c request.CTX, userID, tea
|
||||
}
|
||||
|
||||
message := model.NewWebSocketEvent(model.WebsocketEventThreadUpdated, teamID, "", userID, nil, "")
|
||||
userThread, err := a.Srv().Store().Thread().GetThreadForUser(teamID, tm, true)
|
||||
userThread, err := a.Srv().Store().Thread().GetThreadForUser(tm, true)
|
||||
|
||||
if err != nil {
|
||||
var errNotFound *store.ErrNotFound
|
||||
@@ -2633,7 +2633,7 @@ func (a *App) UpdateThreadReadForUser(c request.CTX, currentSessionId, userID, t
|
||||
if nErr != nil {
|
||||
return nil, model.NewAppError("UpdateThreadReadForUser", "app.user.update_thread_read_for_user.app_error", nil, "", http.StatusInternalServerError).Wrap(nErr)
|
||||
}
|
||||
thread, err := a.GetThreadForUser(teamID, membership, false)
|
||||
thread, err := a.GetThreadForUser(membership, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user