diff --git a/modules/backend/src/main/scala/docspell/backend/ops/OUpload.scala b/modules/backend/src/main/scala/docspell/backend/ops/OUpload.scala index 8a0fc672..9183868e 100644 --- a/modules/backend/src/main/scala/docspell/backend/ops/OUpload.scala +++ b/modules/backend/src/main/scala/docspell/backend/ops/OUpload.scala @@ -67,7 +67,8 @@ object OUpload { validFileTypes: Seq[MimeType], skipDuplicates: Boolean, fileFilter: Glob, - tags: List[String] + tags: List[String], + language: Option[Language] ) case class UploadData[F[_]]( @@ -125,11 +126,19 @@ object OUpload { _ <- checkExistingItem(itemId, account.collective) files <- right(data.files.traverse(saveFile).map(_.flatten)) _ <- checkFileList(files) - lang <- right(store.transact(RCollective.findLanguage(account.collective))) + lang <- data.meta.language match { + case Some(lang) => right(lang.pure[F]) + case None => + right( + store + .transact(RCollective.findLanguage(account.collective)) + .map(_.getOrElse(Language.German)) + ) + } meta = ProcessItemArgs.ProcessMeta( account.collective, itemId, - lang.getOrElse(Language.German), + lang, data.meta.direction, data.meta.sourceAbbrev, data.meta.folderId, diff --git a/modules/common/src/main/scala/docspell/common/ScanMailboxArgs.scala b/modules/common/src/main/scala/docspell/common/ScanMailboxArgs.scala index 781a3589..df9fa87d 100644 --- a/modules/common/src/main/scala/docspell/common/ScanMailboxArgs.scala +++ b/modules/common/src/main/scala/docspell/common/ScanMailboxArgs.scala @@ -35,7 +35,9 @@ case class ScanMailboxArgs( // set a list of tags to apply to new item tags: Option[List[String]], // a glob filter for the mail subject - subjectFilter: Option[Glob] + subjectFilter: Option[Glob], + // the language for extraction and analysis + language: Option[Language] ) object ScanMailboxArgs { diff --git a/modules/joex/src/main/scala/docspell/joex/scanmailbox/ScanMailboxTask.scala b/modules/joex/src/main/scala/docspell/joex/scanmailbox/ScanMailboxTask.scala index 3478dd17..4390da3a 100644 --- a/modules/joex/src/main/scala/docspell/joex/scanmailbox/ScanMailboxTask.scala +++ b/modules/joex/src/main/scala/docspell/joex/scanmailbox/ScanMailboxTask.scala @@ -277,7 +277,8 @@ object ScanMailboxTask { Seq.empty, true, args.fileFilter.getOrElse(Glob.all), - args.tags.getOrElse(Nil) + args.tags.getOrElse(Nil), + args.language ) data = OUpload.UploadData( multiple = false, diff --git a/modules/restapi/src/main/resources/docspell-openapi.yml b/modules/restapi/src/main/resources/docspell-openapi.yml index bff39091..4d0cbb04 100644 --- a/modules/restapi/src/main/resources/docspell-openapi.yml +++ b/modules/restapi/src/main/resources/docspell-openapi.yml @@ -3826,6 +3826,12 @@ components: A glob to filter attachments to import by subject. type: string format: glob + language: + description: | + The language used for text extraction and analysis when + processing mails. + type: string + format: language ImapSettingsList: description: | @@ -4601,6 +4607,9 @@ components: The `tags` input allows to provide tags that should be applied to the item being created. This only works if the tags already exist. It is possible to specify their ids or names. + + The `language` of the document may be specified, otherwise the + one from settings is used. required: - multiple properties: @@ -4621,6 +4630,9 @@ components: fileFilter: type: string format: glob + language: + type: string + format: language Collective: description: | diff --git a/modules/restserver/src/main/scala/docspell/restserver/conv/Conversions.scala b/modules/restserver/src/main/scala/docspell/restserver/conv/Conversions.scala index 35a88eaa..48728535 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/conv/Conversions.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/conv/Conversions.scala @@ -326,13 +326,17 @@ trait Conversions { validFileTypes, m.skipDuplicates.getOrElse(false), m.fileFilter.getOrElse(Glob.all), - m.tags.map(_.items).getOrElse(Nil) + m.tags.map(_.items).getOrElse(Nil), + m.language ) ) ) ) .getOrElse( - (true, UploadMeta(None, sourceName, None, validFileTypes, false, Glob.all, Nil)) + ( + true, + UploadMeta(None, sourceName, None, validFileTypes, false, Glob.all, Nil, None) + ) .pure[F] ) diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/ScanMailboxRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/ScanMailboxRoutes.scala index 36ffbd1d..596fd3f6 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/ScanMailboxRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/ScanMailboxRoutes.scala @@ -116,7 +116,8 @@ object ScanMailboxRoutes { settings.itemFolder, settings.fileFilter, settings.tags.map(_.items), - settings.subjectFilter + settings.subjectFilter, + settings.language ) ) ) @@ -147,6 +148,7 @@ object ScanMailboxRoutes { task.args.itemFolder, task.args.tags.map(StringList.apply), task.args.fileFilter, - task.args.subjectFilter + task.args.subjectFilter, + task.args.language ) }