diff --git a/modules/addonlib/src/test/scala/docspell/addons/AddonExecutorTest.scala b/modules/addonlib/src/test/scala/docspell/addons/AddonExecutorTest.scala index ec2bd862..940fe091 100644 --- a/modules/addonlib/src/test/scala/docspell/addons/AddonExecutorTest.scala +++ b/modules/addonlib/src/test/scala/docspell/addons/AddonExecutorTest.scala @@ -142,7 +142,7 @@ class AddonExecutorTest extends CatsEffectSuite with Fixtures with TestLoggingCo AddonExecutionResult.executionResultMonoid .combine( AddonExecutionResult.empty, - AddonExecutionResult(Nil, true) + AddonExecutionResult(Nil, pure = true) ) .pure ) diff --git a/modules/addonlib/src/test/scala/docspell/addons/AddonGenerator.scala b/modules/addonlib/src/test/scala/docspell/addons/AddonGenerator.scala index 63c162ee..1f80f5d2 100644 --- a/modules/addonlib/src/test/scala/docspell/addons/AddonGenerator.scala +++ b/modules/addonlib/src/test/scala/docspell/addons/AddonGenerator.scala @@ -27,9 +27,9 @@ object AddonGenerator { ): Resource[IO, AddonArchive] = output match { case None => - generate(name, version, false)("exit 0") + generate(name, version, collectOutput = false)("exit 0") case Some(out) => - generate(name, version, true)( + generate(name, version, collectOutput = true)( s""" |cat <<-EOF |${out.asJson.noSpaces} @@ -77,8 +77,9 @@ object AddonGenerator { meta = AddonMeta.Meta(name, version, None), triggers = Set(AddonTriggerType.ExistingItem: AddonTriggerType).some, args = None, - runner = - AddonMeta.Runner(None, None, AddonMeta.TrivialRunner(true, "addon.sh").some).some, + runner = AddonMeta + .Runner(None, None, AddonMeta.TrivialRunner(enable = true, "addon.sh").some) + .some, options = AddonMeta.Options(networking = !collectOutput, collectOutput = collectOutput).some ) diff --git a/modules/addonlib/src/test/scala/docspell/addons/Fixtures.scala b/modules/addonlib/src/test/scala/docspell/addons/Fixtures.scala index 12cb24c8..f169d3dd 100644 --- a/modules/addonlib/src/test/scala/docspell/addons/Fixtures.scala +++ b/modules/addonlib/src/test/scala/docspell/addons/Fixtures.scala @@ -40,13 +40,13 @@ trait Fixtures extends TestLoggingConfig { self: CatsEffectSuite => ), None, runner = Runner( - nix = NixRunner(true).some, + nix = NixRunner(enable = true).some, docker = DockerRunner( enable = true, image = None, build = "Dockerfile".some ).some, - trivial = TrivialRunner(true, "src/addon.sh").some + trivial = TrivialRunner(enable = true, "src/addon.sh").some ).some, options = Options(networking = true, collectOutput = true).some ) @@ -65,7 +65,7 @@ trait Fixtures extends TestLoggingConfig { self: CatsEffectSuite => runner: RunnerType, runners: RunnerType* ): AddonExecutorConfig = { - val nspawn = NSpawn(false, "sudo", "systemd-nspawn", Duration.millis(100)) + val nspawn = NSpawn(enabled = false, "sudo", "systemd-nspawn", Duration.millis(100)) AddonExecutorConfig( runner = runner :: runners.toList, runTimeout = Duration.minutes(2), diff --git a/modules/analysis/src/test/scala/docspell/analysis/nlp/StanfordNerAnnotatorSuite.scala b/modules/analysis/src/test/scala/docspell/analysis/nlp/StanfordNerAnnotatorSuite.scala index 15bc0704..fc4b0010 100644 --- a/modules/analysis/src/test/scala/docspell/analysis/nlp/StanfordNerAnnotatorSuite.scala +++ b/modules/analysis/src/test/scala/docspell/analysis/nlp/StanfordNerAnnotatorSuite.scala @@ -22,7 +22,7 @@ import munit._ class StanfordNerAnnotatorSuite extends FunSuite with TestLoggingConfig { lazy val germanClassifier = - new StanfordCoreNLP(Properties.nerGerman(None, false)) + new StanfordCoreNLP(Properties.nerGerman(None, highRecall = false)) lazy val englishClassifier = new StanfordCoreNLP(Properties.nerEnglish(None)) diff --git a/modules/backend/src/main/scala/docspell/backend/Config.scala b/modules/backend/src/main/scala/docspell/backend/Config.scala index 721f30d5..9f4497fc 100644 --- a/modules/backend/src/main/scala/docspell/backend/Config.scala +++ b/modules/backend/src/main/scala/docspell/backend/Config.scala @@ -90,6 +90,6 @@ object Config { } object Addons { val disabled: Addons = - Addons(false, false, UrlMatcher.False, UrlMatcher.True) + Addons(enabled = false, allowImpure = false, UrlMatcher.False, UrlMatcher.True) } } diff --git a/modules/backend/src/main/scala/docspell/backend/auth/Login.scala b/modules/backend/src/main/scala/docspell/backend/auth/Login.scala index f8003505..00403b7f 100644 --- a/modules/backend/src/main/scala/docspell/backend/auth/Login.scala +++ b/modules/backend/src/main/scala/docspell/backend/auth/Login.scala @@ -127,7 +127,7 @@ object Login { _ <- logF.trace(s"Account lookup: $data") res <- data match { case Some(d) if checkNoPassword(d, Set(AccountSource.OpenId)) => - doLogin(config, d.account, false) + doLogin(config, d.account, rememberMe = false) case Some(d) if checkNoPassword(d, Set(AccountSource.Local)) => config.onAccountSourceConflict match { case OnAccountSourceConflict.Fail => @@ -145,7 +145,7 @@ object Login { AccountSource.OpenId ) ) - res <- doLogin(config, d.account, false) + res <- doLogin(config, d.account, rememberMe = false) } yield res } case _ => @@ -212,7 +212,12 @@ object Login { val okResult: F[Result] = for { _ <- store.transact(RUser.updateLogin(sf.token.account)) - newToken <- AuthToken.user(sf.token.account, false, config.serverSecret, None) + newToken <- AuthToken.user( + sf.token.account, + requireSecondFactor = false, + config.serverSecret, + None + ) rem <- OptionT .whenF(sf.rememberMe && config.rememberMe.enabled)( insertRememberToken(store, sf.token.account, config) @@ -239,7 +244,9 @@ object Login { (for { _ <- validateToken key <- EitherT.fromOptionF( - store.transact(RTotp.findEnabledByUserId(sf.token.account.userId, true)), + store.transact( + RTotp.findEnabledByUserId(sf.token.account.userId, enabled = true) + ), Result.invalidAuth ) now <- EitherT.right[Result](Timestamp.current[F]) @@ -255,7 +262,12 @@ object Login { def okResult(acc: AccountInfo) = for { _ <- store.transact(RUser.updateLogin(acc)) - token <- AuthToken.user(acc, false, config.serverSecret, None) + token <- AuthToken.user( + acc, + requireSecondFactor = false, + config.serverSecret, + None + ) } yield Result.ok(token, None) def rememberedLogin(rid: Ident) = diff --git a/modules/backend/src/main/scala/docspell/backend/joex/AddonOps.scala b/modules/backend/src/main/scala/docspell/backend/joex/AddonOps.scala index 1cfa2a9e..52ccaf8c 100644 --- a/modules/backend/src/main/scala/docspell/backend/joex/AddonOps.scala +++ b/modules/backend/src/main/scala/docspell/backend/joex/AddonOps.scala @@ -93,7 +93,7 @@ object AddonOps { AddonResult.executionFailed( new Exception(s"Addon run config ${id.id} not found.") ) :: Nil, - false + pure = false ) :: Nil, Nil ) diff --git a/modules/backend/src/main/scala/docspell/backend/joex/AddonPrepare.scala b/modules/backend/src/main/scala/docspell/backend/joex/AddonPrepare.scala index 505b781d..63d4c7d0 100644 --- a/modules/backend/src/main/scala/docspell/backend/joex/AddonPrepare.scala +++ b/modules/backend/src/main/scala/docspell/backend/joex/AddonPrepare.scala @@ -72,7 +72,7 @@ private[joex] class AddonPrepare[F[_]: Sync](store: Store[F]) extends LoggerExte token <- AuthToken.user( account, - false, + requireSecondFactor = false, secret.getOrElse(ByteVector.empty), tokenValidity.some ) diff --git a/modules/backend/src/main/scala/docspell/backend/ops/OCollective.scala b/modules/backend/src/main/scala/docspell/backend/ops/OCollective.scala index d96a7333..b75db20e 100644 --- a/modules/backend/src/main/scala/docspell/backend/ops/OCollective.scala +++ b/modules/backend/src/main/scala/docspell/backend/ops/OCollective.scala @@ -194,7 +194,14 @@ object OCollective { id <- Ident.randomId[F] settings = sett.emptyTrash.getOrElse(EmptyTrash.default) args = EmptyTrashArgs(cid, settings.minAge) - ut = UserTask(id, EmptyTrashArgs.taskName, true, settings.schedule, None, args) + ut = UserTask( + id, + EmptyTrashArgs.taskName, + enabled = true, + settings.schedule, + None, + args + ) _ <- uts.updateOneTask(UserTaskScope.collective(cid), args.makeSubject.some, ut) _ <- joex.notifyAllNodes } yield () @@ -220,7 +227,7 @@ object OCollective { ut = UserTask( id, LearnClassifierArgs.taskName, - true, + enabled = true, CalEvent(WeekdayComponent.All, DateEvent.All, TimeEvent.All), None, args @@ -239,7 +246,7 @@ object OCollective { ut = UserTask( id, EmptyTrashArgs.taskName, - true, + enabled = true, CalEvent(WeekdayComponent.All, DateEvent.All, TimeEvent.All), None, args diff --git a/modules/backend/src/main/scala/docspell/backend/ops/ONotification.scala b/modules/backend/src/main/scala/docspell/backend/ops/ONotification.scala index 445efab6..1cfb793b 100644 --- a/modules/backend/src/main/scala/docspell/backend/ops/ONotification.scala +++ b/modules/backend/src/main/scala/docspell/backend/ops/ONotification.scala @@ -114,14 +114,14 @@ object ONotification { ) _ <- notMod.send(logbuf._2.andThen(log), ev, ch) logs <- logbuf._1.get - res = SendTestResult(true, logs) + res = SendTestResult(success = true, logs) } yield res).attempt .map { case Right(res) => res case Left(ex) => val ev = LogEvent.of(Level.Error, "Failed sending sample event").addError(ex) - SendTestResult(false, Vector(ev)) + SendTestResult(success = false, Vector(ev)) } def listChannels(userId: Ident): F[Vector[Channel]] = diff --git a/modules/backend/src/main/scala/docspell/backend/ops/OTotp.scala b/modules/backend/src/main/scala/docspell/backend/ops/OTotp.scala index 4f18a52a..768ba552 100644 --- a/modules/backend/src/main/scala/docspell/backend/ops/OTotp.scala +++ b/modules/backend/src/main/scala/docspell/backend/ops/OTotp.scala @@ -120,7 +120,9 @@ object OTotp { def confirmInit(accountId: AccountInfo, otp: OnetimePassword): F[ConfirmResult] = for { _ <- log.info(s"Confirm TOTP setup for account ${accountId.asString}") - key <- store.transact(RTotp.findEnabledByUserId(accountId.userId, false)) + key <- store.transact( + RTotp.findEnabledByUserId(accountId.userId, enabled = false) + ) now <- Timestamp.current[F] res <- key match { case None => @@ -129,7 +131,7 @@ object OTotp { val check = totp.checkPassword(r.secret, otp, now.value) if (check) store - .transact(RTotp.setEnabled(accountId.userId, true)) + .transact(RTotp.setEnabled(accountId.userId, enabled = true)) .map(_ => ConfirmResult.Success) else ConfirmResult.Failed.pure[F] } @@ -140,7 +142,7 @@ object OTotp { case Some(pw) => for { _ <- log.info(s"Validating TOTP, because it is requested to disable it.") - key <- store.transact(RTotp.findEnabledByLogin(accountId, true)) + key <- store.transact(RTotp.findEnabledByLogin(accountId, enabled = true)) now <- Timestamp.current[F] res <- key match { case None => @@ -149,7 +151,7 @@ object OTotp { val check = totp.checkPassword(r.secret, pw, now.value) if (check) UpdateResult.fromUpdate( - store.transact(RTotp.setEnabled(r.userId, false)) + store.transact(RTotp.setEnabled(r.userId, enabled = false)) ) else log.info(s"TOTP code was invalid. Not disabling it.") *> UpdateResult @@ -160,15 +162,15 @@ object OTotp { case None => UpdateResult.fromUpdate { (for { - key <- OptionT(RTotp.findEnabledByLogin(accountId, true)) - n <- OptionT.liftF(RTotp.setEnabled(key.userId, false)) + key <- OptionT(RTotp.findEnabledByLogin(accountId, enabled = true)) + n <- OptionT.liftF(RTotp.setEnabled(key.userId, enabled = false)) } yield n).mapK(store.transform).getOrElse(0) } } def state(acc: AccountInfo): F[OtpState] = for { - record <- store.transact(RTotp.findEnabledByUserId(acc.userId, true)) + record <- store.transact(RTotp.findEnabledByUserId(acc.userId, enabled = true)) result = record match { case Some(r) => OtpState.Enabled(r.created) diff --git a/modules/backend/src/main/scala/docspell/backend/ops/OUpload.scala b/modules/backend/src/main/scala/docspell/backend/ops/OUpload.scala index 398543d4..a5e5f9eb 100644 --- a/modules/backend/src/main/scala/docspell/backend/ops/OUpload.scala +++ b/modules/backend/src/main/scala/docspell/backend/ops/OUpload.scala @@ -159,7 +159,7 @@ object OUpload { data.meta.skipDuplicates, data.meta.fileFilter.some, data.meta.tags.some, - false, + reprocess = false, data.meta.attachmentsOnly, data.meta.customData ) diff --git a/modules/backend/src/test/scala/docspell/backend/auth/AuthTokenTest.scala b/modules/backend/src/test/scala/docspell/backend/auth/AuthTokenTest.scala index 8c6e111f..4f453bf3 100644 --- a/modules/backend/src/test/scala/docspell/backend/auth/AuthTokenTest.scala +++ b/modules/backend/src/test/scala/docspell/backend/auth/AuthTokenTest.scala @@ -32,9 +32,12 @@ class AuthTokenTest extends CatsEffectSuite { val otherSecret = ByteVector.fromValidHex("16bad") test("validate") { - val token1 = AuthToken.user[IO](user, false, secret, None).unsafeRunSync() + val token1 = + AuthToken.user[IO](user, requireSecondFactor = false, secret, None).unsafeRunSync() val token2 = - AuthToken.user[IO](user, false, secret, Duration.seconds(10).some).unsafeRunSync() + AuthToken + .user[IO](user, requireSecondFactor = false, secret, Duration.seconds(10).some) + .unsafeRunSync() assert(token1.validate(secret, Duration.seconds(5))) assert(!token1.validate(otherSecret, Duration.seconds(5))) assert(!token1.copy(account = john).validate(secret, Duration.seconds(5))) @@ -46,9 +49,12 @@ class AuthTokenTest extends CatsEffectSuite { } test("signature") { - val token1 = AuthToken.user[IO](user, false, secret, None).unsafeRunSync() + val token1 = + AuthToken.user[IO](user, requireSecondFactor = false, secret, None).unsafeRunSync() val token2 = - AuthToken.user[IO](user, false, secret, Duration.seconds(10).some).unsafeRunSync() + AuthToken + .user[IO](user, requireSecondFactor = false, secret, Duration.seconds(10).some) + .unsafeRunSync() assert(token1.sigValid(secret)) assert(token1.sigInvalid(otherSecret)) diff --git a/modules/common/src/main/scala/docspell/common/LenientUri.scala b/modules/common/src/main/scala/docspell/common/LenientUri.scala index c9f797ab..2e2e17a0 100644 --- a/modules/common/src/main/scala/docspell/common/LenientUri.scala +++ b/modules/common/src/main/scala/docspell/common/LenientUri.scala @@ -78,7 +78,11 @@ case class LenientUri( .covary[F] .rethrow .flatMap(url => - fs2.io.readInputStream(Sync[F].delay(url.openStream()), chunkSize, true) + fs2.io.readInputStream( + Sync[F].delay(url.openStream()), + chunkSize, + closeAfterUse = true + ) ) def readText[F[_]: Sync](chunkSize: Int): F[String] = @@ -121,7 +125,7 @@ object LenientUri { val isRoot = true val isEmpty = false def /(seg: String): Path = - NonEmptyPath(NonEmptyList.of(seg), false) + NonEmptyPath(NonEmptyList.of(seg), trailingSlash = false) def asString = "/" } case object EmptyPath extends Path { @@ -129,7 +133,7 @@ object LenientUri { val isRoot = false val isEmpty = true def /(seg: String): Path = - NonEmptyPath(NonEmptyList.of(seg), false) + NonEmptyPath(NonEmptyList.of(seg), trailingSlash = false) def asString = "" } case class NonEmptyPath(segs: NonEmptyList[String], trailingSlash: Boolean) diff --git a/modules/common/src/main/scala/docspell/common/MimeType.scala b/modules/common/src/main/scala/docspell/common/MimeType.scala index 9a0e29af..8b74a2c7 100644 --- a/modules/common/src/main/scala/docspell/common/MimeType.scala +++ b/modules/common/src/main/scala/docspell/common/MimeType.scala @@ -194,7 +194,7 @@ object MimeType { val csValueStart = in.substring(n + "charset=".length).trim val csName = csValueStart.indexOf(';') match { case -1 => unquote(csValueStart).trim - case n => unquote(csValueStart.substring(0, n)).trim + case n2 => unquote(csValueStart.substring(0, n2)).trim } if (Charset.isSupported(csName)) Right((Some(Charset.forName(csName)), "")) else Right((None, "")) diff --git a/modules/common/src/main/scala/docspell/common/UrlMatcher.scala b/modules/common/src/main/scala/docspell/common/UrlMatcher.scala index de978dd9..7c58d5d7 100644 --- a/modules/common/src/main/scala/docspell/common/UrlMatcher.scala +++ b/modules/common/src/main/scala/docspell/common/UrlMatcher.scala @@ -62,7 +62,7 @@ object UrlMatcher { // strip path to only match prefixes val mPath: LenientUri.Path = NonEmptyList.fromList(url.path.segments.take(pathSegmentCount)) match { - case Some(nel) => LenientUri.NonEmptyPath(nel, false) + case Some(nel) => LenientUri.NonEmptyPath(nel, trailingSlash = false) case None => LenientUri.RootPath } diff --git a/modules/convert/src/main/scala/docspell/convert/extern/OcrMyPdf.scala b/modules/convert/src/main/scala/docspell/convert/extern/OcrMyPdf.scala index 1fc778ef..1150d913 100644 --- a/modules/convert/src/main/scala/docspell/convert/extern/OcrMyPdf.scala +++ b/modules/convert/src/main/scala/docspell/convert/extern/OcrMyPdf.scala @@ -31,7 +31,7 @@ object OcrMyPdf { "ocrmypdf", cfg.command.replace(Map("{{lang}}" -> lang.iso3)), cfg.workingDir, - false, + useStdin = false, logger, reader )(in, handler) diff --git a/modules/convert/src/main/scala/docspell/convert/extern/Tesseract.scala b/modules/convert/src/main/scala/docspell/convert/extern/Tesseract.scala index 95875f8f..39007c6c 100644 --- a/modules/convert/src/main/scala/docspell/convert/extern/Tesseract.scala +++ b/modules/convert/src/main/scala/docspell/convert/extern/Tesseract.scala @@ -31,7 +31,7 @@ object Tesseract { "tesseract", cfg.command.replace(Map("{{lang}}" -> lang.iso3)), cfg.workingDir, - false, + useStdin = false, logger, reader )(in, handler) diff --git a/modules/convert/src/main/scala/docspell/convert/extern/Unoconv.scala b/modules/convert/src/main/scala/docspell/convert/extern/Unoconv.scala index cbe0db87..01b9a444 100644 --- a/modules/convert/src/main/scala/docspell/convert/extern/Unoconv.scala +++ b/modules/convert/src/main/scala/docspell/convert/extern/Unoconv.scala @@ -29,7 +29,7 @@ object Unoconv { "unoconv", cfg.command, cfg.workingDir, - false, + useStdin = false, logger, reader )( diff --git a/modules/convert/src/test/scala/docspell/convert/ConversionTest.scala b/modules/convert/src/test/scala/docspell/convert/ConversionTest.scala index 35dfcfa6..0cb2ca65 100644 --- a/modules/convert/src/test/scala/docspell/convert/ConversionTest.scala +++ b/modules/convert/src/test/scala/docspell/convert/ConversionTest.scala @@ -69,7 +69,7 @@ class ConversionTest extends FunSuite with FileChecks with TestLoggingConfig { target ), OcrMyPdfConfig( - true, + enabled = true, SystemCommand.Config( "ocrmypdf", Seq( @@ -86,7 +86,7 @@ class ConversionTest extends FunSuite with FileChecks with TestLoggingConfig { ), target ), - ConvertConfig.DecryptPdf(true, Nil) + ConvertConfig.DecryptPdf(enabled = true, Nil) ) val conversion = diff --git a/modules/fts-solr/src/main/scala/docspell/ftssolr/SolrMigration.scala b/modules/fts-solr/src/main/scala/docspell/ftssolr/SolrMigration.scala index 2a61dac8..1ee5301a 100644 --- a/modules/fts-solr/src/main/scala/docspell/ftssolr/SolrMigration.scala +++ b/modules/fts-solr/src/main/scala/docspell/ftssolr/SolrMigration.scala @@ -45,7 +45,7 @@ object SolrMigration { description, FtsMigration.Result.reIndexAll.pure[F] ), - true + dataChangeOnly = true ) def indexAll[F[_]: Applicative]( @@ -59,7 +59,7 @@ object SolrMigration { description, FtsMigration.Result.indexAll.pure[F] ), - true + dataChangeOnly = true ) def apply[F[_]: Functor]( @@ -74,6 +74,6 @@ object SolrMigration { description, task.map(_ => FtsMigration.Result.workDone) ), - false + dataChangeOnly = false ) } diff --git a/modules/fts-solr/src/main/scala/docspell/ftssolr/SolrSetup.scala b/modules/fts-solr/src/main/scala/docspell/ftssolr/SolrSetup.scala index cf4f7edf..05649747 100644 --- a/modules/fts-solr/src/main/scala/docspell/ftssolr/SolrSetup.scala +++ b/modules/fts-solr/src/main/scala/docspell/ftssolr/SolrSetup.scala @@ -299,14 +299,22 @@ object SolrSetup { Map("add-field" -> body.asJson).asJson def string(field: Field): AddField = - AddField(field, "string", true, true, false) + AddField(field, "string", stored = true, indexed = true, multiValued = false) def textGeneral(field: Field): AddField = - AddField(field, "text_general", true, true, false) + AddField(field, "text_general", stored = true, indexed = true, multiValued = false) def textLang(field: Field, lang: Language): AddField = - if (lang == Language.Czech) AddField(field, s"text_cz", true, true, false) - else AddField(field, s"text_${lang.iso2}", true, true, false) + if (lang == Language.Czech) + AddField(field, s"text_cz", stored = true, indexed = true, multiValued = false) + else + AddField( + field, + s"text_${lang.iso2}", + stored = true, + indexed = true, + multiValued = false + ) } case class DeleteField(name: Field) diff --git a/modules/joex/src/main/scala/docspell/joex/emptytrash/EmptyTrashTask.scala b/modules/joex/src/main/scala/docspell/joex/emptytrash/EmptyTrashTask.scala index 536fd83f..41a03b3a 100644 --- a/modules/joex/src/main/scala/docspell/joex/emptytrash/EmptyTrashTask.scala +++ b/modules/joex/src/main/scala/docspell/joex/emptytrash/EmptyTrashTask.scala @@ -30,7 +30,7 @@ object EmptyTrashTask { UserTask( args.periodicTaskId, EmptyTrashArgs.taskName, - true, + enabled = true, ce, None, args diff --git a/modules/joex/src/main/scala/docspell/joex/filecopy/FileCopyTask.scala b/modules/joex/src/main/scala/docspell/joex/filecopy/FileCopyTask.scala index c3b4a660..7f044fe5 100644 --- a/modules/joex/src/main/scala/docspell/joex/filecopy/FileCopyTask.scala +++ b/modules/joex/src/main/scala/docspell/joex/filecopy/FileCopyTask.scala @@ -29,23 +29,23 @@ object FileCopyTask { case class CopyResult(success: Boolean, message: String, counter: List[Counter]) object CopyResult { def noSourceImpl: CopyResult = - CopyResult(false, "No source BinaryStore implementation found!", Nil) + CopyResult(success = false, "No source BinaryStore implementation found!", Nil) def noTargetImpl: CopyResult = - CopyResult(false, "No target BinaryStore implementation found!", Nil) + CopyResult(success = false, "No target BinaryStore implementation found!", Nil) def noSourceStore(id: Ident): CopyResult = CopyResult( - false, + success = false, s"No source file repo found with id: ${id.id}. Make sure it is present in the config.", Nil ) def noTargetStore: CopyResult = - CopyResult(false, "No target file repositories defined", Nil) + CopyResult(success = false, "No target file repositories defined", Nil) def success(counter: NonEmptyList[Counter]): CopyResult = - CopyResult(true, "Done", counter.toList) + CopyResult(success = true, "Done", counter.toList) implicit val binaryIdCodec: Codec[BinaryId] = Codec.from( @@ -96,8 +96,10 @@ object FileCopyTask { .fromList(targets.filter(_ != srcConfig)) .toRight(CopyResult.noTargetStore) - srcRepo = store.createFileRepository(srcConfig, true) - targetRepos = trgConfig.map(store.createFileRepository(_, false)) + srcRepo = store.createFileRepository(srcConfig, withAttributeStore = true) + targetRepos = trgConfig.map( + store.createFileRepository(_, withAttributeStore = false) + ) } yield (srcRepo, targetRepos) data match { diff --git a/modules/joex/src/main/scala/docspell/joex/hk/CleanupResult.scala b/modules/joex/src/main/scala/docspell/joex/hk/CleanupResult.scala index 931f6714..04b82435 100644 --- a/modules/joex/src/main/scala/docspell/joex/hk/CleanupResult.scala +++ b/modules/joex/src/main/scala/docspell/joex/hk/CleanupResult.scala @@ -13,8 +13,8 @@ case class CleanupResult(removed: Int, disabled: Boolean) { def asString = if (disabled) "disabled" else s"$removed" } object CleanupResult { - def of(n: Int): CleanupResult = CleanupResult(n, false) - def disabled: CleanupResult = CleanupResult(0, true) + def of(n: Int): CleanupResult = CleanupResult(n, disabled = false) + def disabled: CleanupResult = CleanupResult(0, disabled = true) implicit val jsonEncoder: Encoder[CleanupResult] = deriveEncoder diff --git a/modules/joex/src/main/scala/docspell/joex/hk/HouseKeepingTask.scala b/modules/joex/src/main/scala/docspell/joex/hk/HouseKeepingTask.scala index 519cfa03..5aa9c58a 100644 --- a/modules/joex/src/main/scala/docspell/joex/hk/HouseKeepingTask.scala +++ b/modules/joex/src/main/scala/docspell/joex/hk/HouseKeepingTask.scala @@ -55,7 +55,7 @@ object HouseKeepingTask { UserTask( periodicId, taskName, - true, + enabled = true, ce, "Docspell house-keeping".some, () diff --git a/modules/joex/src/main/scala/docspell/joex/process/FindProposal.scala b/modules/joex/src/main/scala/docspell/joex/process/FindProposal.scala index b5cf948a..5581d555 100644 --- a/modules/joex/src/main/scala/docspell/joex/process/FindProposal.scala +++ b/modules/joex/src/main/scala/docspell/joex/process/FindProposal.scala @@ -222,13 +222,13 @@ object FindProposal { def searchExact[F[_]: Sync](ctx: Context[F, Args], store: Store[F]): Finder[F] = labels => labels.toList - .traverse(nl => search(nl, true, ctx, store)) + .traverse(nl => search(nl, exact = true, ctx, store)) .map(MetaProposalList.flatten) def searchFuzzy[F[_]: Sync](ctx: Context[F, Args], store: Store[F]): Finder[F] = labels => labels.toList - .traverse(nl => search(nl, false, ctx, store)) + .traverse(nl => search(nl, exact = false, ctx, store)) .map(MetaProposalList.flatten) } diff --git a/modules/joex/src/main/scala/docspell/joex/process/ReProcessItem.scala b/modules/joex/src/main/scala/docspell/joex/process/ReProcessItem.scala index 19a5193d..39337ee7 100644 --- a/modules/joex/src/main/scala/docspell/joex/process/ReProcessItem.scala +++ b/modules/joex/src/main/scala/docspell/joex/process/ReProcessItem.scala @@ -131,10 +131,10 @@ object ReProcessItem { data.item.source, // source-id None, // folder Seq.empty, - false, + skipDuplicate = false, None, None, - true, + reprocess = true, None, // attachOnly (not used when reprocessing attachments) None // cannot retain customData from an already existing item ), diff --git a/modules/joex/src/main/scala/docspell/joex/process/TextAnalysis.scala b/modules/joex/src/main/scala/docspell/joex/process/TextAnalysis.scala index ee268949..30ff4494 100644 --- a/modules/joex/src/main/scala/docspell/joex/process/TextAnalysis.scala +++ b/modules/joex/src/main/scala/docspell/joex/process/TextAnalysis.scala @@ -75,7 +75,7 @@ object TextAnalysis { analyser: TextAnalyser[F], nerFile: RegexNerFile[F] )(rm: RAttachmentMeta): F[(RAttachmentMeta, AttachmentDates)] = { - val settings = NlpSettings(ctx.args.meta.language, false, None) + val settings = NlpSettings(ctx.args.meta.language, highRecall = false, None) for { customNer <- nerFile.makeFile(ctx.args.meta.collective) sett = settings.copy(regexNer = customNer) diff --git a/modules/joex/src/main/scala/docspell/joex/routes/JoexRoutes.scala b/modules/joex/src/main/scala/docspell/joex/routes/JoexRoutes.scala index e02ff31d..0bbc5264 100644 --- a/modules/joex/src/main/scala/docspell/joex/routes/JoexRoutes.scala +++ b/modules/joex/src/main/scala/docspell/joex/routes/JoexRoutes.scala @@ -28,7 +28,7 @@ object JoexRoutes { for { _ <- app.scheduler.notifyChange _ <- app.periodicScheduler.notifyChange - resp <- Ok(BasicResult(true, "Schedulers notified.")) + resp <- Ok(BasicResult(success = true, "Schedulers notified.")) } yield resp case GET -> Root / "running" => @@ -43,7 +43,7 @@ object JoexRoutes { _ <- Async[F].start( Temporal[F].sleep(Duration.seconds(1).toScala) *> app.initShutdown ) - resp <- Ok(BasicResult(true, "Shutdown initiated.")) + resp <- Ok(BasicResult(success = true, "Shutdown initiated.")) } yield resp case GET -> Root / "job" / Ident(id) => @@ -54,7 +54,9 @@ object JoexRoutes { job <- optJob log <- optLog } yield mkJobLog(job, log) - resp <- jAndL.map(Ok(_)).getOrElse(NotFound(BasicResult(false, "Not found"))) + resp <- jAndL + .map(Ok(_)) + .getOrElse(NotFound(BasicResult(success = false, "Not found"))) } yield resp case POST -> Root / "job" / Ident(id) / "cancel" => diff --git a/modules/joex/src/main/scala/docspell/joex/scanmailbox/ScanMailboxTask.scala b/modules/joex/src/main/scala/docspell/joex/scanmailbox/ScanMailboxTask.scala index e0219121..cdff89ea 100644 --- a/modules/joex/src/main/scala/docspell/joex/scanmailbox/ScanMailboxTask.scala +++ b/modules/joex/src/main/scala/docspell/joex/scanmailbox/ScanMailboxTask.scala @@ -323,7 +323,7 @@ object ScanMailboxTask { s"mailbox-${ctx.args.account.login.id}", args.itemFolder, Seq.empty, - true, + skipDuplicates = true, args.fileFilter.getOrElse(Glob.all), args.tags.getOrElse(Nil), args.language, diff --git a/modules/notification/api/src/main/scala/docspell/notification/api/Event.scala b/modules/notification/api/src/main/scala/docspell/notification/api/Event.scala index 47519dfc..54aff624 100644 --- a/modules/notification/api/src/main/scala/docspell/notification/api/Event.scala +++ b/modules/notification/api/src/main/scala/docspell/notification/api/Event.scala @@ -164,7 +164,7 @@ object Event { for { id1 <- Ident.randomId[F] id2 <- Ident.randomId[F] - } yield ItemSelection(account, Nel.of(id1, id2), true, baseUrl, None) + } yield ItemSelection(account, Nel.of(id1, id2), more = true, baseUrl, None) } /** Event when a new job is added to the queue */ diff --git a/modules/query/shared/src/main/scala/docspell/query/ParseFailure.scala b/modules/query/shared/src/main/scala/docspell/query/ParseFailure.scala index 9f24383c..cd63e4f2 100644 --- a/modules/query/shared/src/main/scala/docspell/query/ParseFailure.scala +++ b/modules/query/shared/src/main/scala/docspell/query/ParseFailure.scala @@ -87,10 +87,10 @@ object ParseFailure { SimpleMessage(offset, message) case InRange(offset, lower, upper) => - if (lower == upper) ExpectMessage(offset, List(lower.toString), true) + if (lower == upper) ExpectMessage(offset, List(lower.toString), exhaustive = true) else { val expect = s"$lower-$upper" - ExpectMessage(offset, List(expect), true) + ExpectMessage(offset, List(expect), exhaustive = true) } case Length(offset, expected, actual) => @@ -110,6 +110,10 @@ object ParseFailure { ExpectMessage(offset, options.take(7), options.size < 8) case WithContext(ctx, expect) => - ExpectMessage(expect.offset, s"Failed to parse near: $ctx" :: Nil, true) + ExpectMessage( + expect.offset, + s"Failed to parse near: $ctx" :: Nil, + exhaustive = true + ) } } diff --git a/modules/restserver/src/main/scala/docspell/restserver/conv/Conversions.scala b/modules/restserver/src/main/scala/docspell/restserver/conv/Conversions.scala index cc745186..78babc04 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/conv/Conversions.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/conv/Conversions.scala @@ -329,7 +329,7 @@ trait Conversions { sourceName, None, validFileTypes, - false, + skipDuplicates = false, Glob.all, Nil, None, @@ -641,82 +641,86 @@ trait Conversions { def basicResult(r: SetValueResult): BasicResult = r match { case SetValueResult.FieldNotFound => - BasicResult(false, "The given field is unknown") + BasicResult(success = false, "The given field is unknown") case SetValueResult.ItemNotFound => - BasicResult(false, "The given item is unknown") + BasicResult(success = false, "The given item is unknown") case SetValueResult.ValueInvalid(msg) => - BasicResult(false, s"The value is invalid: $msg") + BasicResult(success = false, s"The value is invalid: $msg") case SetValueResult.Success => - BasicResult(true, "Custom field value set successfully.") + BasicResult(success = true, "Custom field value set successfully.") } def basicResult(cr: JobCancelResult): BasicResult = cr match { - case JobCancelResult.JobNotFound => BasicResult(false, "Job not found") + case JobCancelResult.JobNotFound => BasicResult(success = false, "Job not found") case JobCancelResult.CancelRequested => - BasicResult(true, "Cancel was requested at the job executor") + BasicResult(success = true, "Cancel was requested at the job executor") case JobCancelResult.Removed => - BasicResult(true, "The job has been removed from the queue.") + BasicResult(success = true, "The job has been removed from the queue.") } def idResult(ar: AddResult, id: Ident, successMsg: String): IdResult = ar match { - case AddResult.Success => IdResult(true, successMsg, id) - case AddResult.EntityExists(msg) => IdResult(false, msg, Ident.unsafe("")) + case AddResult.Success => IdResult(success = true, successMsg, id) + case AddResult.EntityExists(msg) => IdResult(success = false, msg, Ident.unsafe("")) case AddResult.Failure(ex) => - IdResult(false, s"Internal error: ${ex.getMessage}", Ident.unsafe("")) + IdResult(success = false, s"Internal error: ${ex.getMessage}", Ident.unsafe("")) } def basicResult(ar: AddResult, successMsg: String): BasicResult = ar match { - case AddResult.Success => BasicResult(true, successMsg) - case AddResult.EntityExists(msg) => BasicResult(false, msg) + case AddResult.Success => BasicResult(success = true, successMsg) + case AddResult.EntityExists(msg) => BasicResult(success = false, msg) case AddResult.Failure(ex) => - BasicResult(false, s"Internal error: ${ex.getMessage}") + BasicResult(success = false, s"Internal error: ${ex.getMessage}") } def basicResult(ar: UpdateResult, successMsg: String): BasicResult = ar match { - case UpdateResult.Success => BasicResult(true, successMsg) - case UpdateResult.NotFound => BasicResult(false, "Not found") + case UpdateResult.Success => BasicResult(success = true, successMsg) + case UpdateResult.NotFound => BasicResult(success = false, "Not found") case UpdateResult.Failure(ex) => - BasicResult(false, s"Error: ${ex.getMessage}") + BasicResult(success = false, s"Error: ${ex.getMessage}") } def basicResult(ur: OUpload.UploadResult): BasicResult = ur match { - case UploadResult.Success => BasicResult(true, "Files submitted.") - case UploadResult.NoFiles => BasicResult(false, "There were no files to submit.") - case UploadResult.NoSource => BasicResult(false, "The source id is not valid.") - case UploadResult.NoItem => BasicResult(false, "The item could not be found.") + case UploadResult.Success => BasicResult(success = true, "Files submitted.") + case UploadResult.NoFiles => + BasicResult(success = false, "There were no files to submit.") + case UploadResult.NoSource => + BasicResult(success = false, "The source id is not valid.") + case UploadResult.NoItem => + BasicResult(success = false, "The item could not be found.") case UploadResult.NoCollective => - BasicResult(false, "The collective could not be found.") + BasicResult(success = false, "The collective could not be found.") case UploadResult.StoreFailure(_) => BasicResult( - false, + success = false, "There were errors storing a file! See the server logs for details." ) } def basicResult(cr: PassChangeResult): BasicResult = cr match { - case PassChangeResult.Success => BasicResult(true, "Password changed.") + case PassChangeResult.Success => BasicResult(success = true, "Password changed.") case PassChangeResult.UpdateFailed => - BasicResult(false, "The database update failed.") + BasicResult(success = false, "The database update failed.") case PassChangeResult.PasswordMismatch => - BasicResult(false, "The current password is incorrect.") - case PassChangeResult.UserNotFound => BasicResult(false, "User not found.") + BasicResult(success = false, "The current password is incorrect.") + case PassChangeResult.UserNotFound => + BasicResult(success = false, "User not found.") case PassChangeResult.InvalidSource(source) => BasicResult( - false, + success = false, s"User has invalid soure: $source. Passwords are managed elsewhere." ) } def basicResult(e: Either[Throwable, _], successMsg: String): BasicResult = e match { - case Right(_) => BasicResult(true, successMsg) - case Left(ex) => BasicResult(false, ex.getMessage) + case Right(_) => BasicResult(success = true, successMsg) + case Left(ex) => BasicResult(success = false, ex.getMessage) } // MIME Type diff --git a/modules/restserver/src/main/scala/docspell/restserver/http4s/BinaryUtil.scala b/modules/restserver/src/main/scala/docspell/restserver/http4s/BinaryUtil.scala index d0bca31c..12534f47 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/http4s/BinaryUtil.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/http4s/BinaryUtil.scala @@ -38,7 +38,7 @@ object BinaryUtil { if (matches) withResponseHeaders(dsl, NotModified())(data) else makeByteResp(dsl)(data) } - .getOrElse(NotFound(BasicResult(false, "Not found"))) + .getOrElse(NotFound(BasicResult(success = false, "Not found"))) } def respondHead[F[_]: Async](dsl: Http4sDsl[F])( @@ -48,7 +48,7 @@ object BinaryUtil { fileData .map(data => withResponseHeaders(dsl, Ok())(data)) - .getOrElse(NotFound(BasicResult(false, "Not found"))) + .getOrElse(NotFound(BasicResult(success = false, "Not found"))) } def respondPreview[F[_]: Async](dsl: Http4sDsl[F], req: Request[F])( @@ -56,7 +56,7 @@ object BinaryUtil { ): F[Response[F]] = { import dsl._ def notFound = - NotFound(BasicResult(false, "Not found")) + NotFound(BasicResult(success = false, "Not found")) QP.WithFallback.unapply(req.multiParams) match { case Some(bool) => @@ -75,7 +75,7 @@ object BinaryUtil { ) case None => - BadRequest(BasicResult(false, "Invalid query parameter 'withFallback'")) + BadRequest(BasicResult(success = false, "Invalid query parameter 'withFallback'")) } } @@ -85,7 +85,7 @@ object BinaryUtil { import dsl._ fileData .map(data => withResponseHeaders(dsl, Ok())(data)) - .getOrElse(NotFound(BasicResult(false, "Not found"))) + .getOrElse(NotFound(BasicResult(success = false, "Not found"))) } def withResponseHeaders[F[_]: Sync](dsl: Http4sDsl[F], resp: F[Response[F]])( diff --git a/modules/restserver/src/main/scala/docspell/restserver/http4s/ThrowableResponseMapper.scala b/modules/restserver/src/main/scala/docspell/restserver/http4s/ThrowableResponseMapper.scala index ceeabadc..dd25a00a 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/http4s/ThrowableResponseMapper.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/http4s/ThrowableResponseMapper.scala @@ -33,10 +33,10 @@ object ThrowableResponseMapper { def toResponse(ex: Throwable): F[Response[F]] = ex match { case _: IllegalArgumentException => - BadRequest(BasicResult(false, ex.getMessage)) + BadRequest(BasicResult(success = false, ex.getMessage)) case _ => - InternalServerError(BasicResult(false, ex.getMessage)) + InternalServerError(BasicResult(success = false, ex.getMessage)) } } } diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/AddonArchiveRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/AddonArchiveRoutes.scala index 637b6763..10e1e655 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/AddonArchiveRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/AddonArchiveRoutes.scala @@ -52,7 +52,7 @@ object AddonArchiveRoutes extends AddonValidationSupport { case req @ POST -> Root :? Sync(sync) => def create(r: Option[RAddonArchive]) = IdResult( - true, + success = true, r.fold("Addon submitted for installation")(r => s"Addon installed: ${r.id.id}" ), @@ -77,7 +77,7 @@ object AddonArchiveRoutes extends AddonValidationSupport { case PUT -> Root / Ident(id) :? Sync(sync) => def create(r: Option[AddonMeta]) = BasicResult( - true, + success = true, r.fold("Addon updated in background")(m => s"Addon updated: ${m.nameAndVersion}" ) @@ -99,8 +99,8 @@ object AddonArchiveRoutes extends AddonValidationSupport { for { flag <- backend.addons.deleteAddon(token.account.collectiveId, id) resp <- - if (flag) Ok(BasicResult(true, "Addon deleted")) - else NotFound(BasicResult(false, "Addon not found")) + if (flag) Ok(BasicResult(success = true, "Addon deleted")) + else NotFound(BasicResult(success = false, "Addon not found")) } yield resp } } @@ -112,11 +112,11 @@ object AddonArchiveRoutes extends AddonValidationSupport { import dsl._ def failWith(msg: String): F[Response[F]] = - Ok(IdResult(false, msg, Ident.unsafe(""))) + Ok(IdResult(success = false, msg, Ident.unsafe(""))) e match { case AddonValidationError.AddonNotFound => - NotFound(BasicResult(false, "Addon not found.")) + NotFound(BasicResult(success = false, "Addon not found.")) case _ => failWith(validationErrorToMessage(e)) diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/AddonRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/AddonRoutes.scala index 192f6ccb..d9b4fb59 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/AddonRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/AddonRoutes.scala @@ -35,5 +35,5 @@ object AddonRoutes { "run" -> AddonRunRoutes(backend, token) ) else - Responses.notFoundRoute(BasicResult(false, "Addons disabled")) + Responses.notFoundRoute(BasicResult(success = false, "Addons disabled")) } diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/AddonRunConfigRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/AddonRunConfigRoutes.scala index 4f93c9cf..4b6a7496 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/AddonRunConfigRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/AddonRunConfigRoutes.scala @@ -43,8 +43,8 @@ object AddonRunConfigRoutes { .map(_.leftMap(_.message)) ) resp <- res.fold( - msg => Ok(BasicResult(false, msg)), - id => Ok(IdResult(true, s"Addon run config added", id)) + msg => Ok(BasicResult(success = false, msg)), + id => Ok(IdResult(success = true, s"Addon run config added", id)) ) } yield resp @@ -58,8 +58,8 @@ object AddonRunConfigRoutes { .map(_.leftMap(_.message)) ) resp <- res.fold( - msg => Ok(BasicResult(false, msg)), - id => Ok(IdResult(true, s"Addon run config updated", id)) + msg => Ok(BasicResult(success = false, msg)), + id => Ok(IdResult(success = true, s"Addon run config updated", id)) ) } yield resp @@ -67,8 +67,8 @@ object AddonRunConfigRoutes { for { flag <- backend.addons.deleteAddonRunConfig(token.account.collectiveId, id) resp <- - if (flag) Ok(BasicResult(true, "Addon task deleted")) - else NotFound(BasicResult(false, "Addon task not found")) + if (flag) Ok(BasicResult(success = true, "Addon task deleted")) + else NotFound(BasicResult(success = false, "Addon task not found")) } yield resp } } diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/AddonRunRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/AddonRunRoutes.scala index 7b7a977d..c46b5880 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/AddonRunRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/AddonRunRoutes.scala @@ -35,7 +35,7 @@ object AddonRunRoutes { input.addonRunConfigIds.toSet, UserTaskScope(token.account) ) - resp <- Ok(BasicResult(true, "Job for running addons submitted.")) + resp <- Ok(BasicResult(success = true, "Job for running addons submitted.")) } yield resp } } diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/AttachmentRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/AttachmentRoutes.scala index ac43b3ba..89a59af4 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/AttachmentRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/AttachmentRoutes.scala @@ -66,7 +66,7 @@ object AttachmentRoutes { resp <- fileData .map(data => withResponseHeaders(Ok())(data)) - .getOrElse(NotFound(BasicResult(false, "Not found"))) + .getOrElse(NotFound(BasicResult(success = false, "Not found"))) } yield resp case req @ GET -> Root / Ident(id) / "original" => @@ -83,7 +83,7 @@ object AttachmentRoutes { if (matches) withResponseHeaders(NotModified())(data) else makeByteResp(data) } - .getOrElse(NotFound(BasicResult(false, "Not found"))) + .getOrElse(NotFound(BasicResult(success = false, "Not found"))) } yield resp case HEAD -> Root / Ident(id) / "archive" => @@ -93,7 +93,7 @@ object AttachmentRoutes { resp <- fileData .map(data => withResponseHeaders(Ok())(data)) - .getOrElse(NotFound(BasicResult(false, "Not found"))) + .getOrElse(NotFound(BasicResult(success = false, "Not found"))) } yield resp case req @ GET -> Root / Ident(id) / "archive" => @@ -108,7 +108,7 @@ object AttachmentRoutes { if (matches) withResponseHeaders(NotModified())(data) else makeByteResp(data) } - .getOrElse(NotFound(BasicResult(false, "Not found"))) + .getOrElse(NotFound(BasicResult(success = false, "Not found"))) } yield resp case req @ GET -> Root / Ident(id) / "preview" => @@ -148,7 +148,9 @@ object AttachmentRoutes { for { rm <- backend.itemSearch.findAttachmentMeta(id, user.account.collectiveId) md = rm.map(Conversions.mkAttachmentMeta) - resp <- md.map(Ok(_)).getOrElse(NotFound(BasicResult(false, "Not found."))) + resp <- md + .map(Ok(_)) + .getOrElse(NotFound(BasicResult(success = false, "Not found."))) } yield resp case req @ POST -> Root / Ident(id) / "name" => @@ -169,8 +171,11 @@ object AttachmentRoutes { backend.attachment .setExtractedText(user.account.collectiveId, itemId, id, newText) ) - resp <- OptionT.liftF(Ok(BasicResult(true, "Extracted text updated."))) - } yield resp).getOrElseF(NotFound(BasicResult(false, "Attachment not found"))) + resp <- OptionT.liftF( + Ok(BasicResult(success = true, "Extracted text updated.")) + ) + } yield resp) + .getOrElseF(NotFound(BasicResult(success = false, "Attachment not found"))) case DELETE -> Root / Ident(id) / "extracted-text" => (for { @@ -181,7 +186,9 @@ object AttachmentRoutes { backend.attachment .setExtractedText(user.account.collectiveId, itemId, id, "".pure[F]) ) - resp <- OptionT.liftF(Ok(BasicResult(true, "Extracted text cleared."))) + resp <- OptionT.liftF( + Ok(BasicResult(success = true, "Extracted text cleared.")) + ) } yield resp).getOrElseF(NotFound()) case GET -> Root / Ident(id) / "extracted-text" => @@ -190,14 +197,15 @@ object AttachmentRoutes { backend.itemSearch.findAttachmentMeta(id, user.account.collectiveId) ) resp <- OptionT.liftF(Ok(OptionalText(meta.content))) - } yield resp).getOrElseF(NotFound(BasicResult(false, "Attachment not found"))) + } yield resp) + .getOrElseF(NotFound(BasicResult(success = false, "Attachment not found"))) case DELETE -> Root / Ident(id) => for { n <- backend.item.deleteAttachment(id, user.account.collectiveId) res = - if (n == 0) BasicResult(false, "Attachment not found") - else BasicResult(true, "Attachment deleted.") + if (n == 0) BasicResult(success = false, "Attachment not found") + else BasicResult(success = true, "Attachment deleted.") resp <- Ok(res) } yield resp } diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/CalEventCheckRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/CalEventCheckRoutes.scala index 39689f73..7ac2b4f0 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/CalEventCheckRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/CalEventCheckRoutes.scala @@ -40,9 +40,9 @@ object CalEventCheckRoutes { val next = ev .nextElapses(now.toUtcDateTime, 2) .map(Timestamp.atUtc) - CalEventCheckResult(true, "Valid.", ev.some, next) + CalEventCheckResult(success = true, "Valid.", ev.some, next) case Left(err) => - CalEventCheckResult(false, err, None, Nil) + CalEventCheckResult(success = false, err, None, Nil) } } } diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/ClientSettingsRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/ClientSettingsRoutes.scala index f259103c..f61aa37f 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/ClientSettingsRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/ClientSettingsRoutes.scala @@ -66,7 +66,7 @@ object ClientSettingsRoutes { for { data <- req.as[Json] _ <- backend.clientSettings.saveUser(clientId, user.account.userId, data) - res <- Ok(BasicResult(true, "Settings stored")) + res <- Ok(BasicResult(success = true, "Settings stored")) } yield res case GET -> Root / "user" / Ident(clientId) => @@ -97,7 +97,7 @@ object ClientSettingsRoutes { user.account.collectiveId, data ) - res <- Ok(BasicResult(true, "Settings stored")) + res <- Ok(BasicResult(success = true, "Settings stored")) } yield res case GET -> Root / "collective" / Ident(clientId) => diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/CollectiveRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/CollectiveRoutes.scala index faedbac0..ee80d567 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/CollectiveRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/CollectiveRoutes.scala @@ -118,7 +118,7 @@ object CollectiveRoutes { case POST -> Root / "classifier" / "startonce" => for { _ <- backend.collective.startLearnClassifier(user.account.collectiveId) - resp <- Ok(BasicResult(true, "Task submitted")) + resp <- Ok(BasicResult(success = true, "Task submitted")) } yield resp case req @ POST -> Root / "emptytrash" / "startonce" => @@ -127,7 +127,7 @@ object CollectiveRoutes { _ <- backend.collective.startEmptyTrash( EmptyTrashArgs(user.account.collectiveId, data.minAge) ) - resp <- Ok(BasicResult(true, "Task submitted")) + resp <- Ok(BasicResult(success = true, "Task submitted")) } yield resp } } diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/CustomFieldRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/CustomFieldRoutes.scala index 83492974..4942da27 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/CustomFieldRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/CustomFieldRoutes.scala @@ -56,7 +56,7 @@ object CustomFieldRoutes { (for { field <- OptionT(backend.customFields.findById(user.account.collectiveId, id)) res <- OptionT.liftF(Ok(convertField(field))) - } yield res).getOrElseF(NotFound(BasicResult(false, "Not found"))) + } yield res).getOrElseF(NotFound(BasicResult(success = false, "Not found"))) case req @ PUT -> Root / Ident(id) => for { diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/DownloadAllRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/DownloadAllRoutes.scala index 65cf2b7c..e6bde446 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/DownloadAllRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/DownloadAllRoutes.scala @@ -126,7 +126,7 @@ object DownloadAllRoutes { case DELETE -> Root / "file" / Ident(id) => for { _ <- backend.downloadAll.deleteFile(id) - resp <- Ok(BasicResult(true, "File deleted.")) + resp <- Ok(BasicResult(success = true, "File deleted.")) } yield resp case PUT -> Root / "cancel" / Ident(id) => diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/FolderRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/FolderRoutes.scala index 463f20e1..f9e10320 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/FolderRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/FolderRoutes.scala @@ -118,12 +118,12 @@ object FolderRoutes { private def mkFolderChangeResult(r: OFolder.FolderChangeResult): BasicResult = r match { case OFolder.FolderChangeResult.Success => - BasicResult(true, "Successfully changed folder.") + BasicResult(success = true, "Successfully changed folder.") case OFolder.FolderChangeResult.NotFound => - BasicResult(false, "Folder or user not found.") + BasicResult(success = false, "Folder or user not found.") case OFolder.FolderChangeResult.Forbidden => - BasicResult(false, "Not allowed to edit folder.") + BasicResult(success = false, "Not allowed to edit folder.") case OFolder.FolderChangeResult.Exists => - BasicResult(false, "The member already exists.") + BasicResult(success = false, "The member already exists.") } } diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/ItemLinkRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/ItemLinkRoutes.scala index 097f162e..5a9c70bc 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/ItemLinkRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/ItemLinkRoutes.scala @@ -37,7 +37,7 @@ class ItemLinkRoutes[F[_]: Async](account: AccountInfo, backend: OItemLink[F]) case DELETE -> Root / Ident(target) / Ident(id) => for { _ <- backend.removeAll(account.collectiveId, target, NonEmptyList.of(id)) - resp <- Ok(BasicResult(true, "Related items removed")) + resp <- Ok(BasicResult(success = true, "Related items removed")) } yield resp case req @ POST -> Root / "addAll" => @@ -58,19 +58,21 @@ class ItemLinkRoutes[F[_]: Async](account: AccountInfo, backend: OItemLink[F]) _ <- related .map(backend.removeAll(account.collectiveId, input.item, _)) .getOrElse( - BadRequest(BasicResult(false, "List of related items must not be empty")) + BadRequest( + BasicResult(success = false, "List of related items must not be empty") + ) ) - resp <- Ok(BasicResult(true, "Related items removed")) + resp <- Ok(BasicResult(success = true, "Related items removed")) } yield resp } private def convertResult(r: Option[LinkResult]): BasicResult = r match { - case Some(LinkResult.Success) => BasicResult(true, "Related items added") + case Some(LinkResult.Success) => BasicResult(success = true, "Related items added") case Some(LinkResult.LinkTargetItemError) => - BasicResult(false, "Items cannot be related to itself.") + BasicResult(success = false, "Items cannot be related to itself.") case None => - BasicResult(false, "List of related items must not be empty") + BasicResult(success = false, "List of related items must not be empty") } } diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/ItemRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/ItemRoutes.scala index 464bacff..1c3e2954 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/ItemRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/ItemRoutes.scala @@ -49,7 +49,7 @@ object ItemRoutes { resp <- result .map(r => Ok(r)) - .getOrElse(NotFound(BasicResult(false, "Not found."))) + .getOrElse(NotFound(BasicResult(success = false, "Not found."))) } yield resp case POST -> Root / Ident(id) / "confirm" => @@ -285,7 +285,7 @@ object ItemRoutes { case req @ GET -> Root / Ident(id) / "preview" :? QP.WithFallback(flag) => def notFound = - NotFound(BasicResult(false, "Not found")) + NotFound(BasicResult(success = false, "Not found")) for { preview <- backend.itemSearch.findItemPreview(id, user.account.collectiveId) inm = req.headers.get[`If-None-Match`].flatMap(_.tags) @@ -309,7 +309,7 @@ object ItemRoutes { resp <- preview .map(data => BinaryUtil.withResponseHeaders(dsl, Ok())(data)) - .getOrElse(NotFound(BasicResult(false, "Not found"))) + .getOrElse(NotFound(BasicResult(success = false, "Not found"))) } yield resp case req @ POST -> Root / Ident(id) / "reprocess" => diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/ItemSearchPart.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/ItemSearchPart.scala index 3b9e8d3a..4aea2b8e 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/ItemSearchPart.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/ItemSearchPart.scala @@ -196,17 +196,17 @@ final class ItemSearchPart[F[_]: Async]( Right(s) case QueryParseResult.ParseFailed(err) => - BadRequest(BasicResult(false, s"Invalid query: $err")).asLeft + BadRequest(BasicResult(success = false, s"Invalid query: $err")).asLeft case QueryParseResult.FulltextMismatch(Result.TooMany) => BadRequest( - BasicResult(false, "Only one fulltext search expression is allowed.") + BasicResult(success = false, "Only one fulltext search expression is allowed.") ).asLeft case QueryParseResult.FulltextMismatch(Result.UnsupportedPosition) => BadRequest( BasicResult( - false, + success = false, "A fulltext search may only appear in the root and expression." ) ).asLeft diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/LoginRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/LoginRoutes.scala index 464bd149..5c3d4775 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/LoginRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/LoginRoutes.scala @@ -41,7 +41,9 @@ object LoginRoutes { makeResponse(dsl, cfg, req, result, token.account.asString) ) case Left(err) => - BadRequest(BasicResult(false, s"Invalid authentication token: $err")) + BadRequest( + BasicResult(success = false, s"Invalid authentication token: $err") + ) } } yield resp @@ -97,7 +99,7 @@ object LoginRoutes { AuthResult( token.account.collective.id, token.account.login.id, - true, + success = true, "Login successful", Some(cd.asString), cfg.auth.sessionValid.millis, @@ -112,7 +114,17 @@ object LoginRoutes { } yield resp case _ => - Ok(AuthResult("", account, false, "Login failed.", None, 0L, false)) + Ok( + AuthResult( + "", + account, + success = false, + "Login failed.", + None, + 0L, + requireSecondFactor = false + ) + ) } } diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/MailSendRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/MailSendRoutes.scala index 15ceceac..076b153b 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/MailSendRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/MailSendRoutes.scala @@ -36,7 +36,7 @@ object MailSendRoutes { backend.mail.sendMail(user.account.userId, user.account.collectiveId, name, m) ) resp <- res.fold( - err => Ok(BasicResult(false, s"Invalid mail data: $err")), + err => Ok(BasicResult(success = false, s"Invalid mail data: $err")), res => Ok(convertOut(res)) ) } yield resp @@ -56,15 +56,15 @@ object MailSendRoutes { def convertOut(res: SendResult): BasicResult = res match { case SendResult.Success(_) => - BasicResult(true, "Mail sent.") + BasicResult(success = true, "Mail sent.") case SendResult.SendFailure(ex) => - BasicResult(false, s"Mail sending failed: ${ex.getMessage}") + BasicResult(success = false, s"Mail sending failed: ${ex.getMessage}") case SendResult.StoreFailure(ex) => BasicResult( - false, + success = false, s"Mail was sent, but could not be store to database: ${ex.getMessage}" ) case SendResult.NotFound => - BasicResult(false, s"There was no mail-connection or item found.") + BasicResult(success = false, s"There was no mail-connection or item found.") } } diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/MailSettingsRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/MailSettingsRoutes.scala index ff391d67..6e9ed286 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/MailSettingsRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/MailSettingsRoutes.scala @@ -69,7 +69,7 @@ object MailSettingsRoutes { resp <- OptionT.liftF( Ok( up.fold( - err => BasicResult(false, err), + err => BasicResult(success = false, err), ar => Conversions.basicResult(ar, "Mail settings stored.") ) ) @@ -86,7 +86,7 @@ object MailSettingsRoutes { resp <- OptionT.liftF( Ok( up.fold( - err => BasicResult(false, err), + err => BasicResult(success = false, err), ar => Conversions.basicResult(ar, "Mail settings stored.") ) ) @@ -105,10 +105,10 @@ object MailSettingsRoutes { resp <- OptionT.liftF( Ok( up.fold( - err => BasicResult(false, err), + err => BasicResult(success = false, err), n => - if (n > 0) BasicResult(true, "Mail settings stored.") - else BasicResult(false, "Mail settings could not be saved") + if (n > 0) BasicResult(success = true, "Mail settings stored.") + else BasicResult(success = false, "Mail settings could not be saved") ) ) ) @@ -126,10 +126,10 @@ object MailSettingsRoutes { resp <- OptionT.liftF( Ok( up.fold( - err => BasicResult(false, err), + err => BasicResult(success = false, err), n => - if (n > 0) BasicResult(true, "Mail settings stored.") - else BasicResult(false, "Mail settings could not be saved") + if (n > 0) BasicResult(success = true, "Mail settings stored.") + else BasicResult(success = false, "Mail settings could not be saved") ) ) ) @@ -139,8 +139,8 @@ object MailSettingsRoutes { for { n <- backend.mail.deleteSmtpSettings(user.account.userId, name) resp <- Ok( - if (n > 0) BasicResult(true, "Mail settings removed") - else BasicResult(false, "Mail settings could not be removed") + if (n > 0) BasicResult(success = true, "Mail settings removed") + else BasicResult(success = false, "Mail settings could not be removed") ) } yield resp @@ -148,8 +148,8 @@ object MailSettingsRoutes { for { n <- backend.mail.deleteImapSettings(user.account.userId, name) resp <- Ok( - if (n > 0) BasicResult(true, "Mail settings removed") - else BasicResult(false, "Mail settings could not be removed") + if (n > 0) BasicResult(success = true, "Mail settings removed") + else BasicResult(success = false, "Mail settings could not be removed") ) } yield resp } diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/NotificationRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/NotificationRoutes.scala index 2e5940d0..b28b6852 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/NotificationRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/NotificationRoutes.scala @@ -72,7 +72,7 @@ object NotificationRoutes extends NonEmptyListSupport { .createChannel(c, user.account.userId) .map(res => Conversions.basicResult(res, "Channel created")) } - .foldF(ex => BadRequest(BasicResult(false, ex.getMessage)), Ok(_)) + .foldF(ex => BadRequest(BasicResult(success = false, ex.getMessage)), Ok(_)) } yield resp case req @ PUT -> Root => @@ -86,7 +86,7 @@ object NotificationRoutes extends NonEmptyListSupport { .updateChannel(c, user.account.userId) .map(res => Conversions.basicResult(res, "Channel created")) } - .foldF(ex => BadRequest(BasicResult(false, ex.getMessage)), Ok(_)) + .foldF(ex => BadRequest(BasicResult(success = false, ex.getMessage)), Ok(_)) } yield resp } } @@ -173,7 +173,7 @@ object NotificationRoutes extends NonEmptyListSupport { resp <- data.asJsonWithMessage match { case Right(m) => Ok(m) case Left(err) => - BadRequest(BasicResult(false, s"Unable to render message: $err")) + BadRequest(BasicResult(success = false, s"Unable to render message: $err")) } } yield resp } diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/NotifyDueItemsRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/NotifyDueItemsRoutes.scala index c09cd1f4..50c3db70 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/NotifyDueItemsRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/NotifyDueItemsRoutes.scala @@ -86,7 +86,8 @@ object NotifyDueItemsRoutes extends MailAddressCodec with NonEmptyListSupport { for { data <- req.as[PeriodicDueItemsSettings] resp <- - if (data.id.isEmpty) Ok(BasicResult(false, "Empty id is not allowed")) + if (data.id.isEmpty) + Ok(BasicResult(success = false, "Empty id is not allowed")) else run(data) } yield resp diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/PeriodicQueryRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/PeriodicQueryRoutes.scala index 0245216a..910dbd5a 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/PeriodicQueryRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/PeriodicQueryRoutes.scala @@ -87,7 +87,8 @@ object PeriodicQueryRoutes extends MailAddressCodec with NonEmptyListSupport { for { data <- req.as[PeriodicQuerySettings] resp <- - if (data.id.isEmpty) Ok(BasicResult(false, "Empty id is not allowed")) + if (data.id.isEmpty) + Ok(BasicResult(success = false, "Empty id is not allowed")) else run(data) } yield resp diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/RegisterRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/RegisterRoutes.scala index d8efaacb..685dc6ed 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/RegisterRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/RegisterRoutes.scala @@ -48,26 +48,26 @@ object RegisterRoutes { def convert(r: NewInviteResult): InviteResult = r match { case NewInviteResult.Success(id) => - InviteResult(true, "New invitation created.", Some(id)) + InviteResult(success = true, "New invitation created.", Some(id)) case NewInviteResult.InvitationDisabled => - InviteResult(false, "Signing up is not enabled for invitations.", None) + InviteResult(success = false, "Signing up is not enabled for invitations.", None) case NewInviteResult.PasswordMismatch => - InviteResult(false, "Password is invalid.", None) + InviteResult(success = false, "Password is invalid.", None) } def convert(r: SignupResult): BasicResult = r match { case SignupResult.CollectiveExists => - BasicResult(false, "A collective with this name already exists.") + BasicResult(success = false, "A collective with this name already exists.") case SignupResult.InvalidInvitationKey => - BasicResult(false, "Invalid invitation key.") + BasicResult(success = false, "Invalid invitation key.") case SignupResult.SignupClosed => - BasicResult(false, "Sorry, registration is closed.") + BasicResult(success = false, "Sorry, registration is closed.") case SignupResult.Failure(ex) => logger.error(ex)("Error signing up") - BasicResult(false, s"Internal error: ${ex.getMessage}") + BasicResult(success = false, s"Internal error: ${ex.getMessage}") case SignupResult.Success => - BasicResult(true, "Signup successful") + BasicResult(success = true, "Signup successful") } def convert(r: Registration): RegisterData = diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/ScanMailboxRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/ScanMailboxRoutes.scala index 563eb795..07764333 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/ScanMailboxRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/ScanMailboxRoutes.scala @@ -82,7 +82,8 @@ object ScanMailboxRoutes { for { data <- req.as[ScanMailboxSettings] resp <- - if (data.id.isEmpty) Ok(BasicResult(false, "Empty id is not allowed")) + if (data.id.isEmpty) + Ok(BasicResult(success = false, "Empty id is not allowed")) else run(data) } yield resp diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/ShareItemRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/ShareItemRoutes.scala index 38c3d041..fe883366 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/ShareItemRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/ShareItemRoutes.scala @@ -34,7 +34,7 @@ object ShareItemRoutes { resp <- result .map(r => Ok(r)) - .getOrElse(NotFound(BasicResult(false, "Not found."))) + .getOrElse(NotFound(BasicResult(success = false, "Not found."))) } yield resp } } diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/ShareRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/ShareRoutes.scala index d40b766f..9e56f942 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/ShareRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/ShareRoutes.scala @@ -81,7 +81,7 @@ object ShareRoutes { .sendMail(user.account.collectiveId, user.account.userId, name, m) ) resp <- res.fold( - err => Ok(BasicResult(false, s"Invalid mail data: $err")), + err => Ok(BasicResult(success = false, s"Invalid mail data: $err")), res => Ok(convertOut(res)) ) } yield resp @@ -100,14 +100,46 @@ object ShareRoutes { resp <- res match { case VerifyResult.Success(token, name) => val cd = ShareCookieData(token) - Ok(ShareVerifyResult(true, token.asString, false, "Success", name)) + Ok( + ShareVerifyResult( + success = true, + token.asString, + passwordRequired = false, + "Success", + name + ) + ) .map(cd.addCookie(ClientRequestInfo.getBaseUrl(cfg, req))) case VerifyResult.PasswordMismatch => - Ok(ShareVerifyResult(false, "", true, "Failed", None)) + Ok( + ShareVerifyResult( + success = false, + "", + passwordRequired = true, + "Failed", + None + ) + ) case VerifyResult.NotFound => - Ok(ShareVerifyResult(false, "", false, "Failed", None)) + Ok( + ShareVerifyResult( + success = false, + "", + passwordRequired = false, + "Failed", + None + ) + ) case VerifyResult.InvalidToken => - Ok(ShareVerifyResult(false, "", false, "Failed", None)) + Ok( + ShareVerifyResult( + success = false, + "", + passwordRequired = false, + "Failed", + None + ) + ) } } yield resp } @@ -125,18 +157,18 @@ object ShareRoutes { def mkIdResult(r: OShare.ChangeResult, msg: => String): IdResult = r match { - case OShare.ChangeResult.Success(id) => IdResult(true, msg, id) + case OShare.ChangeResult.Success(id) => IdResult(success = true, msg, id) case OShare.ChangeResult.PublishUntilInPast => - IdResult(false, "Until date must not be in the past", Ident.unsafe("")) + IdResult(success = false, "Until date must not be in the past", Ident.unsafe("")) case OShare.ChangeResult.NotFound => IdResult( - false, + success = false, "Share not found or not owner. Only the owner can update a share.", Ident.unsafe("") ) case OShare.ChangeResult.QueryWithFulltext => IdResult( - false, + success = false, "Sorry, shares with fulltext queries are currently not supported.", Ident.unsafe("") ) @@ -144,17 +176,17 @@ object ShareRoutes { def mkBasicResult(r: OShare.ChangeResult, msg: => String): BasicResult = r match { - case OShare.ChangeResult.Success(_) => BasicResult(true, msg) + case OShare.ChangeResult.Success(_) => BasicResult(success = true, msg) case OShare.ChangeResult.PublishUntilInPast => - BasicResult(false, "Until date must not be in the past") + BasicResult(success = false, "Until date must not be in the past") case OShare.ChangeResult.NotFound => BasicResult( - false, + success = false, "Share not found or not owner. Only the owner can update a share." ) case OShare.ChangeResult.QueryWithFulltext => BasicResult( - false, + success = false, "Sorry, shares with fulltext queries are currently not supported." ) } @@ -184,10 +216,10 @@ object ShareRoutes { def convertOut(res: SendResult): BasicResult = res match { case SendResult.Success(_) => - BasicResult(true, "Mail sent.") + BasicResult(success = true, "Mail sent.") case SendResult.SendFailure(ex) => - BasicResult(false, s"Mail sending failed: ${ex.getMessage}") + BasicResult(success = false, s"Mail sending failed: ${ex.getMessage}") case SendResult.NotFound => - BasicResult(false, s"There was no mail-connection or item found.") + BasicResult(success = false, s"There was no mail-connection or item found.") } } diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/TotpRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/TotpRoutes.scala index 1199eb06..b4825710 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/TotpRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/TotpRoutes.scala @@ -36,7 +36,10 @@ object TotpRoutes { for { result <- backend.totp.state(user.account) resp <- Ok( - result.fold(en => OtpState(true, en.created.some), _ => OtpState(false, None)) + result.fold( + en => OtpState(enabled = true, en.created.some), + _ => OtpState(enabled = false, None) + ) ) } yield resp case POST -> Root / "init" => @@ -44,11 +47,13 @@ object TotpRoutes { result <- backend.totp.initialize(user.account) resp <- result match { case OTotp.InitResult.AlreadyExists => - UnprocessableEntity(BasicResult(false, "A totp setup already exists!")) + UnprocessableEntity( + BasicResult(success = false, "A totp setup already exists!") + ) case OTotp.InitResult.NotFound => - NotFound(BasicResult(false, "User not found")) + NotFound(BasicResult(success = false, "User not found")) case OTotp.InitResult.Failed(ex) => - InternalServerError(BasicResult(false, ex.getMessage)) + InternalServerError(BasicResult(success = false, ex.getMessage)) case s @ OTotp.InitResult.Success(_, key) => val issuer = cfg.appName val uri = s.authenticatorUrl(issuer) @@ -62,9 +67,9 @@ object TotpRoutes { result <- backend.totp.confirmInit(user.account, OnetimePassword(data.otp.pass)) resp <- result match { case OTotp.ConfirmResult.Success => - Ok(BasicResult(true, "TOTP setup successful.")) + Ok(BasicResult(success = true, "TOTP setup successful.")) case OTotp.ConfirmResult.Failed => - Ok(BasicResult(false, "TOTP setup failed!")) + Ok(BasicResult(success = false, "TOTP setup failed!")) } } yield resp diff --git a/modules/restserver/src/main/scala/docspell/restserver/routes/UserRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/routes/UserRoutes.scala index a3f84aff..b93829c0 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/routes/UserRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/routes/UserRoutes.scala @@ -97,7 +97,7 @@ object UserRoutes { ) case None => - NotFound(BasicResult(false, s"User '${username.id}' not found")) + NotFound(BasicResult(success = false, s"User '${username.id}' not found")) } } yield resp } @@ -119,16 +119,16 @@ object UserRoutes { ) resp <- Ok(result match { case OCollective.PassResetResult.Success(np) => - ResetPasswordResult(true, np, "Password updated") + ResetPasswordResult(success = true, np, "Password updated") case OCollective.PassResetResult.NotFound => ResetPasswordResult( - false, + success = false, Password(""), "Password update failed. User not found." ) case OCollective.PassResetResult.InvalidSource(source) => ResetPasswordResult( - false, + success = false, Password(""), s"Password update failed. User has unexpected source: $source. Passwords are managed externally." ) diff --git a/modules/scheduler/impl/src/main/scala/docspell/scheduler/impl/PeriodicSchedulerImpl.scala b/modules/scheduler/impl/src/main/scala/docspell/scheduler/impl/PeriodicSchedulerImpl.scala index ada53b9d..45797b7d 100644 --- a/modules/scheduler/impl/src/main/scala/docspell/scheduler/impl/PeriodicSchedulerImpl.scala +++ b/modules/scheduler/impl/src/main/scala/docspell/scheduler/impl/PeriodicSchedulerImpl.scala @@ -169,7 +169,7 @@ final class PeriodicSchedulerImpl[F[_]: Async]( object PeriodicSchedulerImpl { def emptyState[F[_]]: State[F] = - State(false, None) + State(shutdownRequest = false, None) case class State[F[_]]( shutdownRequest: Boolean, diff --git a/modules/scheduler/impl/src/main/scala/docspell/scheduler/impl/SchedulerImpl.scala b/modules/scheduler/impl/src/main/scala/docspell/scheduler/impl/SchedulerImpl.scala index 5d427700..5a7e8197 100644 --- a/modules/scheduler/impl/src/main/scala/docspell/scheduler/impl/SchedulerImpl.scala +++ b/modules/scheduler/impl/src/main/scala/docspell/scheduler/impl/SchedulerImpl.scala @@ -348,7 +348,7 @@ object SchedulerImpl { type CancelToken[F[_]] = F[Unit] def emptyState[F[_]]: State[F] = - State(Map.empty, Set.empty, Map.empty, false) + State(Map.empty, Set.empty, Map.empty, shutdownRequest = false) case class State[F[_]]( counters: Map[Ident, CountingScheme], diff --git a/modules/store/src/main/scala/db/migration/common/MigrateDueItemTasks.scala b/modules/store/src/main/scala/db/migration/common/MigrateDueItemTasks.scala index c169c42f..e421dcf6 100644 --- a/modules/store/src/main/scala/db/migration/common/MigrateDueItemTasks.scala +++ b/modules/store/src/main/scala/db/migration/common/MigrateDueItemTasks.scala @@ -43,8 +43,11 @@ object MigrateDueItemTasks extends TransactorSupport with JsonCodecs { ) _ <- tasks2.traverse(migratePeriodicDueItemsTask) _ <- tasks3.traverse(migratePeriodicQueryTask) - _ <- RPeriodicTask.setEnabledByTask(PeriodicQueryArgsOld.taskName, false) - _ <- RPeriodicTask.setEnabledByTask(PeriodicDueItemsArgsOld.taskName, false) + _ <- RPeriodicTask.setEnabledByTask(PeriodicQueryArgsOld.taskName, enabled = false) + _ <- RPeriodicTask.setEnabledByTask( + PeriodicDueItemsArgsOld.taskName, + enabled = false + ) } yield () private def migratePeriodicQueryTask(old: RPeriodicTask): ConnectionIO[Int] = diff --git a/modules/store/src/main/scala/db/migration/common/MigrateNotifyTasks.scala b/modules/store/src/main/scala/db/migration/common/MigrateNotifyTasks.scala index df3d85bd..f06636ec 100644 --- a/modules/store/src/main/scala/db/migration/common/MigrateNotifyTasks.scala +++ b/modules/store/src/main/scala/db/migration/common/MigrateNotifyTasks.scala @@ -38,7 +38,7 @@ object MigrateNotifyTasks extends TransactorSupport { logger.info(s"Starting to migrate ${tasks.size} user tasks") ) _ <- tasks.traverse(migrateDueItemTask1) - _ <- RPeriodicTask.setEnabledByTask(NotifyDueItemsArgs.taskName, false) + _ <- RPeriodicTask.setEnabledByTask(NotifyDueItemsArgs.taskName, enabled = false) } yield () private def migrateDueItemTask1(old: RPeriodicTask): ConnectionIO[Int] = { diff --git a/modules/store/src/main/scala/docspell/store/SchemaMigrateConfig.scala b/modules/store/src/main/scala/docspell/store/SchemaMigrateConfig.scala index 8659ef99..de3d33f7 100644 --- a/modules/store/src/main/scala/docspell/store/SchemaMigrateConfig.scala +++ b/modules/store/src/main/scala/docspell/store/SchemaMigrateConfig.scala @@ -13,5 +13,9 @@ case class SchemaMigrateConfig( ) object SchemaMigrateConfig { - val defaults = SchemaMigrateConfig(true, true, false) + val defaults = SchemaMigrateConfig( + runMainMigrations = true, + runFixupMigrations = true, + repairSchema = false + ) } diff --git a/modules/store/src/main/scala/docspell/store/file/FileUrlReader.scala b/modules/store/src/main/scala/docspell/store/file/FileUrlReader.scala index bd4e41ee..dfdd1bd1 100644 --- a/modules/store/src/main/scala/docspell/store/file/FileUrlReader.scala +++ b/modules/store/src/main/scala/docspell/store/file/FileUrlReader.scala @@ -25,7 +25,7 @@ object FileUrlReader { authority = Some(""), path = LenientUri.NonEmptyPath( Nel.of(key.collective.valueAsString, key.category.id.id, key.id.id), - false + trailingSlash = false ), query = None, fragment = None diff --git a/modules/store/src/main/scala/docspell/store/qb/DBFunction.scala b/modules/store/src/main/scala/docspell/store/qb/DBFunction.scala index 1f83a318..d7a64bff 100644 --- a/modules/store/src/main/scala/docspell/store/qb/DBFunction.scala +++ b/modules/store/src/main/scala/docspell/store/qb/DBFunction.scala @@ -15,7 +15,7 @@ object DBFunction { val countAll: DBFunction = CountAll def countAs[A](column: Column[A]): DBFunction = - Count(column, false) + Count(column, distinct = false) case object CountAll extends DBFunction diff --git a/modules/store/src/main/scala/docspell/store/qb/DSL.scala b/modules/store/src/main/scala/docspell/store/qb/DSL.scala index f5c8ddb4..01055373 100644 --- a/modules/store/src/main/scala/docspell/store/qb/DSL.scala +++ b/modules/store/src/main/scala/docspell/store/qb/DSL.scala @@ -78,10 +78,10 @@ trait DSL extends DoobieMeta { FromExpr.From(sel, alias) def count(c: Column[_]): DBFunction = - DBFunction.Count(c, false) + DBFunction.Count(c, distinct = false) def countDistinct(c: Column[_]): DBFunction = - DBFunction.Count(c, true) + DBFunction.Count(c, distinct = true) def countAll: DBFunction = DBFunction.CountAll @@ -250,22 +250,22 @@ trait DSL extends DoobieMeta { in(subsel).negate def in(values: Nel[A])(implicit P: Put[A]): Condition = - Condition.InValues(col.s, values, false) + Condition.InValues(col.s, values, lower = false) def notIn(values: Nel[A])(implicit P: Put[A]): Condition = in(values).negate def inLower(values: Nel[String]): Condition = - Condition.InValues(col.s, values.map(_.toLowerCase), true) + Condition.InValues(col.s, values.map(_.toLowerCase), lower = true) def inLowerA(values: Nel[A])(implicit P: Put[A]): Condition = - Condition.InValues(col.s, values, true) + Condition.InValues(col.s, values, lower = true) def notInLower(values: Nel[String]): Condition = - Condition.InValues(col.s, values.map(_.toLowerCase), true).negate + Condition.InValues(col.s, values.map(_.toLowerCase), lower = true).negate def notInLowerA(values: Nel[A])(implicit P: Put[A]): Condition = - Condition.InValues(col.s, values, true).negate + Condition.InValues(col.s, values, lower = true).negate def isNull: Condition = Condition.IsNull(col.s) @@ -382,7 +382,7 @@ trait DSL extends DoobieMeta { Condition.CompareFVal(sel, Operator.Neq, value) def in[A](values: Nel[A])(implicit P: Put[A]): Condition = - Condition.InValues(sel, values, false) + Condition.InValues(sel, values, lower = false) } } diff --git a/modules/store/src/main/scala/docspell/store/qb/Select.scala b/modules/store/src/main/scala/docspell/store/qb/Select.scala index 7f2e6916..45773834 100644 --- a/modules/store/src/main/scala/docspell/store/qb/Select.scala +++ b/modules/store/src/main/scala/docspell/store/qb/Select.scala @@ -76,32 +76,38 @@ sealed trait Select { object Select { def apply(projection: SelectExpr) = - SimpleSelect(false, Nel.of(projection), None, Condition.unit, None) + SimpleSelect(distinctFlag = false, Nel.of(projection), None, Condition.unit, None) def apply(projection: Nel[SelectExpr], from: FromExpr) = - SimpleSelect(false, projection, from.some, Condition.unit, None) + SimpleSelect(distinctFlag = false, projection, from.some, Condition.unit, None) def apply(projection: SelectExpr, from: FromExpr) = - SimpleSelect(false, Nel.of(projection), from.some, Condition.unit, None) + SimpleSelect( + distinctFlag = false, + Nel.of(projection), + from.some, + Condition.unit, + None + ) def apply( projection: Nel[SelectExpr], from: FromExpr, where: Condition - ) = SimpleSelect(false, projection, from.some, where, None) + ) = SimpleSelect(distinctFlag = false, projection, from.some, where, None) def apply( projection: SelectExpr, from: FromExpr, where: Condition - ) = SimpleSelect(false, Nel.of(projection), from.some, where, None) + ) = SimpleSelect(distinctFlag = false, Nel.of(projection), from.some, where, None) def apply( projection: Nel[SelectExpr], from: FromExpr, where: Condition, groupBy: GroupBy - ) = SimpleSelect(false, projection, from.some, where, Some(groupBy)) + ) = SimpleSelect(distinctFlag = false, projection, from.some, where, Some(groupBy)) case class SimpleSelect( distinctFlag: Boolean, diff --git a/modules/store/src/main/scala/docspell/store/records/RCollective.scala b/modules/store/src/main/scala/docspell/store/records/RCollective.scala index 48b431c6..1454f186 100644 --- a/modules/store/src/main/scala/docspell/store/records/RCollective.scala +++ b/modules/store/src/main/scala/docspell/store/records/RCollective.scala @@ -46,7 +46,7 @@ object RCollective { collName, CollectiveState.Active, Language.German, - true, + integrationEnabled = true, created ) diff --git a/modules/store/src/main/scala/docspell/store/records/RTag.scala b/modules/store/src/main/scala/docspell/store/records/RTag.scala index fc66f6e8..b1e432c6 100644 --- a/modules/store/src/main/scala/docspell/store/records/RTag.scala +++ b/modules/store/src/main/scala/docspell/store/records/RTag.scala @@ -180,8 +180,8 @@ object RTag { .sortBy(_._1) byCat match { - case (None, tags) :: rest => - rest.flatMap(_._2) ++ tags + case (None, tagsByCat) :: rest => + rest.flatMap(_._2) ++ tagsByCat case _ => byCat.flatMap(_._2) } diff --git a/modules/store/src/main/scala/docspell/store/records/RTotp.scala b/modules/store/src/main/scala/docspell/store/records/RTotp.scala index 00148b18..4a67d389 100644 --- a/modules/store/src/main/scala/docspell/store/records/RTotp.scala +++ b/modules/store/src/main/scala/docspell/store/records/RTotp.scala @@ -44,7 +44,7 @@ object RTotp { for { now <- Timestamp.current[F] key <- Key.generate[F](mac) - } yield RTotp(userId, false, key, now) + } yield RTotp(userId, enabled = false, key, now) def insert(r: RTotp): ConnectionIO[Int] = DML.insert(T, T.all, sql"${r.userId},${r.enabled},${r.secret},${r.created}") diff --git a/modules/store/src/main/scala/docspell/store/records/RUserEmail.scala b/modules/store/src/main/scala/docspell/store/records/RUserEmail.scala index 22995f1d..e6952954 100644 --- a/modules/store/src/main/scala/docspell/store/records/RUserEmail.scala +++ b/modules/store/src/main/scala/docspell/store/records/RUserEmail.scala @@ -199,10 +199,10 @@ object RUserEmail { userId: Ident, nameQ: Option[String] ): ConnectionIO[Vector[RUserEmail]] = - findByAccount0(userId, nameQ, false).to[Vector] + findByAccount0(userId, nameQ, exact = false).to[Vector] def getByName(userId: Ident, name: Ident): ConnectionIO[Option[RUserEmail]] = - findByAccount0(userId, Some(name.id), true).option + findByAccount0(userId, Some(name.id), exact = true).option def getById(id: Ident): ConnectionIO[Option[RUserEmail]] = { val t = Table(None) diff --git a/modules/store/src/main/scala/docspell/store/records/RUserImap.scala b/modules/store/src/main/scala/docspell/store/records/RUserImap.scala index 127d82fe..fefe1e8d 100644 --- a/modules/store/src/main/scala/docspell/store/records/RUserImap.scala +++ b/modules/store/src/main/scala/docspell/store/records/RUserImap.scala @@ -195,13 +195,13 @@ object RUserImap { userId: Ident, nameQ: Option[String] ): ConnectionIO[Vector[RUserImap]] = - findByAccount0(userId, nameQ, false).to[Vector] + findByAccount0(userId, nameQ, exact = false).to[Vector] def getByName( userId: Ident, name: Ident ): ConnectionIO[Option[RUserImap]] = - findByAccount0(userId, Some(name.id), true).option + findByAccount0(userId, Some(name.id), exact = true).option def delete( userId: Ident, diff --git a/modules/store/src/test/scala/docspell/store/StoreFixture.scala b/modules/store/src/test/scala/docspell/store/StoreFixture.scala index a6696a39..e95844aa 100644 --- a/modules/store/src/test/scala/docspell/store/StoreFixture.scala +++ b/modules/store/src/test/scala/docspell/store/StoreFixture.scala @@ -106,7 +106,7 @@ object StoreFixture { for { xa <- makeXA(ds) cfg = FileRepositoryConfig.Database(64 * 1024) - fr = FileRepository[IO](xa, ds, cfg, true) + fr = FileRepository[IO](xa, ds, cfg, withAttributeStore = true) store = new StoreImpl[IO](fr, jdbc, schemaMigrateConfig, ds, xa) _ <- Resource.eval(store.migrate) } yield store diff --git a/modules/store/src/test/scala/docspell/store/fts/TempFtsOpsTest.scala b/modules/store/src/test/scala/docspell/store/fts/TempFtsOpsTest.scala index 83d5006a..ee0f5a4b 100644 --- a/modules/store/src/test/scala/docspell/store/fts/TempFtsOpsTest.scala +++ b/modules/store/src/test/scala/docspell/store/fts/TempFtsOpsTest.scala @@ -193,7 +193,7 @@ class TempFtsOpsTest extends DatabaseTest { DocspellSystem.account.collective, CollectiveState.Active, Language.English, - true, + integrationEnabled = true, ts ) diff --git a/modules/store/src/test/scala/docspell/store/qb/QueryBuilderTest.scala b/modules/store/src/test/scala/docspell/store/qb/QueryBuilderTest.scala index 69a63410..059df6cd 100644 --- a/modules/store/src/test/scala/docspell/store/qb/QueryBuilderTest.scala +++ b/modules/store/src/test/scala/docspell/store/qb/QueryBuilderTest.scala @@ -39,7 +39,7 @@ class QueryBuilderTest extends FunSuite with TestLoggingConfig { val q = Select(proj, tables, cond).orderBy(c.name.desc) q match { case Select.Ordered( - Select.SimpleSelect(false, proj, from, where, group), + Select.SimpleSelect(false, projs, from, where, group), sb, vempty ) => @@ -48,7 +48,7 @@ class QueryBuilderTest extends FunSuite with TestLoggingConfig { sb, OrderBy(SelectExpr.SelectColumn(c.name, None), OrderBy.OrderType.Desc) ) - assertEquals(11, proj.size) + assertEquals(11, projs.size) from match { case None => fail("Unexpected from value")