option to resend specific post webmention
This commit is contained in:
parent
db9dee6232
commit
ecfcd84b82
|
@ -6,8 +6,14 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var postId string
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(webmentionCmd)
|
||||
webmentionCmd.Flags().StringVar(
|
||||
&postId, "post", "",
|
||||
"specify the post to send webmentions for. Otherwise, all posts will be checked.",
|
||||
)
|
||||
}
|
||||
|
||||
var webmentionCmd = &cobra.Command{
|
||||
|
@ -39,19 +45,13 @@ var webmentionCmd = &cobra.Command{
|
|||
}
|
||||
}
|
||||
|
||||
for _, user := range users {
|
||||
posts, err := user.Posts()
|
||||
if err != nil {
|
||||
println("Error getting posts: ", err.Error())
|
||||
}
|
||||
|
||||
for _, post := range posts {
|
||||
processPost := func(user owl.User, post *owl.Post) error {
|
||||
println("Webmentions for post: ", post.Title())
|
||||
|
||||
err := post.ScanForLinks()
|
||||
if err != nil {
|
||||
println("Error scanning post for links: ", err.Error())
|
||||
continue
|
||||
return err
|
||||
}
|
||||
|
||||
webmentions := post.OutgoingWebmentions()
|
||||
|
@ -64,6 +64,27 @@ var webmentionCmd = &cobra.Command{
|
|||
println("Webmention sent to ", webmention.Target)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, user := range users {
|
||||
if postId != "" {
|
||||
// send webmentions for a specific post
|
||||
post, err := user.GetPost(postId)
|
||||
if err != nil {
|
||||
println("Error getting post: ", err.Error())
|
||||
return
|
||||
}
|
||||
processPost(user, &post)
|
||||
}
|
||||
|
||||
posts, err := user.Posts()
|
||||
if err != nil {
|
||||
println("Error getting posts: ", err.Error())
|
||||
}
|
||||
|
||||
for _, post := range posts {
|
||||
processPost(user, post)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue