Browse Source

Add Notion integration

Jean Khawand 2 years ago
parent
commit
bfb4fc1c36

+ 9 - 0
database/migrations.go

@@ -707,4 +707,13 @@ var migrations = []func(tx *sql.Tx) error{
 		_, err = tx.Exec(sql)
 		_, err = tx.Exec(sql)
 		return err
 		return err
 	},
 	},
+	func(tx *sql.Tx) (err error) {
+		sql := `
+		ALTER TABLE integrations ADD COLUMN notion_enabled bool default 'f';
+		ALTER TABLE integrations ADD COLUMN notion_token text default '';
+		ALTER TABLE integrations ADD COLUMN notion_page_id text default '';
+		`
+		_, err = tx.Exec(sql)
+		return err
+	},
 }
 }

+ 29 - 3
http/client/client.go

@@ -44,9 +44,9 @@ type Client struct {
 	requestPassword            string
 	requestPassword            string
 	requestUserAgent           string
 	requestUserAgent           string
 	requestCookie              string
 	requestCookie              string
-
-	useProxy             bool
-	doNotFollowRedirects bool
+	customHeaders              map[string]string
+	useProxy                   bool
+	doNotFollowRedirects       bool
 
 
 	ClientTimeout               int
 	ClientTimeout               int
 	ClientMaxBodySize           int64
 	ClientMaxBodySize           int64
@@ -111,6 +111,12 @@ func (c *Client) WithAuthorization(authorization string) *Client {
 	return c
 	return c
 }
 }
 
 
+// WithCustomHeaders defines custom HTTP headers.
+func (c *Client) WithCustomHeaders(customHeaders map[string]string) *Client {
+	c.customHeaders = customHeaders
+	return c
+}
+
 // WithCacheHeaders defines caching headers.
 // WithCacheHeaders defines caching headers.
 func (c *Client) WithCacheHeaders(etagHeader, lastModifiedHeader string) *Client {
 func (c *Client) WithCacheHeaders(etagHeader, lastModifiedHeader string) *Client {
 	c.requestEtagHeader = etagHeader
 	c.requestEtagHeader = etagHeader
@@ -183,6 +189,22 @@ func (c *Client) PostJSON(data interface{}) (*Response, error) {
 	return c.executeRequest(request)
 	return c.executeRequest(request)
 }
 }
 
 
+// PatchJSON performs a Patch HTTP request with a JSON payload.
+func (c *Client) PatchJSON(data interface{}) (*Response, error) {
+	b, err := json.Marshal(data)
+	if err != nil {
+		return nil, err
+	}
+
+	request, err := c.buildRequest(http.MethodPatch, bytes.NewReader(b))
+	if err != nil {
+		return nil, err
+	}
+
+	request.Header.Add("Content-Type", "application/json")
+	return c.executeRequest(request)
+}
+
 func (c *Client) executeRequest(request *http.Request) (*Response, error) {
 func (c *Client) executeRequest(request *http.Request) (*Response, error) {
 	defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[HttpClient] inputURL=%s", c.inputURL))
 	defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[HttpClient] inputURL=%s", c.inputURL))
 
 
@@ -337,6 +359,10 @@ func (c *Client) buildHeaders() http.Header {
 		headers.Add("Cookie", c.requestCookie)
 		headers.Add("Cookie", c.requestCookie)
 	}
 	}
 
 
+	for key, value := range c.customHeaders {
+		headers.Add(key, value)
+	}
+
 	headers.Add("Connection", "close")
 	headers.Add("Connection", "close")
 	return headers
 	return headers
 }
 }

+ 13 - 0
integration/integration.go

@@ -9,6 +9,7 @@ import (
 	"miniflux.app/integration/instapaper"
 	"miniflux.app/integration/instapaper"
 	"miniflux.app/integration/linkding"
 	"miniflux.app/integration/linkding"
 	"miniflux.app/integration/matrixbot"
 	"miniflux.app/integration/matrixbot"
+	"miniflux.app/integration/notion"
 	"miniflux.app/integration/nunuxkeeper"
 	"miniflux.app/integration/nunuxkeeper"
 	"miniflux.app/integration/pinboard"
 	"miniflux.app/integration/pinboard"
 	"miniflux.app/integration/pocket"
 	"miniflux.app/integration/pocket"
@@ -62,6 +63,18 @@ func SendEntry(entry *model.Entry, integration *model.Integration) {
 		}
 		}
 	}
 	}
 
 
+	if integration.NotionEnabled {
+		logger.Debug("[Integration] Sending Entry #%d %q for User #%d to Notion", entry.ID, entry.URL, integration.UserID)
+
+		client := notion.NewClient(
+			integration.NotionToken,
+			integration.NotionPageID,
+		)
+		if err := client.AddEntry(entry.URL, entry.Title); err != nil {
+			logger.Error("[Integration] UserID #%d: %v", integration.UserID, err)
+		}
+	}
+
 	if integration.NunuxKeeperEnabled {
 	if integration.NunuxKeeperEnabled {
 		logger.Debug("[Integration] Sending Entry #%d %q for User #%d to NunuxKeeper", entry.ID, entry.URL, integration.UserID)
 		logger.Debug("[Integration] Sending Entry #%d %q for User #%d to NunuxKeeper", entry.ID, entry.URL, integration.UserID)
 
 

+ 54 - 0
integration/notion/notion.go

@@ -0,0 +1,54 @@
+// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
+// SPDX-License-Identifier: Apache-2.0
+
+package notion
+
+import (
+	"fmt"
+
+	"miniflux.app/http/client"
+)
+
+// Client represents a Notion client.
+type Client struct {
+	token  string
+	pageID string
+}
+
+// NewClient returns a new Notion client.
+func NewClient(token, pageID string) *Client {
+	return &Client{token, pageID}
+}
+
+func (c *Client) AddEntry(entryURL string, entryTitle string) error {
+	if c.token == "" || c.pageID == "" {
+		return fmt.Errorf("notion: missing credentials")
+	}
+	clt := client.New("https://api.notion.com/v1/blocks/" + c.pageID + "/children")
+	block := &Data{
+		Children: []Block{
+			{
+				Object: "block",
+				Type:   "bookmark",
+				Bookmark: Bookmark{
+					Caption: []interface{}{},
+					URL:     entryURL,
+				},
+			},
+		},
+	}
+	clt.WithAuthorization("Bearer " + c.token)
+	customHeaders := map[string]string{
+		"Notion-Version": "2022-06-28",
+	}
+	clt.WithCustomHeaders(customHeaders)
+	response, error := clt.PatchJSON(block)
+	if error != nil {
+		return fmt.Errorf("notion: unable to patch entry: %v", error)
+	}
+
+	if response.HasServerFailure() {
+		return fmt.Errorf("notion: request failed, status=%d", response.StatusCode)
+	}
+	return nil
+}

+ 19 - 0
integration/notion/wrapper.go

@@ -0,0 +1,19 @@
+// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
+// SPDX-License-Identifier: Apache-2.0
+
+package notion
+
+type Data struct {
+	Children []Block `json:"children"`
+}
+
+type Block struct {
+	Object   string   `json:"object"`
+	Type     string   `json:"type"`
+	Bookmark Bookmark `json:"bookmark"`
+}
+
+type Bookmark struct {
+	Caption []interface{} `json:"caption"` // Assuming the "caption" field can have different types
+	URL     string        `json:"url"`
+}

+ 3 - 0
locale/translations/de_DE.json

@@ -351,6 +351,9 @@
     "form.integration.wallabag_client_secret": "Wallabag Client-Secret",
     "form.integration.wallabag_client_secret": "Wallabag Client-Secret",
     "form.integration.wallabag_username": "Wallabag Benutzername",
     "form.integration.wallabag_username": "Wallabag Benutzername",
     "form.integration.wallabag_password": "Wallabag Passwort",
     "form.integration.wallabag_password": "Wallabag Passwort",
+    "form.integration.notion_activate": "Save entries to Notion",
+    "form.integration.notion_page_id": "Notion Page ID",
+    "form.integration.notion_token": "Notion Secret Token",
     "form.integration.nunux_keeper_activate": "Artikel in Nunux Keeper speichern",
     "form.integration.nunux_keeper_activate": "Artikel in Nunux Keeper speichern",
     "form.integration.nunux_keeper_endpoint": "Nunux Keeper API-Endpunkt",
     "form.integration.nunux_keeper_endpoint": "Nunux Keeper API-Endpunkt",
     "form.integration.nunux_keeper_api_key": "Nunux Keeper API-Schlüssel",
     "form.integration.nunux_keeper_api_key": "Nunux Keeper API-Schlüssel",

+ 3 - 0
locale/translations/el_EL.json

@@ -351,6 +351,9 @@
     "form.integration.wallabag_client_secret": "Wallabag Μυστικό Πελάτη",
     "form.integration.wallabag_client_secret": "Wallabag Μυστικό Πελάτη",
     "form.integration.wallabag_username": "Όνομα Χρήστη Wallabag",
     "form.integration.wallabag_username": "Όνομα Χρήστη Wallabag",
     "form.integration.wallabag_password": "Wallabag Κωδικός Πρόσβασης",
     "form.integration.wallabag_password": "Wallabag Κωδικός Πρόσβασης",
+    "form.integration.notion_activate": "Save entries to Notion",
+    "form.integration.notion_page_id": "Notion Page ID",
+    "form.integration.notion_token": "Notion Secret Token",
     "form.integration.nunux_keeper_activate": "Αποθήκευση άρθρων στο Nunux Keeper",
     "form.integration.nunux_keeper_activate": "Αποθήκευση άρθρων στο Nunux Keeper",
     "form.integration.nunux_keeper_endpoint": "Τελικό σημείο Nunux Keeper API",
     "form.integration.nunux_keeper_endpoint": "Τελικό σημείο Nunux Keeper API",
     "form.integration.nunux_keeper_api_key": "Κλειδί API Nunux Keeper",
     "form.integration.nunux_keeper_api_key": "Κλειδί API Nunux Keeper",

+ 3 - 0
locale/translations/en_US.json

@@ -351,6 +351,9 @@
     "form.integration.wallabag_client_secret": "Wallabag Client Secret",
     "form.integration.wallabag_client_secret": "Wallabag Client Secret",
     "form.integration.wallabag_username": "Wallabag Username",
     "form.integration.wallabag_username": "Wallabag Username",
     "form.integration.wallabag_password": "Wallabag Password",
     "form.integration.wallabag_password": "Wallabag Password",
+    "form.integration.notion_activate": "Save entries to Notion",
+    "form.integration.notion_page_id": "Notion Page ID",
+    "form.integration.notion_token": "Notion Secret Token",
     "form.integration.nunux_keeper_activate": "Save entries to Nunux Keeper",
     "form.integration.nunux_keeper_activate": "Save entries to Nunux Keeper",
     "form.integration.nunux_keeper_endpoint": "Nunux Keeper API Endpoint",
     "form.integration.nunux_keeper_endpoint": "Nunux Keeper API Endpoint",
     "form.integration.nunux_keeper_api_key": "Nunux Keeper API key",
     "form.integration.nunux_keeper_api_key": "Nunux Keeper API key",

+ 3 - 0
locale/translations/es_ES.json

@@ -351,6 +351,9 @@
     "form.integration.wallabag_client_secret": "Secreto de cliente de Wallabag",
     "form.integration.wallabag_client_secret": "Secreto de cliente de Wallabag",
     "form.integration.wallabag_username": "Nombre de usuario de Wallabag",
     "form.integration.wallabag_username": "Nombre de usuario de Wallabag",
     "form.integration.wallabag_password": "Contraseña de Wallabag",
     "form.integration.wallabag_password": "Contraseña de Wallabag",
+    "form.integration.notion_activate": "Save entries to Notion",
+    "form.integration.notion_page_id": "Notion Page ID",
+    "form.integration.notion_token": "Notion Secret Token",
     "form.integration.nunux_keeper_activate": "Enviar artículos a Nunux Keeper",
     "form.integration.nunux_keeper_activate": "Enviar artículos a Nunux Keeper",
     "form.integration.nunux_keeper_endpoint": "Acceso API de Nunux Keeper",
     "form.integration.nunux_keeper_endpoint": "Acceso API de Nunux Keeper",
     "form.integration.nunux_keeper_api_key": "Clave de API de Nunux Keeper",
     "form.integration.nunux_keeper_api_key": "Clave de API de Nunux Keeper",

+ 3 - 0
locale/translations/fi_FI.json

@@ -351,6 +351,9 @@
     "form.integration.wallabag_client_secret": "Wallabag Client Secret",
     "form.integration.wallabag_client_secret": "Wallabag Client Secret",
     "form.integration.wallabag_username": "Wallabag-käyttäjätunnus",
     "form.integration.wallabag_username": "Wallabag-käyttäjätunnus",
     "form.integration.wallabag_password": "Wallabag-salasana",
     "form.integration.wallabag_password": "Wallabag-salasana",
+    "form.integration.notion_activate": "Save entries to Notion",
+    "form.integration.notion_page_id": "Notion Page ID",
+    "form.integration.notion_token": "Notion Secret Token",
     "form.integration.nunux_keeper_activate": "Tallenna artikkelit Nunux Keeperiin",
     "form.integration.nunux_keeper_activate": "Tallenna artikkelit Nunux Keeperiin",
     "form.integration.nunux_keeper_endpoint": "Nunux Keeper API-päätepiste",
     "form.integration.nunux_keeper_endpoint": "Nunux Keeper API-päätepiste",
     "form.integration.nunux_keeper_api_key": "Nunux Keeper API-avain",
     "form.integration.nunux_keeper_api_key": "Nunux Keeper API-avain",

+ 3 - 0
locale/translations/fr_FR.json

@@ -351,6 +351,9 @@
     "form.integration.wallabag_client_secret": "Clé secrète du client Wallabag",
     "form.integration.wallabag_client_secret": "Clé secrète du client Wallabag",
     "form.integration.wallabag_username": "Nom d'utilisateur de Wallabag",
     "form.integration.wallabag_username": "Nom d'utilisateur de Wallabag",
     "form.integration.wallabag_password": "Mot de passe de Wallabag",
     "form.integration.wallabag_password": "Mot de passe de Wallabag",
+    "form.integration.notion_activate": "Sauvegarder les articles vers Notion",
+    "form.integration.notion_page_id": "l'identifiant de la page Notion",
+    "form.integration.notion_token": "Jeton d'accès de l'API de Notion",
     "form.integration.nunux_keeper_activate": "Sauvegarder les articles vers Nunux Keeper",
     "form.integration.nunux_keeper_activate": "Sauvegarder les articles vers Nunux Keeper",
     "form.integration.nunux_keeper_endpoint": "URL de l'API de Nunux Keeper",
     "form.integration.nunux_keeper_endpoint": "URL de l'API de Nunux Keeper",
     "form.integration.nunux_keeper_api_key": "Clé d'API de Nunux Keeper",
     "form.integration.nunux_keeper_api_key": "Clé d'API de Nunux Keeper",

+ 3 - 0
locale/translations/hi_IN.json

@@ -351,6 +351,9 @@
     "form.integration.wallabag_client_secret": "वालाबैग क्लाइंट सीक्रेट",
     "form.integration.wallabag_client_secret": "वालाबैग क्लाइंट सीक्रेट",
     "form.integration.wallabag_username": "वालाबैग उपयोगकर्ता नाम",
     "form.integration.wallabag_username": "वालाबैग उपयोगकर्ता नाम",
     "form.integration.wallabag_password": "वालाबैग पासवर्ड",
     "form.integration.wallabag_password": "वालाबैग पासवर्ड",
+    "form.integration.notion_activate": "Save entries to Notion",
+    "form.integration.notion_page_id": "Notion Page ID",
+    "form.integration.notion_token": "Notion Secret Token",
     "form.integration.nunux_keeper_activate": "विषय-वस्तु को ननक्स कीपर में सहेजें",
     "form.integration.nunux_keeper_activate": "विषय-वस्तु को ननक्स कीपर में सहेजें",
     "form.integration.nunux_keeper_endpoint": "ननक्स कीपर एपीआई समापन बिंदु",
     "form.integration.nunux_keeper_endpoint": "ननक्स कीपर एपीआई समापन बिंदु",
     "form.integration.nunux_keeper_api_key": "ननक्स कीपर एपीआई कुंजी",
     "form.integration.nunux_keeper_api_key": "ननक्स कीपर एपीआई कुंजी",

+ 3 - 0
locale/translations/id_ID.json

@@ -348,6 +348,9 @@
     "form.integration.wallabag_client_secret": "Rahasia Klien Wallabag",
     "form.integration.wallabag_client_secret": "Rahasia Klien Wallabag",
     "form.integration.wallabag_username": "Nama Pengguna Wallabag",
     "form.integration.wallabag_username": "Nama Pengguna Wallabag",
     "form.integration.wallabag_password": "Kata Sandi Wallabag",
     "form.integration.wallabag_password": "Kata Sandi Wallabag",
+    "form.integration.notion_activate": "Save entries to Notion",
+    "form.integration.notion_page_id": "Notion Page ID",
+    "form.integration.notion_token": "Notion Secret Token",
     "form.integration.nunux_keeper_activate": "Simpan artikel ke Nunux Keeper",
     "form.integration.nunux_keeper_activate": "Simpan artikel ke Nunux Keeper",
     "form.integration.nunux_keeper_endpoint": "Titik URL API Nunux Keeper",
     "form.integration.nunux_keeper_endpoint": "Titik URL API Nunux Keeper",
     "form.integration.nunux_keeper_api_key": "Kunci API Nunux Keeper",
     "form.integration.nunux_keeper_api_key": "Kunci API Nunux Keeper",

+ 3 - 0
locale/translations/it_IT.json

@@ -351,6 +351,9 @@
     "form.integration.wallabag_client_secret": "Client secret dell'account Wallabag",
     "form.integration.wallabag_client_secret": "Client secret dell'account Wallabag",
     "form.integration.wallabag_username": "Nome utente dell'account Wallabag",
     "form.integration.wallabag_username": "Nome utente dell'account Wallabag",
     "form.integration.wallabag_password": "Password dell'account Wallabag",
     "form.integration.wallabag_password": "Password dell'account Wallabag",
+    "form.integration.notion_activate": "Save entries to Notion",
+    "form.integration.notion_page_id": "Notion Page ID",
+    "form.integration.notion_token": "Notion Secret Token",
     "form.integration.nunux_keeper_activate": "Salva gli articoli su Nunux Keeper",
     "form.integration.nunux_keeper_activate": "Salva gli articoli su Nunux Keeper",
     "form.integration.nunux_keeper_endpoint": "Endpoint dell'API di Nunux Keeper",
     "form.integration.nunux_keeper_endpoint": "Endpoint dell'API di Nunux Keeper",
     "form.integration.nunux_keeper_api_key": "API key dell'account Nunux Keeper",
     "form.integration.nunux_keeper_api_key": "API key dell'account Nunux Keeper",

+ 3 - 0
locale/translations/ja_JP.json

@@ -351,6 +351,9 @@
     "form.integration.wallabag_client_secret": "Wallabag の Client Secret",
     "form.integration.wallabag_client_secret": "Wallabag の Client Secret",
     "form.integration.wallabag_username": "Wallabag のユーザー名",
     "form.integration.wallabag_username": "Wallabag のユーザー名",
     "form.integration.wallabag_password": "Wallabag のパスワード",
     "form.integration.wallabag_password": "Wallabag のパスワード",
+    "form.integration.notion_activate": "Save entries to Notion",
+    "form.integration.notion_page_id": "Notion Page ID",
+    "form.integration.notion_token": "Notion Secret Token",
     "form.integration.nunux_keeper_activate": "Nunux Keeper に記事を保存する",
     "form.integration.nunux_keeper_activate": "Nunux Keeper に記事を保存する",
     "form.integration.nunux_keeper_endpoint": "Nunux Keeper の API Endpoint",
     "form.integration.nunux_keeper_endpoint": "Nunux Keeper の API Endpoint",
     "form.integration.nunux_keeper_api_key": "Nunux Keeper の API key",
     "form.integration.nunux_keeper_api_key": "Nunux Keeper の API key",

+ 3 - 0
locale/translations/nl_NL.json

@@ -351,6 +351,9 @@
     "form.integration.wallabag_client_secret": "Wallabag Client-Secret",
     "form.integration.wallabag_client_secret": "Wallabag Client-Secret",
     "form.integration.wallabag_username": "Wallabag gebruikersnaam",
     "form.integration.wallabag_username": "Wallabag gebruikersnaam",
     "form.integration.wallabag_password": "Wallabag wachtwoord",
     "form.integration.wallabag_password": "Wallabag wachtwoord",
+    "form.integration.notion_activate": "Save entries to Notion",
+    "form.integration.notion_page_id": "Notion Page ID",
+    "form.integration.notion_token": "Notion Secret Token",
     "form.integration.nunux_keeper_activate": "Opslaan naar Nunux Keeper",
     "form.integration.nunux_keeper_activate": "Opslaan naar Nunux Keeper",
     "form.integration.nunux_keeper_endpoint": "Nunux Keeper URL",
     "form.integration.nunux_keeper_endpoint": "Nunux Keeper URL",
     "form.integration.nunux_keeper_api_key": "Nunux Keeper API-sleutel",
     "form.integration.nunux_keeper_api_key": "Nunux Keeper API-sleutel",

+ 3 - 0
locale/translations/pl_PL.json

@@ -353,6 +353,9 @@
     "form.integration.wallabag_client_secret": "Wallabag Client Secret",
     "form.integration.wallabag_client_secret": "Wallabag Client Secret",
     "form.integration.wallabag_username": "Login do Wallabag",
     "form.integration.wallabag_username": "Login do Wallabag",
     "form.integration.wallabag_password": "Hasło do Wallabag",
     "form.integration.wallabag_password": "Hasło do Wallabag",
+    "form.integration.notion_activate": "Save entries to Notion",
+    "form.integration.notion_page_id": "Notion Page ID",
+    "form.integration.notion_token": "Notion Secret Token",
     "form.integration.nunux_keeper_activate": "Zapisz artykuly do Nunux Keeper",
     "form.integration.nunux_keeper_activate": "Zapisz artykuly do Nunux Keeper",
     "form.integration.nunux_keeper_endpoint": "Nunux Keeper URL",
     "form.integration.nunux_keeper_endpoint": "Nunux Keeper URL",
     "form.integration.nunux_keeper_api_key": "Nunux Keeper API key",
     "form.integration.nunux_keeper_api_key": "Nunux Keeper API key",

+ 3 - 0
locale/translations/pt_BR.json

@@ -351,6 +351,9 @@
     "form.integration.wallabag_client_secret": "Segredo do cliente (Client Secret) do Wallabag",
     "form.integration.wallabag_client_secret": "Segredo do cliente (Client Secret) do Wallabag",
     "form.integration.wallabag_username": "Nome de usuário do Wallabag",
     "form.integration.wallabag_username": "Nome de usuário do Wallabag",
     "form.integration.wallabag_password": "Senha do Wallabag",
     "form.integration.wallabag_password": "Senha do Wallabag",
+    "form.integration.notion_activate": "Save entries to Notion",
+    "form.integration.notion_page_id": "Notion Page ID",
+    "form.integration.notion_token": "Notion Secret Token",
     "form.integration.nunux_keeper_activate": "Salvar itens no Nunux Keeper",
     "form.integration.nunux_keeper_activate": "Salvar itens no Nunux Keeper",
     "form.integration.nunux_keeper_endpoint": "Endpoint de API do Nunux Keeper",
     "form.integration.nunux_keeper_endpoint": "Endpoint de API do Nunux Keeper",
     "form.integration.nunux_keeper_api_key": "Chave de API do Nunux Keeper",
     "form.integration.nunux_keeper_api_key": "Chave de API do Nunux Keeper",

+ 3 - 0
locale/translations/ru_RU.json

@@ -353,6 +353,9 @@
     "form.integration.wallabag_client_secret": "Wallabag Client Secret",
     "form.integration.wallabag_client_secret": "Wallabag Client Secret",
     "form.integration.wallabag_username": "Имя пользователя Wallabag",
     "form.integration.wallabag_username": "Имя пользователя Wallabag",
     "form.integration.wallabag_password": "Пароль Wallabag",
     "form.integration.wallabag_password": "Пароль Wallabag",
+    "form.integration.notion_activate": "Save entries to Notion",
+    "form.integration.notion_page_id": "Notion Page ID",
+    "form.integration.notion_token": "Notion Secret Token",
     "form.integration.nunux_keeper_activate": "Сохранять статьи в Nunux Keeper",
     "form.integration.nunux_keeper_activate": "Сохранять статьи в Nunux Keeper",
     "form.integration.nunux_keeper_endpoint": "Конечная точка Nunux Keeper API",
     "form.integration.nunux_keeper_endpoint": "Конечная точка Nunux Keeper API",
     "form.integration.nunux_keeper_api_key": "API-ключ Nunux Keeper",
     "form.integration.nunux_keeper_api_key": "API-ключ Nunux Keeper",

+ 3 - 0
locale/translations/tr_TR.json

@@ -351,6 +351,9 @@
     "form.integration.wallabag_client_secret": "Wallabag Client Secret",
     "form.integration.wallabag_client_secret": "Wallabag Client Secret",
     "form.integration.wallabag_username": "Wallabag Kullanıcı Adı",
     "form.integration.wallabag_username": "Wallabag Kullanıcı Adı",
     "form.integration.wallabag_password": "Wallabag Parolası",
     "form.integration.wallabag_password": "Wallabag Parolası",
+    "form.integration.notion_activate": "Save entries to Notion",
+    "form.integration.notion_page_id": "Notion Page ID",
+    "form.integration.notion_token": "Notion Secret Token",
     "form.integration.nunux_keeper_activate": "Makaleleri Nunux Keeper'a kaydet",
     "form.integration.nunux_keeper_activate": "Makaleleri Nunux Keeper'a kaydet",
     "form.integration.nunux_keeper_endpoint": "Nunux Keeper API Uç Noktası",
     "form.integration.nunux_keeper_endpoint": "Nunux Keeper API Uç Noktası",
     "form.integration.nunux_keeper_api_key": "Nunux Keeper API anahtarı",
     "form.integration.nunux_keeper_api_key": "Nunux Keeper API anahtarı",

+ 3 - 0
locale/translations/uk_UA.json

@@ -350,6 +350,9 @@
   "form.integration.wallabag_client_secret": "Wallabag Client Secret",
   "form.integration.wallabag_client_secret": "Wallabag Client Secret",
   "form.integration.wallabag_username": "Ім’я користувача Wallabag",
   "form.integration.wallabag_username": "Ім’я користувача Wallabag",
   "form.integration.wallabag_password": "Пароль Wallabag",
   "form.integration.wallabag_password": "Пароль Wallabag",
+  "form.integration.notion_activate": "Save entries to Notion",
+  "form.integration.notion_page_id": "Notion Page ID",
+  "form.integration.notion_token": "Notion Secret Token",
   "form.integration.nunux_keeper_activate": "Зберігати статті до Nunux Keeper",
   "form.integration.nunux_keeper_activate": "Зберігати статті до Nunux Keeper",
   "form.integration.nunux_keeper_endpoint": "Nunux Keeper API Endpoint",
   "form.integration.nunux_keeper_endpoint": "Nunux Keeper API Endpoint",
   "form.integration.nunux_keeper_api_key": "Ключ API Nunux Keeper",
   "form.integration.nunux_keeper_api_key": "Ключ API Nunux Keeper",

+ 3 - 0
locale/translations/zh_CN.json

@@ -349,6 +349,9 @@
     "form.integration.wallabag_client_secret": "Wallabag 客户端 Secret",
     "form.integration.wallabag_client_secret": "Wallabag 客户端 Secret",
     "form.integration.wallabag_username": "Wallabag 用户名",
     "form.integration.wallabag_username": "Wallabag 用户名",
     "form.integration.wallabag_password": "Wallabag 密码",
     "form.integration.wallabag_password": "Wallabag 密码",
+    "form.integration.notion_activate": "Save entries to Notion",
+    "form.integration.notion_page_id": "Notion Page ID",
+    "form.integration.notion_token": "Notion Secret Token",
     "form.integration.nunux_keeper_activate": "保存文章到 Nunux Keeper",
     "form.integration.nunux_keeper_activate": "保存文章到 Nunux Keeper",
     "form.integration.nunux_keeper_endpoint": "Nunux Keeper API 端点",
     "form.integration.nunux_keeper_endpoint": "Nunux Keeper API 端点",
     "form.integration.nunux_keeper_api_key": "Nunux Keeper API 密钥",
     "form.integration.nunux_keeper_api_key": "Nunux Keeper API 密钥",

+ 3 - 0
locale/translations/zh_TW.json

@@ -351,6 +351,9 @@
     "form.integration.wallabag_client_secret": "Wallabag 客戶端 Secret",
     "form.integration.wallabag_client_secret": "Wallabag 客戶端 Secret",
     "form.integration.wallabag_username": "Wallabag 使用者名稱",
     "form.integration.wallabag_username": "Wallabag 使用者名稱",
     "form.integration.wallabag_password": "Wallabag 密碼",
     "form.integration.wallabag_password": "Wallabag 密碼",
+    "form.integration.notion_activate": "Save entries to Notion",
+    "form.integration.notion_page_id": "Notion Page ID",
+    "form.integration.notion_token": "Notion Secret Token",
     "form.integration.nunux_keeper_activate": "儲存文章到 Nunux Keeper",
     "form.integration.nunux_keeper_activate": "儲存文章到 Nunux Keeper",
     "form.integration.nunux_keeper_endpoint": "Nunux Keeper API 端點",
     "form.integration.nunux_keeper_endpoint": "Nunux Keeper API 端點",
     "form.integration.nunux_keeper_api_key": "Nunux Keeper API 金鑰",
     "form.integration.nunux_keeper_api_key": "Nunux Keeper API 金鑰",

+ 3 - 0
model/integration.go

@@ -29,6 +29,9 @@ type Integration struct {
 	NunuxKeeperEnabled   bool
 	NunuxKeeperEnabled   bool
 	NunuxKeeperURL       string
 	NunuxKeeperURL       string
 	NunuxKeeperAPIKey    string
 	NunuxKeeperAPIKey    string
+	NotionEnabled        bool
+	NotionToken          string
+	NotionPageID         string
 	EspialEnabled        bool
 	EspialEnabled        bool
 	EspialURL            string
 	EspialURL            string
 	EspialAPIKey         string
 	EspialAPIKey         string

+ 21 - 3
storage/integration.go

@@ -130,6 +130,9 @@ func (s *Storage) Integration(userID int64) (*model.Integration, error) {
 			wallabag_client_secret,
 			wallabag_client_secret,
 			wallabag_username,
 			wallabag_username,
 			wallabag_password,
 			wallabag_password,
+			notion_enabled,
+			notion_token,
+			notion_page_id,
 			nunux_keeper_enabled,
 			nunux_keeper_enabled,
 			nunux_keeper_url,
 			nunux_keeper_url,
 			nunux_keeper_api_key,
 			nunux_keeper_api_key,
@@ -181,6 +184,9 @@ func (s *Storage) Integration(userID int64) (*model.Integration, error) {
 		&integration.WallabagClientSecret,
 		&integration.WallabagClientSecret,
 		&integration.WallabagUsername,
 		&integration.WallabagUsername,
 		&integration.WallabagPassword,
 		&integration.WallabagPassword,
+		&integration.NotionEnabled,
+		&integration.NotionToken,
+		&integration.NotionPageID,
 		&integration.NunuxKeeperEnabled,
 		&integration.NunuxKeeperEnabled,
 		&integration.NunuxKeeperURL,
 		&integration.NunuxKeeperURL,
 		&integration.NunuxKeeperAPIKey,
 		&integration.NunuxKeeperAPIKey,
@@ -269,7 +275,10 @@ func (s *Storage) UpdateIntegration(integration *model.Integration) error {
 			matrix_bot_user=$40,
 			matrix_bot_user=$40,
 			matrix_bot_password=$41,
 			matrix_bot_password=$41,
 			matrix_bot_url=$42,
 			matrix_bot_url=$42,
-			matrix_bot_chat_id=$43
+			matrix_bot_chat_id=$43,
+			notion_enabled=$45,
+			notion_token=$46,
+			notion_page_id=$47
 		WHERE
 		WHERE
 			user_id=$44
 			user_id=$44
 	`
 	`
@@ -318,6 +327,9 @@ func (s *Storage) UpdateIntegration(integration *model.Integration) error {
 			integration.MatrixBotPassword,
 			integration.MatrixBotPassword,
 			integration.MatrixBotURL,
 			integration.MatrixBotURL,
 			integration.MatrixBotChatID,
 			integration.MatrixBotChatID,
+			integration.NotionEnabled,
+			integration.NotionToken,
+			integration.NotionPageID,
 			integration.UserID,
 			integration.UserID,
 		)
 		)
 	} else {
 	} else {
@@ -367,7 +379,10 @@ func (s *Storage) UpdateIntegration(integration *model.Integration) error {
 		matrix_bot_user=$40,
 		matrix_bot_user=$40,
 		matrix_bot_password=$41,
 		matrix_bot_password=$41,
 		matrix_bot_url=$42,
 		matrix_bot_url=$42,
-		matrix_bot_chat_id=$43
+		matrix_bot_chat_id=$43,
+		notion_enabled=$45,
+		notion_token=$46,
+		notion_page_id=$47
 	WHERE
 	WHERE
 		user_id=$44
 		user_id=$44
 	`
 	`
@@ -417,6 +432,9 @@ func (s *Storage) UpdateIntegration(integration *model.Integration) error {
 			integration.MatrixBotURL,
 			integration.MatrixBotURL,
 			integration.MatrixBotChatID,
 			integration.MatrixBotChatID,
 			integration.UserID,
 			integration.UserID,
+			integration.NotionEnabled,
+			integration.NotionToken,
+			integration.NotionPageID,
 		)
 		)
 	}
 	}
 
 
@@ -437,7 +455,7 @@ func (s *Storage) HasSaveEntry(userID int64) (result bool) {
 		WHERE
 		WHERE
 			user_id=$1
 			user_id=$1
 		AND
 		AND
-			(pinboard_enabled='t' OR instapaper_enabled='t' OR wallabag_enabled='t' OR nunux_keeper_enabled='t' OR espial_enabled='t' OR pocket_enabled='t' OR linkding_enabled='t')
+			(pinboard_enabled='t' OR instapaper_enabled='t' OR wallabag_enabled='t' OR notion_enabled='t' OR nunux_keeper_enabled='t' OR espial_enabled='t' OR pocket_enabled='t' OR linkding_enabled='t')
 	`
 	`
 	if err := s.db.QueryRow(query, userID).Scan(&result); err != nil {
 	if err := s.db.QueryRow(query, userID).Scan(&result); err != nil {
 		result = false
 		result = false

+ 15 - 0
template/templates/views/integrations.html

@@ -142,7 +142,22 @@
             <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>
     </div>
     </div>
+    <h3>Notion</h3>
+    <div class="form-section">
+        <label>
+            <input type="checkbox" name="notion_enabled" value="1" {{ if .form.NotionEnabled }}checked{{ end }}> {{ t "form.integration.notion_activate" }}
+        </label>
+
+        <label for="form-notion-token">{{ t "form.integration.notion_token" }}</label>
+        <input type="password" name="notion_token" id="form-notion-token" value="{{ .form.NotionToken }}" spellcheck="false">
+
+        <label for="form-notion-page-id">{{ t "form.integration.notion_page_id" }}</label>
+        <input type="text" name="notion_page_id" id="form-notion-page-id" value="{{ .form.NotionPageID }}" spellcheck="false">
 
 
+        <div class="buttons">
+            <button type="submit" class="button button-primary" data-label-loading="{{ t "form.submit.saving" }}">{{ t "action.update" }}</button>
+        </div>
+    </div>
     <h3>Nunux Keeper</h3>
     <h3>Nunux Keeper</h3>
     <div class="form-section">
     <div class="form-section">
         <label>
         <label>

+ 9 - 0
ui/form/integration.go

@@ -31,6 +31,9 @@ type IntegrationForm struct {
 	WallabagClientSecret string
 	WallabagClientSecret string
 	WallabagUsername     string
 	WallabagUsername     string
 	WallabagPassword     string
 	WallabagPassword     string
+	NotionEnabled        bool
+	NotionPageID         string
+	NotionToken          string
 	NunuxKeeperEnabled   bool
 	NunuxKeeperEnabled   bool
 	NunuxKeeperURL       string
 	NunuxKeeperURL       string
 	NunuxKeeperAPIKey    string
 	NunuxKeeperAPIKey    string
@@ -76,6 +79,9 @@ 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.NotionEnabled = i.NotionEnabled
+	integration.NotionPageID = i.NotionPageID
+	integration.NotionToken = i.NotionToken
 	integration.NunuxKeeperEnabled = i.NunuxKeeperEnabled
 	integration.NunuxKeeperEnabled = i.NunuxKeeperEnabled
 	integration.NunuxKeeperURL = i.NunuxKeeperURL
 	integration.NunuxKeeperURL = i.NunuxKeeperURL
 	integration.NunuxKeeperAPIKey = i.NunuxKeeperAPIKey
 	integration.NunuxKeeperAPIKey = i.NunuxKeeperAPIKey
@@ -124,6 +130,9 @@ 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"),
+		NotionEnabled:        r.FormValue("notion_enabled") == "1",
+		NotionPageID:         r.FormValue("notion_page_id"),
+		NotionToken:          r.FormValue("notion_token"),
 		NunuxKeeperEnabled:   r.FormValue("nunux_keeper_enabled") == "1",
 		NunuxKeeperEnabled:   r.FormValue("nunux_keeper_enabled") == "1",
 		NunuxKeeperURL:       r.FormValue("nunux_keeper_url"),
 		NunuxKeeperURL:       r.FormValue("nunux_keeper_url"),
 		NunuxKeeperAPIKey:    r.FormValue("nunux_keeper_api_key"),
 		NunuxKeeperAPIKey:    r.FormValue("nunux_keeper_api_key"),

+ 3 - 0
ui/integration_show.go

@@ -46,6 +46,9 @@ 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,
+		NotionEnabled:        integration.NotionEnabled,
+		NotionPageID:         integration.NotionPageID,
+		NotionToken:          integration.NotionToken,
 		NunuxKeeperEnabled:   integration.NunuxKeeperEnabled,
 		NunuxKeeperEnabled:   integration.NunuxKeeperEnabled,
 		NunuxKeeperURL:       integration.NunuxKeeperURL,
 		NunuxKeeperURL:       integration.NunuxKeeperURL,
 		NunuxKeeperAPIKey:    integration.NunuxKeeperAPIKey,
 		NunuxKeeperAPIKey:    integration.NunuxKeeperAPIKey,