Fix uploading to enabled/disabled source endpoints

This commit is contained in:
Eike Kettner 2020-08-09 09:21:23 +02:00
parent 6460315b2b
commit 098e4cf868
4 changed files with 8 additions and 8 deletions

View File

@ -41,7 +41,7 @@ trait OCollective[F[_]] {
kind: Option[ContactKind] kind: Option[ContactKind]
): Stream[F, RContact] ): 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] = ): Stream[F, RContact] =
store.transact(QCollective.getContacts(collective, query, kind)) store.transact(QCollective.getContacts(collective, query, kind))
def findSource(sourceId: Ident): F[Option[RSource]] = def findEnabledSource(sourceId: Ident): F[Option[RSource]] =
store.transact(RSource.find(sourceId)) store.transact(RSource.findEnabled(sourceId))
}) })
} }

View File

@ -147,7 +147,7 @@ object OUpload {
itemId: Option[Ident] itemId: Option[Ident]
): F[OUpload.UploadResult] = ): F[OUpload.UploadResult] =
(for { (for {
src <- OptionT(store.transact(RSource.find(sourceId))) src <- OptionT(store.transact(RSource.findEnabled(sourceId)))
updata = data.copy( updata = data.copy(
meta = data.meta.copy( meta = data.meta.copy(
sourceAbbrev = src.abbrev, sourceAbbrev = src.abbrev,

View File

@ -46,7 +46,7 @@ object UploadRoutes {
HttpRoutes.of { HttpRoutes.of {
case req @ POST -> Root / "item" / Ident(srcId) => case req @ POST -> Root / "item" / Ident(srcId) =>
(for { (for {
_ <- OptionT(backend.collective.findSource(srcId)) _ <- OptionT(backend.collective.findEnabledSource(srcId))
res <- OptionT.liftF( res <- OptionT.liftF(
submitFiles(backend, cfg, Left(srcId))(req, None, Priority.Low, dsl) 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) => case req @ POST -> Root / "item" / Ident(itemId) / Ident(srcId) =>
(for { (for {
_ <- OptionT(backend.collective.findSource(srcId)) _ <- OptionT(backend.collective.findEnabledSource(srcId))
res <- OptionT.liftF( res <- OptionT.liftF(
submitFiles(backend, cfg, Left(srcId))(req, Some(itemId), Priority.Low, dsl) submitFiles(backend, cfg, Left(srcId))(req, Some(itemId), Priority.Low, dsl)
) )

View File

@ -83,8 +83,8 @@ object RSource {
sql.query[Int].unique.map(_ > 0) sql.query[Int].unique.map(_ > 0)
} }
def find(id: Ident): ConnectionIO[Option[RSource]] = { def findEnabled(id: Ident): ConnectionIO[Option[RSource]] = {
val sql = selectSimple(all, table, sid.is(id)) val sql = selectSimple(all, table, and(sid.is(id), enabled.is(true)))
sql.query[RSource].option sql.query[RSource].option
} }