1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-09-15 18:57:04 +00:00

feat(integration): support Wallabag tags in integration client

This commit is contained in:
Kevin Jiang 2025-08-24 15:12:32 +12:00
parent cc7f1a3710
commit 04e5e1e993
5 changed files with 17 additions and 4 deletions

View file

@ -108,6 +108,7 @@ func SendEntry(entry *model.Entry, userIntegrations *model.Integration) {
if userIntegrations.WallabagEnabled {
slog.Debug("Sending entry to Wallabag",
slog.Int64("user_id", userIntegrations.UserID),
slog.String("user_tags", userIntegrations.WallabagTags),
slog.Int64("entry_id", entry.ID),
slog.String("entry_url", entry.URL),
)
@ -118,12 +119,14 @@ func SendEntry(entry *model.Entry, userIntegrations *model.Integration) {
userIntegrations.WallabagClientSecret,
userIntegrations.WallabagUsername,
userIntegrations.WallabagPassword,
userIntegrations.WallabagTags,
userIntegrations.WallabagOnlyURL,
)
if err := client.CreateEntry(entry.URL, entry.Title, entry.Content); err != nil {
slog.Error("Unable to send entry to Wallabag",
slog.Int64("user_id", userIntegrations.UserID),
slog.String("user_tags", userIntegrations.WallabagTags),
slog.Int64("entry_id", entry.ID),
slog.String("entry_url", entry.URL),
slog.Any("error", err),

View file

@ -24,11 +24,12 @@ type Client struct {
clientSecret string
username string
password string
tags string
onlyURL bool
}
func NewClient(baseURL, clientID, clientSecret, username, password string, onlyURL bool) *Client {
return &Client{baseURL, clientID, clientSecret, username, password, onlyURL}
func NewClient(baseURL, clientID, clientSecret, username, password, tags string, onlyURL bool) *Client {
return &Client{baseURL, clientID, clientSecret, username, password, tags, onlyURL}
}
func (c *Client) CreateEntry(entryURL, entryTitle, entryContent string) error {
@ -41,10 +42,10 @@ func (c *Client) CreateEntry(entryURL, entryTitle, entryContent string) error {
return err
}
return c.createEntry(accessToken, entryURL, entryTitle, entryContent)
return c.createEntry(accessToken, entryURL, entryTitle, entryContent, c.tags)
}
func (c *Client) createEntry(accessToken, entryURL, entryTitle, entryContent string) error {
func (c *Client) createEntry(accessToken, entryURL, entryTitle, entryContent, tags string) error {
apiEndpoint, err := urllib.JoinBaseURLAndPath(c.baseURL, "/api/entries.json")
if err != nil {
return fmt.Errorf("wallbag: unable to generate entries endpoint: %v", err)
@ -58,6 +59,7 @@ func (c *Client) createEntry(accessToken, entryURL, entryTitle, entryContent str
URL: entryURL,
Title: entryTitle,
Content: entryContent,
Tags: tags,
})
if err != nil {
return fmt.Errorf("wallbag: unable to encode request body: %v", err)
@ -140,4 +142,5 @@ type createEntryRequest struct {
URL string `json:"url"`
Title string `json:"title"`
Content string `json:"content,omitempty"`
Tags string `json:"tags,omitempty"`
}

View file

@ -664,6 +664,9 @@
<label for="form-wallabag-password">{{ t "form.integration.wallabag_password" }}</label>
<input type="password" name="wallabag_password" id="form-wallabag-password" value="{{ .form.WallabagPassword }}" autocomplete="new-password">
<label for="form-wallabag-tags">{{ t "form.integration.wallabag_tags" }}</label>
<input type="text" name="wallabag_tags" id="form-wallabag-tags" value="{{ .form.WallabagTags }}" spellcheck="false">
<div class="buttons">
<button type="submit" class="button button-primary" data-label-loading="{{ t "form.submit.saving" }}">{{ t "action.update" }}</button>
</div>

View file

@ -32,6 +32,7 @@ type IntegrationForm struct {
WallabagClientSecret string
WallabagUsername string
WallabagPassword string
WallabagTags string
NotionEnabled bool
NotionPageID string
NotionToken string
@ -150,6 +151,7 @@ func (i IntegrationForm) Merge(integration *model.Integration) {
integration.WallabagClientSecret = i.WallabagClientSecret
integration.WallabagUsername = i.WallabagUsername
integration.WallabagPassword = i.WallabagPassword
integration.WallabagTags = i.WallabagTags
integration.NotionEnabled = i.NotionEnabled
integration.NotionPageID = i.NotionPageID
integration.NotionToken = i.NotionToken
@ -270,6 +272,7 @@ func NewIntegrationForm(r *http.Request) *IntegrationForm {
WallabagClientSecret: r.FormValue("wallabag_client_secret"),
WallabagUsername: r.FormValue("wallabag_username"),
WallabagPassword: r.FormValue("wallabag_password"),
WallabagTags: r.FormValue("wallabag_tags"),
NotionEnabled: r.FormValue("notion_enabled") == "1",
NotionPageID: r.FormValue("notion_page_id"),
NotionToken: r.FormValue("notion_token"),

View file

@ -45,6 +45,7 @@ func (h *handler) showIntegrationPage(w http.ResponseWriter, r *http.Request) {
WallabagClientSecret: integration.WallabagClientSecret,
WallabagUsername: integration.WallabagUsername,
WallabagPassword: integration.WallabagPassword,
WallabagTags: integration.WallabagTags,
NotionEnabled: integration.NotionEnabled,
NotionPageID: integration.NotionPageID,
NotionToken: integration.NotionToken,