Skip to content

Commit

Permalink
fix: skip post 0 from go-4chan-api, minor rename
Browse files Browse the repository at this point in the history
  • Loading branch information
azimut committed Apr 13, 2023
1 parent bdb3bdd commit 7d3608b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions internal/fourchan/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ func toThread(apiThread *api.Thread) *Thread {
subject: apiThread.OP.Subject,
},
}
// NOTE: go-4chan-api adds op as the first (aka [0]) post
if len(apiThread.Posts) <= 1 {
return &thread
}
// TODO: depth + replies tree
for _, post := range apiThread.Posts {
reply := Post{
attachment: getAttachment(post),
comment: post.Comment,
created: post.Time,
for _, apiPost := range apiThread.Posts[1:] {
post := Post{
attachment: getAttachment(apiPost),
comment: apiPost.Comment,
created: apiPost.Time,
}
thread.posts = append(thread.posts, reply)
thread.posts = append(thread.posts, post)
}
return &thread
}
Expand Down

0 comments on commit 7d3608b

Please sign in to comment.