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]
): 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))
})
}

View File

@ -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,

View File

@ -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)
)

View File

@ -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
}