From 51722eb1a438328512e0f21d3e8f9115e939ceab Mon Sep 17 00:00:00 2001 From: Xavier Michelon Date: Tue, 21 Nov 2023 09:23:55 +0100 Subject: [PATCH] feat(GODT-3121): introduced knowledgebase package. --- internal/knowledgebase/kbArticleList.json | 263 ++++++++++++++++++++++ internal/knowledgebase/suggester.go | 49 ++++ internal/knowledgebase/suggester_test.go | 42 ++++ 3 files changed, 354 insertions(+) create mode 100644 internal/knowledgebase/kbArticleList.json create mode 100644 internal/knowledgebase/suggester.go create mode 100644 internal/knowledgebase/suggester_test.go diff --git a/internal/knowledgebase/kbArticleList.json b/internal/knowledgebase/kbArticleList.json new file mode 100644 index 00000000..438b7094 --- /dev/null +++ b/internal/knowledgebase/kbArticleList.json @@ -0,0 +1,263 @@ +[ + { + "url": "https://proton.me/support/automatically-start-bridge", + "title": "Automatically start Bridge", + "keywords": [ + "start", + "automatically", + "login" + ] + }, + { + "url": "https://proton.me/support/bridge-automatic-update", + "title": "Automatic Update and Bridge", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/messages-encrypted-via-bridge", + "title": "Are my messages encrypted via Proton Mail Bridge?", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/labels-in-bridge", + "title": "Labels in Bridge", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/bridge-ssl-connection-issue", + "title": "Proton Mail Bridge connection issues with Thunderbird, Outlook, and Apple Mail", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/sending-pgp-emails-bridge", + "title": "Sending PGP emails in Proton Mail Bridge", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/difference-combined-addresses-mode-split-addresses-mode", + "title": "Difference between combined addresses mode and split addresses mode", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/thunderbird-connection-server-timed-error", + "title": "Thunderbird: 'Connection to server timed out' error", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/update-required", + "title": "Update required", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/port-already-occupied-error", + "title": "Port already occupied error", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/clients-supported-bridge", + "title": "Email clients supported by Proton Mail Bridge", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/imap-smtp-and-pop3-setup", + "title": "IMAP, SMTP, and POP3 setup", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/protonmail-bridge-install", + "title": "How to install Proton Mail Bridge", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/bridge-for-linux", + "title": "Proton Mail Bridge for Linux", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/operating-systems-supported-bridge", + "title": "System requirements for Proton Mail Bridge", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/protonmail-bridge-configure-client", + "title": "How to configure your email client for Proton Mail Bridge", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/invalid-password-error-setting-email-client", + "title": "Invalid password error while setting up email client", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/protonmail-bridge-clients-windows-outlook-2019", + "title": "Proton Mail Bridge Microsoft Outlook for Windows 2019 setup guide", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/protonmail-bridge-clients-windows-outlook-2016", + "title": "Proton Mail Bridge Microsoft Outlook 2016 for Windows setup guide", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/protonmail-bridge-clients-apple-mail", + "title": "Proton Mail Bridge Apple Mail setup guide", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/protonmail-bridge-clients-macos-new-outlook", + "title": "Proton Mail Bridge new Outlook for macOS setup guide", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/protonmail-bridge-clients-windows-thunderbird", + "title": "Proton Mail Bridge Thunderbird setup guide for Windows, macOS, and Linux", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/protonmail-bridge-clients-macos-outlook-2016", + "title": "Proton Mail Bridge Microsoft Outlook 2016 for macOS setup guide", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/protonmail-bridge-clients-macos-outlook-2019", + "title": "Proton Mail Bridge Microsoft Outlook 2019 for macOS setup guide", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/protonmail-bridge-clients-windows-outlook-2013", + "title": "Proton Mail Bridge Microsoft Outlook 2013 for Windows setup guide", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/protonmail-bridge-clients-macos-outlook-2011", + "title": "Proton Mail Bridge Microsoft Outlook 2011 for macOS setup guide", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/install-bridge-linux-pkgbuild-file", + "title": "Installing Proton Mail Bridge for Linux using a PKGBUILD file", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/installing-bridge-linux-deb-file", + "title": "Installing Proton Mail Bridge for Linux using a DEB file", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/verifying-bridge-package", + "title": "Verifying the Proton Mail Bridge package for Linux", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/bridge-cli-guide", + "title": "Bridge CLI (command line interface) guide", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/install-bridge-linux-rpm-file", + "title": "Installing Proton Mail Bridge for Linux using an RPM file", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/bridge-linux-login-error", + "title": "How to fix Proton Bridge login errors", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/bridge-linux-tray-icon", + "title": "How to fix a missing system tray icon in Linux", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/why-you-need-bridge", + "title": "Why you need Proton Mail Bridge", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/protonmail-bridge-manual-update", + "title": "How to manually update Proton Mail Bridge", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/macos-certificate-warning", + "title": "Warning when installing Proton Mail Bridge on macOS", + "keywords": [ + "TBD" + ] + }, + { + "url": "https://proton.me/support/apple-mail-certificate", + "title": "Why you need to install a certificate for Apple Mail with Proton Mail Bridge", + "keywords": [ + "TBD" + ] + } + ] diff --git a/internal/knowledgebase/suggester.go b/internal/knowledgebase/suggester.go new file mode 100644 index 00000000..cde16198 --- /dev/null +++ b/internal/knowledgebase/suggester.go @@ -0,0 +1,49 @@ +// Copyright (c) 2023 Proton AG +// +// This file is part of Proton Mail Bridge. +// +// Proton Mail Bridge is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Proton Mail Bridge is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Proton Mail Bridge. If not, see . + +package knowledgebase + +import ( + _ "embed" + "encoding/json" +) + +//go:embed kbArticleList.json +var articleListString []byte + +// Article is a struct that holds information about a knowledge-base article. +type Article struct { + URL string `json:"url"` + Title string `json:"title"` + Keywords []string `json:"keywords"` +} + +type ArticleList []Article + +// getArticleList returns the list of KB articles. +func getArticleList() (ArticleList, error) { + var articles ArticleList + err := json.Unmarshal(articleListString, &articles) + + return articles, err +} + +// GetSuggestions return a list of up to 3 suggestions for KB articles matching the given user input. +func GetSuggestions(_ string) (ArticleList, error) { + // TBD + return ArticleList{}, nil +} diff --git a/internal/knowledgebase/suggester_test.go b/internal/knowledgebase/suggester_test.go new file mode 100644 index 00000000..7a616928 --- /dev/null +++ b/internal/knowledgebase/suggester_test.go @@ -0,0 +1,42 @@ +// Copyright (c) 2023 Proton AG +// +// This file is part of Proton Mail Bridge. +// +// Proton Mail Bridge is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Proton Mail Bridge is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Proton Mail Bridge. If not, see . + +package knowledgebase + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func Test_ArticleList(t *testing.T) { + articles, err := getArticleList() + require.NoError(t, err) + require.NotEmpty(t, articles) + + for _, article := range articles { + require.NotEmpty(t, article.URL) + require.NotEmpty(t, article.Title) + require.NotEmpty(t, article.Keywords) + } +} + +func Test_GetSuggestions(t *testing.T) { + suggestions, err := GetSuggestions("") + require.NoError(t, err) + require.Empty(t, suggestions) +}