MM-30304 - Handle collapsed threads in page apis (#17064)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
f2e27a39da
Коммит
4aa6c863c3
@@ -44,7 +44,7 @@ type AppIface interface {
|
||||
// AddCursorIdsForPostList adds NextPostId and PrevPostId as cursor to the PostList.
|
||||
// The conditional blocks ensure that it sets those cursor IDs immediately as afterPost, beforePost or empty,
|
||||
// and only query to database whenever necessary.
|
||||
AddCursorIdsForPostList(originalList *model.PostList, afterPost, beforePost string, since int64, page, perPage int)
|
||||
AddCursorIdsForPostList(originalList *model.PostList, afterPost, beforePost string, since int64, page, perPage int, collapsedThreads bool)
|
||||
// AddPublicKey will add plugin public key to the config. Overwrites the previous file
|
||||
AddPublicKey(name string, key io.Reader) *model.AppError
|
||||
// Caller must close the first return value
|
||||
@@ -610,7 +610,7 @@ type AppIface interface {
|
||||
GetMessageForNotification(post *model.Post, translateFunc i18n.TranslateFunc) string
|
||||
GetMultipleEmojiByName(names []string) ([]*model.Emoji, *model.AppError)
|
||||
GetNewUsersForTeamPage(teamID string, page, perPage int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, *model.AppError)
|
||||
GetNextPostIdFromPostList(postList *model.PostList) string
|
||||
GetNextPostIdFromPostList(postList *model.PostList, collapsedThreads bool) string
|
||||
GetNotificationNameFormat(user *model.User) string
|
||||
GetNumberOfChannelsOnTeam(teamID string) (int, *model.AppError)
|
||||
GetOAuthAccessTokenForCodeFlow(clientId, grantType, redirectUri, code, secret, refreshToken string) (*model.AccessResponse, *model.AppError)
|
||||
@@ -636,9 +636,9 @@ type AppIface interface {
|
||||
GetPinnedPosts(channelID string) (*model.PostList, *model.AppError)
|
||||
GetPluginKey(pluginID string, key string) ([]byte, *model.AppError)
|
||||
GetPlugins() (*model.PluginsResponse, *model.AppError)
|
||||
GetPostAfterTime(channelID string, time int64) (*model.Post, *model.AppError)
|
||||
GetPostIdAfterTime(channelID string, time int64) (string, *model.AppError)
|
||||
GetPostIdBeforeTime(channelID string, time int64) (string, *model.AppError)
|
||||
GetPostAfterTime(channelID string, time int64, collapsedThreads bool) (*model.Post, *model.AppError)
|
||||
GetPostIdAfterTime(channelID string, time int64, collapsedThreads bool) (string, *model.AppError)
|
||||
GetPostIdBeforeTime(channelID string, time int64, collapsedThreads bool) (string, *model.AppError)
|
||||
GetPostThread(postID string, skipFetchThreads, collapsedThreads, collapsedThreadsExtended bool) (*model.PostList, *model.AppError)
|
||||
GetPosts(channelID string, offset int, limit int) (*model.PostList, *model.AppError)
|
||||
GetPostsAfterPost(options model.GetPostsOptions) (*model.PostList, *model.AppError)
|
||||
@@ -651,7 +651,7 @@ type AppIface interface {
|
||||
GetPreferenceByCategoryAndNameForUser(userID string, category string, preferenceName string) (*model.Preference, *model.AppError)
|
||||
GetPreferenceByCategoryForUser(userID string, category string) (model.Preferences, *model.AppError)
|
||||
GetPreferencesForUser(userID string) (model.Preferences, *model.AppError)
|
||||
GetPrevPostIdFromPostList(postList *model.PostList) string
|
||||
GetPrevPostIdFromPostList(postList *model.PostList, collapsedThreads bool) string
|
||||
GetPrivateChannelsForTeam(teamID string, offset int, limit int) (*model.ChannelList, *model.AppError)
|
||||
GetProfileImage(user *model.User) ([]byte, bool, *model.AppError)
|
||||
GetPublicChannelsByIdsForTeam(teamID string, channelIDs []string) (*model.ChannelList, *model.AppError)
|
||||
|
||||
@@ -132,7 +132,7 @@ func (a *OpenTracingAppLayer) AddConfigListener(listener func(*model.Config, *mo
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) AddCursorIdsForPostList(originalList *model.PostList, afterPost string, beforePost string, since int64, page int, perPage int) {
|
||||
func (a *OpenTracingAppLayer) AddCursorIdsForPostList(originalList *model.PostList, afterPost string, beforePost string, since int64, page int, perPage int, collapsedThreads bool) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.AddCursorIdsForPostList")
|
||||
|
||||
@@ -144,7 +144,7 @@ func (a *OpenTracingAppLayer) AddCursorIdsForPostList(originalList *model.PostLi
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
a.app.AddCursorIdsForPostList(originalList, afterPost, beforePost, since, page, perPage)
|
||||
a.app.AddCursorIdsForPostList(originalList, afterPost, beforePost, since, page, perPage, collapsedThreads)
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) AddDirectChannels(teamID string, user *model.User) *model.AppError {
|
||||
@@ -6432,7 +6432,7 @@ func (a *OpenTracingAppLayer) GetNewUsersForTeamPage(teamID string, page int, pe
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetNextPostIdFromPostList(postList *model.PostList) string {
|
||||
func (a *OpenTracingAppLayer) GetNextPostIdFromPostList(postList *model.PostList, collapsedThreads bool) string {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetNextPostIdFromPostList")
|
||||
|
||||
@@ -6444,7 +6444,7 @@ func (a *OpenTracingAppLayer) GetNextPostIdFromPostList(postList *model.PostList
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0 := a.app.GetNextPostIdFromPostList(postList)
|
||||
resultVar0 := a.app.GetNextPostIdFromPostList(postList, collapsedThreads)
|
||||
|
||||
return resultVar0
|
||||
}
|
||||
@@ -7072,7 +7072,7 @@ func (a *OpenTracingAppLayer) GetPluginsEnvironment() *plugin.Environment {
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetPostAfterTime(channelID string, time int64) (*model.Post, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetPostAfterTime(channelID string, time int64, collapsedThreads bool) (*model.Post, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetPostAfterTime")
|
||||
|
||||
@@ -7084,7 +7084,7 @@ func (a *OpenTracingAppLayer) GetPostAfterTime(channelID string, time int64) (*m
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1 := a.app.GetPostAfterTime(channelID, time)
|
||||
resultVar0, resultVar1 := a.app.GetPostAfterTime(channelID, time, collapsedThreads)
|
||||
|
||||
if resultVar1 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar1))
|
||||
@@ -7094,7 +7094,7 @@ func (a *OpenTracingAppLayer) GetPostAfterTime(channelID string, time int64) (*m
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetPostIdAfterTime(channelID string, time int64) (string, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetPostIdAfterTime(channelID string, time int64, collapsedThreads bool) (string, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetPostIdAfterTime")
|
||||
|
||||
@@ -7106,7 +7106,7 @@ func (a *OpenTracingAppLayer) GetPostIdAfterTime(channelID string, time int64) (
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1 := a.app.GetPostIdAfterTime(channelID, time)
|
||||
resultVar0, resultVar1 := a.app.GetPostIdAfterTime(channelID, time, collapsedThreads)
|
||||
|
||||
if resultVar1 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar1))
|
||||
@@ -7116,7 +7116,7 @@ func (a *OpenTracingAppLayer) GetPostIdAfterTime(channelID string, time int64) (
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetPostIdBeforeTime(channelID string, time int64) (string, *model.AppError) {
|
||||
func (a *OpenTracingAppLayer) GetPostIdBeforeTime(channelID string, time int64, collapsedThreads bool) (string, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetPostIdBeforeTime")
|
||||
|
||||
@@ -7128,7 +7128,7 @@ func (a *OpenTracingAppLayer) GetPostIdBeforeTime(channelID string, time int64)
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1 := a.app.GetPostIdBeforeTime(channelID, time)
|
||||
resultVar0, resultVar1 := a.app.GetPostIdBeforeTime(channelID, time, collapsedThreads)
|
||||
|
||||
if resultVar1 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar1))
|
||||
@@ -7397,7 +7397,7 @@ func (a *OpenTracingAppLayer) GetPreferencesForUser(userID string) (model.Prefer
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetPrevPostIdFromPostList(postList *model.PostList) string {
|
||||
func (a *OpenTracingAppLayer) GetPrevPostIdFromPostList(postList *model.PostList, collapsedThreads bool) string {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetPrevPostIdFromPostList")
|
||||
|
||||
@@ -7409,7 +7409,7 @@ func (a *OpenTracingAppLayer) GetPrevPostIdFromPostList(postList *model.PostList
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0 := a.app.GetPrevPostIdFromPostList(postList)
|
||||
resultVar0 := a.app.GetPrevPostIdFromPostList(postList, collapsedThreads)
|
||||
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
28
app/post.go
28
app/post.go
@@ -876,8 +876,8 @@ func (a *App) GetPostsAroundPost(before bool, options model.GetPostsOptions) (*m
|
||||
return postList, nil
|
||||
}
|
||||
|
||||
func (a *App) GetPostAfterTime(channelID string, time int64) (*model.Post, *model.AppError) {
|
||||
post, err := a.Srv().Store.Post().GetPostAfterTime(channelID, time)
|
||||
func (a *App) GetPostAfterTime(channelID string, time int64, collapsedThreads bool) (*model.Post, *model.AppError) {
|
||||
post, err := a.Srv().Store.Post().GetPostAfterTime(channelID, time, collapsedThreads)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetPostAfterTime", "app.post.get_post_after_time.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -885,8 +885,8 @@ func (a *App) GetPostAfterTime(channelID string, time int64) (*model.Post, *mode
|
||||
return post, nil
|
||||
}
|
||||
|
||||
func (a *App) GetPostIdAfterTime(channelID string, time int64) (string, *model.AppError) {
|
||||
postID, err := a.Srv().Store.Post().GetPostIdAfterTime(channelID, time)
|
||||
func (a *App) GetPostIdAfterTime(channelID string, time int64, collapsedThreads bool) (string, *model.AppError) {
|
||||
postID, err := a.Srv().Store.Post().GetPostIdAfterTime(channelID, time, collapsedThreads)
|
||||
if err != nil {
|
||||
return "", model.NewAppError("GetPostIdAfterTime", "app.post.get_post_id_around.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -894,8 +894,8 @@ func (a *App) GetPostIdAfterTime(channelID string, time int64) (string, *model.A
|
||||
return postID, nil
|
||||
}
|
||||
|
||||
func (a *App) GetPostIdBeforeTime(channelID string, time int64) (string, *model.AppError) {
|
||||
postID, err := a.Srv().Store.Post().GetPostIdBeforeTime(channelID, time)
|
||||
func (a *App) GetPostIdBeforeTime(channelID string, time int64, collapsedThreads bool) (string, *model.AppError) {
|
||||
postID, err := a.Srv().Store.Post().GetPostIdBeforeTime(channelID, time, collapsedThreads)
|
||||
if err != nil {
|
||||
return "", model.NewAppError("GetPostIdBeforeTime", "app.post.get_post_id_around.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -903,11 +903,11 @@ func (a *App) GetPostIdBeforeTime(channelID string, time int64) (string, *model.
|
||||
return postID, nil
|
||||
}
|
||||
|
||||
func (a *App) GetNextPostIdFromPostList(postList *model.PostList) string {
|
||||
func (a *App) GetNextPostIdFromPostList(postList *model.PostList, collapsedThreads bool) string {
|
||||
if len(postList.Order) > 0 {
|
||||
firstPostId := postList.Order[0]
|
||||
firstPost := postList.Posts[firstPostId]
|
||||
nextPostId, err := a.GetPostIdAfterTime(firstPost.ChannelId, firstPost.CreateAt)
|
||||
nextPostId, err := a.GetPostIdAfterTime(firstPost.ChannelId, firstPost.CreateAt, collapsedThreads)
|
||||
if err != nil {
|
||||
mlog.Warn("GetNextPostIdFromPostList: failed in getting next post", mlog.Err(err))
|
||||
}
|
||||
@@ -918,11 +918,11 @@ func (a *App) GetNextPostIdFromPostList(postList *model.PostList) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (a *App) GetPrevPostIdFromPostList(postList *model.PostList) string {
|
||||
func (a *App) GetPrevPostIdFromPostList(postList *model.PostList, collapsedThreads bool) string {
|
||||
if len(postList.Order) > 0 {
|
||||
lastPostId := postList.Order[len(postList.Order)-1]
|
||||
lastPost := postList.Posts[lastPostId]
|
||||
previousPostId, err := a.GetPostIdBeforeTime(lastPost.ChannelId, lastPost.CreateAt)
|
||||
previousPostId, err := a.GetPostIdBeforeTime(lastPost.ChannelId, lastPost.CreateAt, collapsedThreads)
|
||||
if err != nil {
|
||||
mlog.Warn("GetPrevPostIdFromPostList: failed in getting previous post", mlog.Err(err))
|
||||
}
|
||||
@@ -936,7 +936,7 @@ func (a *App) GetPrevPostIdFromPostList(postList *model.PostList) string {
|
||||
// AddCursorIdsForPostList adds NextPostId and PrevPostId as cursor to the PostList.
|
||||
// The conditional blocks ensure that it sets those cursor IDs immediately as afterPost, beforePost or empty,
|
||||
// and only query to database whenever necessary.
|
||||
func (a *App) AddCursorIdsForPostList(originalList *model.PostList, afterPost, beforePost string, since int64, page, perPage int) {
|
||||
func (a *App) AddCursorIdsForPostList(originalList *model.PostList, afterPost, beforePost string, since int64, page, perPage int, collapsedThreads bool) {
|
||||
prevPostIdSet := false
|
||||
prevPostId := ""
|
||||
nextPostIdSet := false
|
||||
@@ -966,11 +966,11 @@ func (a *App) AddCursorIdsForPostList(originalList *model.PostList, afterPost, b
|
||||
}
|
||||
|
||||
if !nextPostIdSet {
|
||||
nextPostId = a.GetNextPostIdFromPostList(originalList)
|
||||
nextPostId = a.GetNextPostIdFromPostList(originalList, collapsedThreads)
|
||||
}
|
||||
|
||||
if !prevPostIdSet {
|
||||
prevPostId = a.GetPrevPostIdFromPostList(originalList)
|
||||
prevPostId = a.GetPrevPostIdFromPostList(originalList, collapsedThreads)
|
||||
}
|
||||
|
||||
originalList.NextPostId = nextPostId
|
||||
@@ -985,7 +985,7 @@ func (a *App) GetPostsForChannelAroundLastUnread(channelID, userID string, limit
|
||||
return model.NewPostList(), nil
|
||||
}
|
||||
|
||||
lastUnreadPostId, err := a.GetPostIdAfterTime(channelID, member.LastViewedAt)
|
||||
lastUnreadPostId, err := a.GetPostIdAfterTime(channelID, member.LastViewedAt, collapsedThreads)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if lastUnreadPostId == "" {
|
||||
|
||||
Ссылка в новой задаче
Block a user