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