mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-05-28 19:19:15 +00:00
Use source name from config file for integration endpoint uploads
Fixes: #389
This commit is contained in:
parent
0f84200118
commit
0114bb4d72
@ -2,7 +2,8 @@ package docspell.common
|
|||||||
|
|
||||||
object DocspellSystem {
|
object DocspellSystem {
|
||||||
|
|
||||||
val taskGroup = Ident.unsafe("docspell-system")
|
val user = Ident.unsafe("docspell-system")
|
||||||
|
val taskGroup = user
|
||||||
val migrationTaskTracker = Ident.unsafe("full-text-index-tracker")
|
val migrationTaskTracker = Ident.unsafe("full-text-index-tracker")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,10 @@ docspell.server {
|
|||||||
# The priority to use when submitting files through this endpoint.
|
# The priority to use when submitting files through this endpoint.
|
||||||
priority = "low"
|
priority = "low"
|
||||||
|
|
||||||
|
# The name used for the item "source" property when uploaded
|
||||||
|
# through this endpoint.
|
||||||
|
source-name = "integration"
|
||||||
|
|
||||||
# IPv4 addresses to allow access. An empty list, if enabled,
|
# IPv4 addresses to allow access. An empty list, if enabled,
|
||||||
# prohibits all requests. IP addresses may be specified as simple
|
# prohibits all requests. IP addresses may be specified as simple
|
||||||
# globs: a part marked as `*' matches any octet, like in
|
# globs: a part marked as `*' matches any octet, like in
|
||||||
|
@ -28,6 +28,7 @@ object Config {
|
|||||||
case class IntegrationEndpoint(
|
case class IntegrationEndpoint(
|
||||||
enabled: Boolean,
|
enabled: Boolean,
|
||||||
priority: Priority,
|
priority: Priority,
|
||||||
|
sourceName: String,
|
||||||
allowedIps: IntegrationEndpoint.AllowedIps,
|
allowedIps: IntegrationEndpoint.AllowedIps,
|
||||||
httpBasic: IntegrationEndpoint.HttpBasic,
|
httpBasic: IntegrationEndpoint.HttpBasic,
|
||||||
httpHeader: IntegrationEndpoint.HttpHeader
|
httpHeader: IntegrationEndpoint.HttpHeader
|
||||||
|
@ -273,6 +273,7 @@ trait Conversions {
|
|||||||
// upload
|
// upload
|
||||||
def readMultipart[F[_]: Effect](
|
def readMultipart[F[_]: Effect](
|
||||||
mp: Multipart[F],
|
mp: Multipart[F],
|
||||||
|
sourceName: String,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
prio: Priority,
|
prio: Priority,
|
||||||
validFileTypes: Seq[MimeType]
|
validFileTypes: Seq[MimeType]
|
||||||
@ -300,7 +301,7 @@ trait Conversions {
|
|||||||
m.multiple,
|
m.multiple,
|
||||||
UploadMeta(
|
UploadMeta(
|
||||||
m.direction,
|
m.direction,
|
||||||
"webapp",
|
sourceName,
|
||||||
m.folder,
|
m.folder,
|
||||||
validFileTypes,
|
validFileTypes,
|
||||||
m.skipDuplicates.getOrElse(false)
|
m.skipDuplicates.getOrElse(false)
|
||||||
@ -309,7 +310,7 @@ trait Conversions {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
.getOrElse(
|
.getOrElse(
|
||||||
(true, UploadMeta(None, "webapp", None, validFileTypes, false)).pure[F]
|
(true, UploadMeta(None, sourceName, None, validFileTypes, false)).pure[F]
|
||||||
)
|
)
|
||||||
|
|
||||||
val files = mp.parts
|
val files = mp.parts
|
||||||
|
@ -99,11 +99,12 @@ object IntegrationEndpointRoutes {
|
|||||||
multipart <- req.as[Multipart[F]]
|
multipart <- req.as[Multipart[F]]
|
||||||
updata <- readMultipart(
|
updata <- readMultipart(
|
||||||
multipart,
|
multipart,
|
||||||
|
cfg.integrationEndpoint.sourceName,
|
||||||
logger,
|
logger,
|
||||||
cfg.integrationEndpoint.priority,
|
cfg.integrationEndpoint.priority,
|
||||||
cfg.backend.files.validMimeTypes
|
cfg.backend.files.validMimeTypes
|
||||||
)
|
)
|
||||||
account = AccountId(coll, Ident.unsafe("docspell-system"))
|
account = AccountId(coll, DocspellSystem.user)
|
||||||
result <- backend.upload.submit(updata, account, true, None)
|
result <- backend.upload.submit(updata, account, true, None)
|
||||||
res <- Ok(basicResult(result))
|
res <- Ok(basicResult(result))
|
||||||
} yield res
|
} yield res
|
||||||
|
@ -78,6 +78,7 @@ object UploadRoutes {
|
|||||||
multipart <- req.as[Multipart[F]]
|
multipart <- req.as[Multipart[F]]
|
||||||
updata <- readMultipart(
|
updata <- readMultipart(
|
||||||
multipart,
|
multipart,
|
||||||
|
"webapp",
|
||||||
logger,
|
logger,
|
||||||
prio,
|
prio,
|
||||||
cfg.backend.files.validMimeTypes
|
cfg.backend.files.validMimeTypes
|
||||||
|
@ -23,6 +23,7 @@ let
|
|||||||
integration-endpoint = {
|
integration-endpoint = {
|
||||||
enabled = false;
|
enabled = false;
|
||||||
priority = "low";
|
priority = "low";
|
||||||
|
source-name = "integration";
|
||||||
allowed-ips = {
|
allowed-ips = {
|
||||||
enabled = false;
|
enabled = false;
|
||||||
ips = [ "127.0.0.1" ];
|
ips = [ "127.0.0.1" ];
|
||||||
@ -214,6 +215,13 @@ in {
|
|||||||
default = defaults.integration-endpoint.priority;
|
default = defaults.integration-endpoint.priority;
|
||||||
description = "The priority to use when submitting files through this endpoint.";
|
description = "The priority to use when submitting files through this endpoint.";
|
||||||
};
|
};
|
||||||
|
source-name = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = defaults.integration-endpoint.source-name;
|
||||||
|
description = ''
|
||||||
|
The name used for the item "source" property when uploaded through this endpoint.
|
||||||
|
'';
|
||||||
|
};
|
||||||
allowed-ips = mkOption {
|
allowed-ips = mkOption {
|
||||||
type = types.submodule({
|
type = types.submodule({
|
||||||
options = {
|
options = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user