MM-45494: Add endpoint for message history (#20945)

* add api url

* write sql in store

* update app and client golang driver

* update layers and tests

* change sql query sort

* update layers

* fix style

* fix style post_store.go

* fix comments

* add test for app/post_test.go

* update layers

* fix test

* fix style

* fix style again :)

* add permission check

* add additional checks and tests

* change from nil to empty

* update app-layers

* fix style

* add index for OriginalId for Posts table

* fix postgres query

* update migration file names

* update app-layers

* address PR reviews

* write tests for post store

* fix style

* Update file name

* Update file name 2

* Update file name 3

* Update file name 4

* change the error orders

* update migration file name

---------

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Sinan Sonmez (Chaush)
2023-02-07 15:30:37 +01:00
коммит произвёл GitHub
родитель eabf454764
Коммит 50fec7c892
19 изменённых файлов: 433 добавлений и 0 удалений

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

@@ -4017,6 +4017,27 @@ func (c *Client4) GetPostsByIds(postIds []string) ([]*Post, *Response, error) {
return list, BuildResponse(r), nil
}
// GetEditHistoryForPost gets a list of posts by taking a post ids
func (c *Client4) GetEditHistoryForPost(postId string) ([]*Post, *Response, error) {
js, err := json.Marshal(postId)
if err != nil {
return nil, nil, NewAppError("GetEditHistoryForPost", "api.marshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
}
r, err := c.DoAPIGet(c.postRoute(postId)+"/edit_history", string(js))
if err != nil {
return nil, BuildResponse(r), err
}
defer closeBody(r)
var list []*Post
if r.StatusCode == http.StatusNotModified {
return list, BuildResponse(r), nil
}
if err := json.NewDecoder(r.Body).Decode(&list); err != nil {
return nil, nil, NewAppError("GetEditHistoryForPost", "api.unmarshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
}
return list, BuildResponse(r), nil
}
// GetFlaggedPostsForUser returns flagged posts of a user based on user id string.
func (c *Client4) GetFlaggedPostsForUser(userId string, page int, perPage int) (*PostList, *Response, error) {
query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)