diff --git a/docs/content/en/integrations/outgoing-webhook/generic/index.md b/docs/content/en/integrations/outgoing-webhook/generic/index.md index 55a4abb2a..7bb3ac4df 100644 --- a/docs/content/en/integrations/outgoing-webhook/generic/index.md +++ b/docs/content/en/integrations/outgoing-webhook/generic/index.md @@ -14,6 +14,7 @@ By default, the article is sent as a JSON with the following format: ```json { + "href": "article URL on readflow", "title": "The title", "text": "Text content (the summary)", "html": "HTML content", diff --git a/docs/content/fr/integrations/outgoing-webhook/generic/index.md b/docs/content/fr/integrations/outgoing-webhook/generic/index.md index 2abefeb1f..3fac182d6 100644 --- a/docs/content/fr/integrations/outgoing-webhook/generic/index.md +++ b/docs/content/fr/integrations/outgoing-webhook/generic/index.md @@ -14,6 +14,7 @@ Par défaut, l'article est envoyé en JSON selon le format suivant: ```json { + "href": "L'URL de l'article sur readflow", "title": "Le titre", "text": "Le text de l'article (le résumé)", "html": "Le contenu HTML de l'article", diff --git a/pkg/integration/webhook/generic/generic.go b/pkg/integration/webhook/generic/generic.go index 983184f34..daf620545 100644 --- a/pkg/integration/webhook/generic/generic.go +++ b/pkg/integration/webhook/generic/generic.go @@ -7,6 +7,7 @@ import ( "fmt" "net/http" "net/url" + "strings" "text/template" "time" @@ -31,6 +32,7 @@ func isValidContentType(contentType string) bool { // webhookArticle is the structure definition of a generic Webhook article type webhookArticle struct { + Href string `json:"href,omitempty"` Title string `json:"title,omitempty"` Text *string `json:"text,omitempty"` HTML *string `json:"html,omitempty"` @@ -49,8 +51,9 @@ type ProviderConfig struct { // Provider is the structure definition of a Webhook outbound service type Provider struct { - config ProviderConfig - tpl *template.Template + config ProviderConfig + tpl *template.Template + hrefBase string } func newWebhookProvider(srv model.OutgoingWebhook, conf config.Config) (webhook.Provider, error) { @@ -81,8 +84,9 @@ func newWebhookProvider(srv model.OutgoingWebhook, conf config.Config) (webhook. } provider := &Provider{ - config: config, - tpl: tpl, + config: config, + tpl: tpl, + hrefBase: strings.Replace(conf.Global.PublicURL, "api.", "", 1), } return provider, nil @@ -91,6 +95,7 @@ func newWebhookProvider(srv model.OutgoingWebhook, conf config.Config) (webhook. // Send article to Webhook endpoint. func (whp *Provider) Send(ctx context.Context, article model.Article) error { art := webhookArticle{ + Href: fmt.Sprintf("%s/inbox/%d", whp.hrefBase, article.ID), Title: article.Title, Text: article.Text, HTML: article.HTML,