Added the SearchPostsInTeam method to the plugin API (#10106)

Этот коммит содержится в:
Andrew Braunstein
2019-02-12 22:41:32 -08:00
коммит произвёл Hanzei
родитель 87e36a3ecf
Коммит c08fda1337
11 изменённых файлов: 197 добавлений и 31 удалений

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

@@ -21,6 +21,14 @@ func NewPostList() *PostList {
}
}
func (o *PostList) ToSlice() []*Post {
var posts []*Post
for _, id := range o.Order {
posts = append(posts, o.Posts[id])
}
return posts
}
func (o *PostList) WithRewrittenImageURLs(f func(string) string) *PostList {
copy := *o
copy.Posts = make(map[string]*Post)

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

@@ -90,3 +90,21 @@ func TestPostListSortByCreateAt(t *testing.T) {
assert.EqualValues(t, pl.Order[1], p1.Id)
assert.EqualValues(t, pl.Order[2], p2.Id)
}
func TestPostListToSlice(t *testing.T) {
pl := PostList{}
p1 := &Post{Id: NewId(), Message: NewId(), CreateAt: 2}
pl.AddPost(p1)
p2 := &Post{Id: NewId(), Message: NewId(), CreateAt: 1}
pl.AddPost(p2)
p3 := &Post{Id: NewId(), Message: NewId(), CreateAt: 3}
pl.AddPost(p3)
pl.AddOrder(p1.Id)
pl.AddOrder(p2.Id)
pl.AddOrder(p3.Id)
want := []*Post{p1, p2, p3}
assert.Equal(t, want, pl.ToSlice())
}

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

@@ -23,6 +23,8 @@ type SearchParams struct {
OrTerms bool
IncludeDeletedChannels bool
TimeZoneOffset int
// True if this search doesn't originate from a "current user".
SearchWithoutUserId bool
}
// Returns the epoch timestamp of the start of the day specified by SearchParams.AfterDate