mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-04 10:29:34 +00:00
Allow to specify document lanugage with the request
This commit is contained in:
parent
470471dff6
commit
5fe532001b
@ -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,
|
||||
|
@ -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 {
|
||||
|
@ -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,
|
||||
|
@ -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: |
|
||||
|
@ -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]
|
||||
)
|
||||
|
||||
|
@ -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
|
||||
)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user