jlelse
/
jsonpub
Archived
1
Fork 0
This commit is contained in:
Jan-Lukas Else 2020-04-11 21:33:18 +02:00
parent 7b9473f6fc
commit a0afd43471
1 changed files with 14 additions and 12 deletions

26
http.go
View File

@ -19,21 +19,23 @@ func Serve() {
hookHandler := func(w http.ResponseWriter, r *http.Request) {
fmt.Println("Fetch feeds: ", time.Now().Format(time.RFC3339))
for _, actor := range actors {
fmt.Println(actor.feed)
articles, err := allFeedItems(actor.feed)
if err != nil {
fmt.Println(actor.feed, err.Error())
continue
}
// Post or update latest 5 article
for _, article := range (*articles)[0:int(math.Min(float64(len(*articles)-1), 4))] {
err = actor.PostArticle(article)
go func() {
for _, actor := range actors {
fmt.Println(actor.feed)
articles, err := allFeedItems(actor.feed)
if err != nil {
fmt.Println("Posting", article, "failed")
fmt.Println(actor.feed, err.Error())
continue
}
// Post or update latest 5 article
for _, article := range (*articles)[0:int(math.Min(float64(len(*articles)-1), 4))] {
err = actor.PostArticle(article)
if err != nil {
fmt.Println("Posting", article, "failed")
}
}
}
}
}()
}
webfingerHandler := func(w http.ResponseWriter, r *http.Request) {