Skip to content

Commit

Permalink
Renaming completion-webhook-url to webhook-url
Browse files Browse the repository at this point in the history
  • Loading branch information
boggydigital committed Aug 17, 2023
1 parent d6353fc commit b54b9f8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions cli-commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ get-litres-my-books
import

post-completion
completion-webhook-url$
webhook-url^*$

purge
id*^
Expand All @@ -56,7 +56,7 @@ reduce-litres-my-books
sync
new-only
no-throttle
completion-webhook-url$
webhook-url$

serve
port$*
Expand Down
17 changes: 9 additions & 8 deletions cli/post_completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ import (
)

func PostCompletionHandler(u *url.URL) error {
cwu := u.Query().Get("completion-webhook-url")
return PostCompletion(cwu)
wu := u.Query().Get("webhook-url")
return PostCompletion(wu)
}

func PostCompletion(completionWebhookUrl string) error {

if completionWebhookUrl == "" {
return nil
}
func PostCompletion(webhookUrl string) error {

pca := nod.Begin("posting completion...")
defer pca.End()

_, err := http.DefaultClient.Post(completionWebhookUrl, "", nil)
if webhookUrl == "" {
pca.EndWithResult("webhook-url is empty")
return nil
}

_, err := http.DefaultClient.Post(webhookUrl, "", nil)
if err != nil {
return pca.EndWithError(err)
}
Expand Down
8 changes: 4 additions & 4 deletions cli/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
func SyncHandler(u *url.URL) error {
newOnly := u.Query().Has("new-only")
noThrottle := u.Query().Has("no-throttle")
cwu := u.Query().Get("completion-webhook-url")
wu := u.Query().Get("webhook-url")

return Sync(cwu, newOnly, noThrottle)
return Sync(wu, newOnly, noThrottle)
}
func Sync(completionWebhookUrl string, newOnly, noThrottle bool) error {
func Sync(webhookUrl string, newOnly, noThrottle bool) error {

hc, err := coost.NewHttpClientFromFile(data.AbsCookiesFilename(), litres_integration.LitResHost)
if err != nil {
Expand Down Expand Up @@ -60,7 +60,7 @@ func Sync(completionWebhookUrl string, newOnly, noThrottle bool) error {
return err
}

if err := PostCompletion(completionWebhookUrl); err != nil {
if err := PostCompletion(webhookUrl); err != nil {
return err
}

Expand Down

0 comments on commit b54b9f8

Please sign in to comment.