You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
471 B
Go
27 lines
471 B
Go
package filters
|
|
|
|
import (
|
|
"git.blob42.xyz/blob42/hugobot/v3/feeds"
|
|
"git.blob42.xyz/blob42/hugobot/v3/posts"
|
|
"log"
|
|
)
|
|
|
|
type FilterHook func(feed feeds.Feed, post *posts.Post) error
|
|
|
|
var (
|
|
PostFilters []FilterHook
|
|
)
|
|
|
|
func RegisterPostFilterHook(hook FilterHook) {
|
|
PostFilters = append(PostFilters, hook)
|
|
}
|
|
|
|
func RunPostFilterHooks(feed feeds.Feed, post *posts.Post) {
|
|
for _, h := range PostFilters {
|
|
err := h(feed, post)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
}
|