MM-33544 is_following prop in getPosts API methods (#17093)

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Eli Yukelzon
2021-03-23 13:31:54 +02:00
коммит произвёл GitHub
родитель c0971970e9
Коммит 0cc72342de
18 изменённых файлов: 162 добавлений и 108 удалений

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

@@ -187,7 +187,7 @@ func (a *App) CreatePost(post *model.Post, channel *model.Channel, triggerWebhoo
if post.RootId != "" {
pchan = make(chan store.StoreResult, 1)
go func() {
r, pErr := a.Srv().Store.Post().Get(sqlstore.WithMaster(context.Background()), post.RootId, false, false, false)
r, pErr := a.Srv().Store.Post().Get(sqlstore.WithMaster(context.Background()), post.RootId, false, false, false, "")
pchan <- store.StoreResult{Data: r, NErr: pErr}
close(pchan)
}()
@@ -538,7 +538,7 @@ func (a *App) DeleteEphemeralPost(userID, postID string) {
func (a *App) UpdatePost(post *model.Post, safeUpdate bool) (*model.Post, *model.AppError) {
post.SanitizeProps()
postLists, nErr := a.Srv().Store.Post().Get(context.Background(), post.Id, false, false, false)
postLists, nErr := a.Srv().Store.Post().Get(context.Background(), post.Id, false, false, false, "")
if nErr != nil {
var nfErr *store.ErrNotFound
var invErr *store.ErrInvalidInput
@@ -742,8 +742,8 @@ func (a *App) GetSinglePost(postID string) (*model.Post, *model.AppError) {
return post, nil
}
func (a *App) GetPostThread(postID string, skipFetchThreads, collapsedThreads, collapsedThreadsExtended bool) (*model.PostList, *model.AppError) {
posts, err := a.Srv().Store.Post().Get(context.Background(), postID, skipFetchThreads, collapsedThreads, collapsedThreadsExtended)
func (a *App) GetPostThread(postID string, skipFetchThreads, collapsedThreads, collapsedThreadsExtended bool, userID string) (*model.PostList, *model.AppError) {
posts, err := a.Srv().Store.Post().Get(context.Background(), postID, skipFetchThreads, collapsedThreads, collapsedThreadsExtended, userID)
if err != nil {
var nfErr *store.ErrNotFound
var invErr *store.ErrInvalidInput
@@ -788,7 +788,7 @@ func (a *App) GetFlaggedPostsForChannel(userID, channelID string, offset int, li
}
func (a *App) GetPermalinkPost(postID string, userID string) (*model.PostList, *model.AppError) {
list, nErr := a.Srv().Store.Post().Get(context.Background(), postID, false, false, false)
list, nErr := a.Srv().Store.Post().Get(context.Background(), postID, false, false, false, userID)
if nErr != nil {
var nfErr *store.ErrNotFound
var invErr *store.ErrInvalidInput
@@ -987,7 +987,7 @@ func (a *App) GetPostsForChannelAroundLastUnread(channelID, userID string, limit
return model.NewPostList(), nil
}
postList, err := a.GetPostThread(lastUnreadPostId, skipFetchThreads, collapsedThreads, collapsedThreadsExtended)
postList, err := a.GetPostThread(lastUnreadPostId, skipFetchThreads, collapsedThreads, collapsedThreadsExtended, userID)
if err != nil {
return nil, err
}
@@ -995,13 +995,13 @@ func (a *App) GetPostsForChannelAroundLastUnread(channelID, userID string, limit
// channel organically, those replies will be added below.
postList.Order = []string{lastUnreadPostId}
if postListBefore, err := a.GetPostsBeforePost(model.GetPostsOptions{ChannelId: channelID, PostId: lastUnreadPostId, Page: PageDefault, PerPage: limitBefore, SkipFetchThreads: skipFetchThreads, CollapsedThreads: collapsedThreads, CollapsedThreadsExtended: collapsedThreadsExtended}); err != nil {
if postListBefore, err := a.GetPostsBeforePost(model.GetPostsOptions{ChannelId: channelID, PostId: lastUnreadPostId, Page: PageDefault, PerPage: limitBefore, SkipFetchThreads: skipFetchThreads, CollapsedThreads: collapsedThreads, CollapsedThreadsExtended: collapsedThreadsExtended, UserId: userID}); err != nil {
return nil, err
} else if postListBefore != nil {
postList.Extend(postListBefore)
}
if postListAfter, err := a.GetPostsAfterPost(model.GetPostsOptions{ChannelId: channelID, PostId: lastUnreadPostId, Page: PageDefault, PerPage: limitAfter - 1, SkipFetchThreads: skipFetchThreads, CollapsedThreads: collapsedThreads, CollapsedThreadsExtended: collapsedThreadsExtended}); err != nil {
if postListAfter, err := a.GetPostsAfterPost(model.GetPostsOptions{ChannelId: channelID, PostId: lastUnreadPostId, Page: PageDefault, PerPage: limitAfter - 1, SkipFetchThreads: skipFetchThreads, CollapsedThreads: collapsedThreads, CollapsedThreadsExtended: collapsedThreadsExtended, UserId: userID}); err != nil {
return nil, err
} else if postListAfter != nil {
postList.Extend(postListAfter)
@@ -1437,7 +1437,7 @@ func (a *App) countMentionsFromPost(user *model.User, post *model.Post) (int, *m
// A mapping of thread root IDs to whether or not a post in that thread mentions the user
mentionedByThread := make(map[string]bool)
thread, err := a.GetPostThread(post.Id, false, false, false)
thread, err := a.GetPostThread(post.Id, false, false, false, user.Id)
if err != nil {
return 0, err
}