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:
parent
cc7f1a3710
commit
04e5e1e993
5 changed files with 17 additions and 4 deletions
|
@ -108,6 +108,7 @@ func SendEntry(entry *model.Entry, userIntegrations *model.Integration) {
|
||||||
if userIntegrations.WallabagEnabled {
|
if userIntegrations.WallabagEnabled {
|
||||||
slog.Debug("Sending entry to Wallabag",
|
slog.Debug("Sending entry to Wallabag",
|
||||||
slog.Int64("user_id", userIntegrations.UserID),
|
slog.Int64("user_id", userIntegrations.UserID),
|
||||||
|
slog.String("user_tags", userIntegrations.WallabagTags),
|
||||||
slog.Int64("entry_id", entry.ID),
|
slog.Int64("entry_id", entry.ID),
|
||||||
slog.String("entry_url", entry.URL),
|
slog.String("entry_url", entry.URL),
|
||||||
)
|
)
|
||||||
|
@ -118,12 +119,14 @@ func SendEntry(entry *model.Entry, userIntegrations *model.Integration) {
|
||||||
userIntegrations.WallabagClientSecret,
|
userIntegrations.WallabagClientSecret,
|
||||||
userIntegrations.WallabagUsername,
|
userIntegrations.WallabagUsername,
|
||||||
userIntegrations.WallabagPassword,
|
userIntegrations.WallabagPassword,
|
||||||
|
userIntegrations.WallabagTags,
|
||||||
userIntegrations.WallabagOnlyURL,
|
userIntegrations.WallabagOnlyURL,
|
||||||
)
|
)
|
||||||
|
|
||||||
if err := client.CreateEntry(entry.URL, entry.Title, entry.Content); err != nil {
|
if err := client.CreateEntry(entry.URL, entry.Title, entry.Content); err != nil {
|
||||||
slog.Error("Unable to send entry to Wallabag",
|
slog.Error("Unable to send entry to Wallabag",
|
||||||
slog.Int64("user_id", userIntegrations.UserID),
|
slog.Int64("user_id", userIntegrations.UserID),
|
||||||
|
slog.String("user_tags", userIntegrations.WallabagTags),
|
||||||
slog.Int64("entry_id", entry.ID),
|
slog.Int64("entry_id", entry.ID),
|
||||||
slog.String("entry_url", entry.URL),
|
slog.String("entry_url", entry.URL),
|
||||||
slog.Any("error", err),
|
slog.Any("error", err),
|
||||||
|
|
|
@ -24,11 +24,12 @@ type Client struct {
|
||||||
clientSecret string
|
clientSecret string
|
||||||
username string
|
username string
|
||||||
password string
|
password string
|
||||||
|
tags string
|
||||||
onlyURL bool
|
onlyURL bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClient(baseURL, clientID, clientSecret, username, password string, onlyURL bool) *Client {
|
func NewClient(baseURL, clientID, clientSecret, username, password, tags string, onlyURL bool) *Client {
|
||||||
return &Client{baseURL, clientID, clientSecret, username, password, onlyURL}
|
return &Client{baseURL, clientID, clientSecret, username, password, tags, onlyURL}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) CreateEntry(entryURL, entryTitle, entryContent string) error {
|
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 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")
|
apiEndpoint, err := urllib.JoinBaseURLAndPath(c.baseURL, "/api/entries.json")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("wallbag: unable to generate entries endpoint: %v", err)
|
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,
|
URL: entryURL,
|
||||||
Title: entryTitle,
|
Title: entryTitle,
|
||||||
Content: entryContent,
|
Content: entryContent,
|
||||||
|
Tags: tags,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("wallbag: unable to encode request body: %v", err)
|
return fmt.Errorf("wallbag: unable to encode request body: %v", err)
|
||||||
|
@ -140,4 +142,5 @@ type createEntryRequest struct {
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Content string `json:"content,omitempty"`
|
Content string `json:"content,omitempty"`
|
||||||
|
Tags string `json:"tags,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -664,6 +664,9 @@
|
||||||
<label for="form-wallabag-password">{{ t "form.integration.wallabag_password" }}</label>
|
<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">
|
<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">
|
<div class="buttons">
|
||||||
<button type="submit" class="button button-primary" data-label-loading="{{ t "form.submit.saving" }}">{{ t "action.update" }}</button>
|
<button type="submit" class="button button-primary" data-label-loading="{{ t "form.submit.saving" }}">{{ t "action.update" }}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -32,6 +32,7 @@ type IntegrationForm struct {
|
||||||
WallabagClientSecret string
|
WallabagClientSecret string
|
||||||
WallabagUsername string
|
WallabagUsername string
|
||||||
WallabagPassword string
|
WallabagPassword string
|
||||||
|
WallabagTags string
|
||||||
NotionEnabled bool
|
NotionEnabled bool
|
||||||
NotionPageID string
|
NotionPageID string
|
||||||
NotionToken string
|
NotionToken string
|
||||||
|
@ -150,6 +151,7 @@ func (i IntegrationForm) Merge(integration *model.Integration) {
|
||||||
integration.WallabagClientSecret = i.WallabagClientSecret
|
integration.WallabagClientSecret = i.WallabagClientSecret
|
||||||
integration.WallabagUsername = i.WallabagUsername
|
integration.WallabagUsername = i.WallabagUsername
|
||||||
integration.WallabagPassword = i.WallabagPassword
|
integration.WallabagPassword = i.WallabagPassword
|
||||||
|
integration.WallabagTags = i.WallabagTags
|
||||||
integration.NotionEnabled = i.NotionEnabled
|
integration.NotionEnabled = i.NotionEnabled
|
||||||
integration.NotionPageID = i.NotionPageID
|
integration.NotionPageID = i.NotionPageID
|
||||||
integration.NotionToken = i.NotionToken
|
integration.NotionToken = i.NotionToken
|
||||||
|
@ -270,6 +272,7 @@ func NewIntegrationForm(r *http.Request) *IntegrationForm {
|
||||||
WallabagClientSecret: r.FormValue("wallabag_client_secret"),
|
WallabagClientSecret: r.FormValue("wallabag_client_secret"),
|
||||||
WallabagUsername: r.FormValue("wallabag_username"),
|
WallabagUsername: r.FormValue("wallabag_username"),
|
||||||
WallabagPassword: r.FormValue("wallabag_password"),
|
WallabagPassword: r.FormValue("wallabag_password"),
|
||||||
|
WallabagTags: r.FormValue("wallabag_tags"),
|
||||||
NotionEnabled: r.FormValue("notion_enabled") == "1",
|
NotionEnabled: r.FormValue("notion_enabled") == "1",
|
||||||
NotionPageID: r.FormValue("notion_page_id"),
|
NotionPageID: r.FormValue("notion_page_id"),
|
||||||
NotionToken: r.FormValue("notion_token"),
|
NotionToken: r.FormValue("notion_token"),
|
||||||
|
|
|
@ -45,6 +45,7 @@ func (h *handler) showIntegrationPage(w http.ResponseWriter, r *http.Request) {
|
||||||
WallabagClientSecret: integration.WallabagClientSecret,
|
WallabagClientSecret: integration.WallabagClientSecret,
|
||||||
WallabagUsername: integration.WallabagUsername,
|
WallabagUsername: integration.WallabagUsername,
|
||||||
WallabagPassword: integration.WallabagPassword,
|
WallabagPassword: integration.WallabagPassword,
|
||||||
|
WallabagTags: integration.WallabagTags,
|
||||||
NotionEnabled: integration.NotionEnabled,
|
NotionEnabled: integration.NotionEnabled,
|
||||||
NotionPageID: integration.NotionPageID,
|
NotionPageID: integration.NotionPageID,
|
||||||
NotionToken: integration.NotionToken,
|
NotionToken: integration.NotionToken,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue