mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Allow a collective to disable the integration endpoint
This commit is contained in:
@ -4,6 +4,7 @@ import cats.effect._
|
||||
import cats.implicits._
|
||||
import docspell.backend.BackendApp
|
||||
import docspell.backend.auth.AuthToken
|
||||
import docspell.backend.ops.OCollective
|
||||
import docspell.restapi.model._
|
||||
import docspell.restserver.conv.Conversions
|
||||
import docspell.restserver.http4s._
|
||||
@ -28,16 +29,17 @@ object CollectiveRoutes {
|
||||
case req @ POST -> Root / "settings" =>
|
||||
for {
|
||||
settings <- req.as[CollectiveSettings]
|
||||
sett = OCollective.Settings(settings.language, settings.integrationEnabled)
|
||||
res <-
|
||||
backend.collective
|
||||
.updateLanguage(user.account.collective, settings.language)
|
||||
resp <- Ok(Conversions.basicResult(res, "Language updated."))
|
||||
.updateSettings(user.account.collective, sett)
|
||||
resp <- Ok(Conversions.basicResult(res, "Settings updated."))
|
||||
} yield resp
|
||||
|
||||
case GET -> Root / "settings" =>
|
||||
for {
|
||||
collDb <- backend.collective.find(user.account.collective)
|
||||
sett = collDb.map(c => CollectiveSettings(c.language))
|
||||
sett = collDb.map(c => CollectiveSettings(c.language, c.integrationEnabled))
|
||||
resp <- sett.toResponse()
|
||||
} yield resp
|
||||
|
||||
|
@ -59,7 +59,7 @@ object IntegrationEndpointRoutes {
|
||||
): EitherT[F, Response[F], Unit] =
|
||||
for {
|
||||
opt <- EitherT.liftF(backend.collective.find(coll))
|
||||
res <- EitherT.cond[F](opt.isDefined, (), Response.notFound[F])
|
||||
res <- EitherT.cond[F](opt.exists(_.integrationEnabled), (), Response.notFound[F])
|
||||
} yield res
|
||||
|
||||
def uploadFile[F[_]: Effect](
|
||||
|
@ -12,7 +12,8 @@ case class Flags(
|
||||
appName: String,
|
||||
baseUrl: LenientUri,
|
||||
signupMode: SignupConfig.Mode,
|
||||
docspellAssetPath: String
|
||||
docspellAssetPath: String,
|
||||
integrationEnabled: Boolean
|
||||
)
|
||||
|
||||
object Flags {
|
||||
@ -21,7 +22,8 @@ object Flags {
|
||||
cfg.appName,
|
||||
cfg.baseUrl,
|
||||
cfg.backend.signup.mode,
|
||||
s"/app/assets/docspell-webapp/${BuildInfo.version}"
|
||||
s"/app/assets/docspell-webapp/${BuildInfo.version}",
|
||||
cfg.integrationEndpoint.enabled
|
||||
)
|
||||
|
||||
implicit val jsonEncoder: Encoder[Flags] =
|
||||
|
Reference in New Issue
Block a user