From a9dff0fcb015c0173e253ae7c50cf490509040d2 Mon Sep 17 00:00:00 2001 From: Max Magorsch Date: Fri, 19 Jun 2020 17:45:02 +0200 Subject: Only import messages of public lists for now Signed-off-by: Max Magorsch --- pkg/importer/importer.go | 4 +++- pkg/importer/utils.go | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'pkg') diff --git a/pkg/importer/importer.go b/pkg/importer/importer.go index a989238..379332c 100644 --- a/pkg/importer/importer.go +++ b/pkg/importer/importer.go @@ -14,7 +14,9 @@ func FullImport() { return err } if !info.IsDir() && getDepth(path, config.MailDirPath()) >= 1 { - importMail(info.Name(), path, config.MailDirPath()) + if isPublicList(path) { + importMail(info.Name(), path, config.MailDirPath()) + } } return nil }) diff --git a/pkg/importer/utils.go b/pkg/importer/utils.go index 5672577..c2d38fc 100644 --- a/pkg/importer/utils.go +++ b/pkg/importer/utils.go @@ -1,6 +1,7 @@ package importer import ( + "archives/pkg/config" "archives/pkg/database" "archives/pkg/models" "fmt" @@ -123,3 +124,12 @@ func insertMessage(message models.Message) error { Insert() return err } + +func isPublicList(path string) bool { + for _, publicList := range config.AllPublicMailingLists(){ + if strings.HasPrefix(path, config.MailDirPath() + "." + publicList + "/") { + return true + } + } + return false +} -- cgit v1.2.3-65-gdbad