mirror of
				https://github.com/TheAnachronism/docspell.git
				synced 2025-10-31 09:30:12 +00:00 
			
		
		
		
	Fix uploading to enabled/disabled source endpoints
This commit is contained in:
		| @@ -41,7 +41,7 @@ trait OCollective[F[_]] { | ||||
|       kind: Option[ContactKind] | ||||
|   ): Stream[F, RContact] | ||||
|  | ||||
|   def findSource(sourceId: Ident): F[Option[RSource]] | ||||
|   def findEnabledSource(sourceId: Ident): F[Option[RSource]] | ||||
|  | ||||
| } | ||||
|  | ||||
| @@ -158,7 +158,7 @@ object OCollective { | ||||
|       ): Stream[F, RContact] = | ||||
|         store.transact(QCollective.getContacts(collective, query, kind)) | ||||
|  | ||||
|       def findSource(sourceId: Ident): F[Option[RSource]] = | ||||
|         store.transact(RSource.find(sourceId)) | ||||
|       def findEnabledSource(sourceId: Ident): F[Option[RSource]] = | ||||
|         store.transact(RSource.findEnabled(sourceId)) | ||||
|     }) | ||||
| } | ||||
|   | ||||
| @@ -147,7 +147,7 @@ object OUpload { | ||||
|           itemId: Option[Ident] | ||||
|       ): F[OUpload.UploadResult] = | ||||
|         (for { | ||||
|           src <- OptionT(store.transact(RSource.find(sourceId))) | ||||
|           src <- OptionT(store.transact(RSource.findEnabled(sourceId))) | ||||
|           updata = data.copy( | ||||
|             meta = data.meta.copy( | ||||
|               sourceAbbrev = src.abbrev, | ||||
|   | ||||
| @@ -46,7 +46,7 @@ object UploadRoutes { | ||||
|     HttpRoutes.of { | ||||
|       case req @ POST -> Root / "item" / Ident(srcId) => | ||||
|         (for { | ||||
|           _ <- OptionT(backend.collective.findSource(srcId)) | ||||
|           _ <- OptionT(backend.collective.findEnabledSource(srcId)) | ||||
|           res <- OptionT.liftF( | ||||
|             submitFiles(backend, cfg, Left(srcId))(req, None, Priority.Low, dsl) | ||||
|           ) | ||||
| @@ -54,7 +54,7 @@ object UploadRoutes { | ||||
|  | ||||
|       case req @ POST -> Root / "item" / Ident(itemId) / Ident(srcId) => | ||||
|         (for { | ||||
|           _ <- OptionT(backend.collective.findSource(srcId)) | ||||
|           _ <- OptionT(backend.collective.findEnabledSource(srcId)) | ||||
|           res <- OptionT.liftF( | ||||
|             submitFiles(backend, cfg, Left(srcId))(req, Some(itemId), Priority.Low, dsl) | ||||
|           ) | ||||
|   | ||||
| @@ -83,8 +83,8 @@ object RSource { | ||||
|     sql.query[Int].unique.map(_ > 0) | ||||
|   } | ||||
|  | ||||
|   def find(id: Ident): ConnectionIO[Option[RSource]] = { | ||||
|     val sql = selectSimple(all, table, sid.is(id)) | ||||
|   def findEnabled(id: Ident): ConnectionIO[Option[RSource]] = { | ||||
|     val sql = selectSimple(all, table, and(sid.is(id), enabled.is(true))) | ||||
|     sql.query[RSource].option | ||||
|   } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user