From 756dd449ccb1f8dd5a6a24f5d167bdb4a6b8b28d Mon Sep 17 00:00:00 2001 From: Jean Khawand <22157081+jeankhawand@users.noreply.github.com> Date: Sat, 30 Mar 2024 00:37:05 +0100 Subject: [PATCH] integration/webhook: add category title to request body --- internal/integration/webhook/webhook.go | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/internal/integration/webhook/webhook.go b/internal/integration/webhook/webhook.go index 52399c3d..a69730f9 100644 --- a/internal/integration/webhook/webhook.go +++ b/internal/integration/webhook/webhook.go @@ -57,6 +57,7 @@ func (c *Client) SendSaveEntryWebhookEvent(entry *model.Entry) error { ID: entry.Feed.ID, UserID: entry.Feed.UserID, CategoryID: entry.Feed.Category.ID, + Category: &WebhookCategory{ID: entry.Feed.Category.ID, Title: entry.Feed.Category.Title}, FeedURL: entry.Feed.FeedURL, SiteURL: entry.Feed.SiteURL, Title: entry.Feed.Title, @@ -94,13 +95,13 @@ func (c *Client) SendNewEntriesWebhookEvent(feed *model.Feed, entries model.Entr Tags: entry.Tags, }) } - return c.makeRequest(NewEntriesEventType, &WebhookNewEntriesEvent{ EventType: NewEntriesEventType, Feed: &WebhookFeed{ ID: feed.ID, UserID: feed.UserID, CategoryID: feed.Category.ID, + Category: &WebhookCategory{ID: feed.Category.ID, Title: feed.Category.Title}, FeedURL: feed.FeedURL, SiteURL: feed.SiteURL, Title: feed.Title, @@ -145,13 +146,19 @@ func (c *Client) makeRequest(eventType string, payload any) error { } type WebhookFeed struct { - ID int64 `json:"id"` - UserID int64 `json:"user_id"` - CategoryID int64 `json:"category_id"` - FeedURL string `json:"feed_url"` - SiteURL string `json:"site_url"` - Title string `json:"title"` - CheckedAt time.Time `json:"checked_at"` + ID int64 `json:"id"` + UserID int64 `json:"user_id"` + CategoryID int64 `json:"category_id"` + Category *WebhookCategory `json:"category,omitempty"` + FeedURL string `json:"feed_url"` + SiteURL string `json:"site_url"` + Title string `json:"title"` + CheckedAt time.Time `json:"checked_at"` +} + +type WebhookCategory struct { + ID int64 `json:"id"` + Title string `json:"title"` } type WebhookEntry struct {