1
0
mirror of https://github.com/mrusme/neonmodem.git synced 2025-02-02 15:07:59 -05:00

Fix #32, forum filter implementation for Lemmy

This commit is contained in:
マリウス 2024-07-31 17:24:19 -05:00
parent 970eec5f12
commit e37b59f0df
No known key found for this signature in database
GPG Key ID: 272ED814BF63261F

View File

@ -177,11 +177,31 @@ func (sys *System) ListForums() ([]forum.Forum, error) {
}
func (sys *System) ListPosts(forumID string) ([]post.Post, error) {
resp, err := sys.client.Posts(context.Background(), lemmy.GetPosts{
var err error
var catID int = -1
if forumID != "" {
catID, err = strconv.Atoi(forumID)
if err != nil {
return []post.Post{}, err
}
}
lgp := lemmy.GetPosts{
Type: lemmy.NewOptional(lemmy.ListingTypeSubscribed),
Sort: lemmy.NewOptional(lemmy.SortTypeNew),
Limit: lemmy.NewOptional(int64(50)),
})
}
if catID > -1 {
lgp = lemmy.GetPosts{
CommunityID: lemmy.NewOptional(int64(catID)),
Type: lemmy.NewOptional(lemmy.ListingTypeSubscribed),
Sort: lemmy.NewOptional(lemmy.SortTypeNew),
Limit: lemmy.NewOptional(int64(50)),
}
}
resp, err := sys.client.Posts(context.Background(), lgp)
if err != nil {
return []post.Post{}, err