mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-03-27 17:35:04 +00:00
Fix compile warnings after scala update
This commit is contained in:
parent
3e76385d08
commit
924aaf720e
@ -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
|
||||
)
|
||||
|
@ -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
|
||||
)
|
||||
|
@ -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),
|
||||
|
@ -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))
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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) =
|
||||
|
@ -93,7 +93,7 @@ object AddonOps {
|
||||
AddonResult.executionFailed(
|
||||
new Exception(s"Addon run config ${id.id} not found.")
|
||||
) :: Nil,
|
||||
false
|
||||
pure = false
|
||||
) :: Nil,
|
||||
Nil
|
||||
)
|
||||
|
@ -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
|
||||
)
|
||||
|
@ -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
|
||||
|
@ -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]] =
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
)
|
||||
|
@ -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))
|
||||
|
@ -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)
|
||||
|
@ -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, ""))
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ object OcrMyPdf {
|
||||
"ocrmypdf",
|
||||
cfg.command.replace(Map("{{lang}}" -> lang.iso3)),
|
||||
cfg.workingDir,
|
||||
false,
|
||||
useStdin = false,
|
||||
logger,
|
||||
reader
|
||||
)(in, handler)
|
||||
|
@ -31,7 +31,7 @@ object Tesseract {
|
||||
"tesseract",
|
||||
cfg.command.replace(Map("{{lang}}" -> lang.iso3)),
|
||||
cfg.workingDir,
|
||||
false,
|
||||
useStdin = false,
|
||||
logger,
|
||||
reader
|
||||
)(in, handler)
|
||||
|
@ -29,7 +29,7 @@ object Unoconv {
|
||||
"unoconv",
|
||||
cfg.command,
|
||||
cfg.workingDir,
|
||||
false,
|
||||
useStdin = false,
|
||||
logger,
|
||||
reader
|
||||
)(
|
||||
|
@ -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 =
|
||||
|
@ -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
|
||||
)
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -30,7 +30,7 @@ object EmptyTrashTask {
|
||||
UserTask(
|
||||
args.periodicTaskId,
|
||||
EmptyTrashArgs.taskName,
|
||||
true,
|
||||
enabled = true,
|
||||
ce,
|
||||
None,
|
||||
args
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -55,7 +55,7 @@ object HouseKeepingTask {
|
||||
UserTask(
|
||||
periodicId,
|
||||
taskName,
|
||||
true,
|
||||
enabled = true,
|
||||
ce,
|
||||
"Docspell house-keeping".some,
|
||||
()
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
),
|
||||
|
@ -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)
|
||||
|
@ -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" =>
|
||||
|
@ -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,
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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]])(
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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))
|
||||
|
@ -35,5 +35,5 @@ object AddonRoutes {
|
||||
"run" -> AddonRunRoutes(backend, token)
|
||||
)
|
||||
else
|
||||
Responses.notFoundRoute(BasicResult(false, "Addons disabled"))
|
||||
Responses.notFoundRoute(BasicResult(success = false, "Addons disabled"))
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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) =>
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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) =>
|
||||
|
@ -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.")
|
||||
}
|
||||
}
|
||||
|
@ -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")
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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" =>
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.")
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 =
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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.")
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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."
|
||||
)
|
||||
|
@ -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,
|
||||
|
@ -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],
|
||||
|
@ -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] =
|
||||
|
@ -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] = {
|
||||
|
@ -13,5 +13,9 @@ case class SchemaMigrateConfig(
|
||||
)
|
||||
|
||||
object SchemaMigrateConfig {
|
||||
val defaults = SchemaMigrateConfig(true, true, false)
|
||||
val defaults = SchemaMigrateConfig(
|
||||
runMainMigrations = true,
|
||||
runFixupMigrations = true,
|
||||
repairSchema = false
|
||||
)
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -46,7 +46,7 @@ object RCollective {
|
||||
collName,
|
||||
CollectiveState.Active,
|
||||
Language.German,
|
||||
true,
|
||||
integrationEnabled = true,
|
||||
created
|
||||
)
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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}")
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -193,7 +193,7 @@ class TempFtsOpsTest extends DatabaseTest {
|
||||
DocspellSystem.account.collective,
|
||||
CollectiveState.Active,
|
||||
Language.English,
|
||||
true,
|
||||
integrationEnabled = true,
|
||||
ts
|
||||
)
|
||||
|
||||
|
@ -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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user