mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
Autoformat
This commit is contained in:
@ -46,9 +46,8 @@ object Config {
|
||||
pattern == ip || (inet.isLoopbackAddress && pattern == "127.0.0.1") || (pattern
|
||||
.split('.')
|
||||
.zip(ipParts)
|
||||
.foldLeft(true) {
|
||||
case (r, (a, b)) =>
|
||||
r && (a == "*" || a == b)
|
||||
.foldLeft(true) { case (r, (a, b)) =>
|
||||
r && (a == "*" || a == b)
|
||||
})
|
||||
|
||||
ips.exists(checkSingle)
|
||||
|
@ -99,13 +99,12 @@ object RestServer {
|
||||
val dsl = new Http4sDsl[F] {}
|
||||
import dsl._
|
||||
|
||||
HttpRoutes.of {
|
||||
case GET -> Root =>
|
||||
Response[F](
|
||||
Status.SeeOther,
|
||||
body = Stream.empty,
|
||||
headers = Headers.of(Location(Uri(path = path)))
|
||||
).pure[F]
|
||||
HttpRoutes.of { case GET -> Root =>
|
||||
Response[F](
|
||||
Status.SeeOther,
|
||||
body = Stream.empty,
|
||||
headers = Headers.of(Location(Uri(path = path)))
|
||||
).pure[F]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -441,9 +441,8 @@ trait Conversions {
|
||||
oid: Option[Ident],
|
||||
pid: Option[Ident]
|
||||
): F[RContact] =
|
||||
timeId.map {
|
||||
case (id, now) =>
|
||||
RContact(id, c.value, c.kind, pid, oid, now)
|
||||
timeId.map { case (id, now) =>
|
||||
RContact(id, c.value, c.kind, pid, oid, now)
|
||||
}
|
||||
|
||||
// users
|
||||
@ -460,19 +459,18 @@ trait Conversions {
|
||||
)
|
||||
|
||||
def newUser[F[_]: Sync](u: User, cid: Ident): F[RUser] =
|
||||
timeId.map {
|
||||
case (id, now) =>
|
||||
RUser(
|
||||
id,
|
||||
u.login,
|
||||
cid,
|
||||
u.password.getOrElse(Password.empty),
|
||||
u.state,
|
||||
u.email,
|
||||
0,
|
||||
None,
|
||||
now
|
||||
)
|
||||
timeId.map { case (id, now) =>
|
||||
RUser(
|
||||
id,
|
||||
u.login,
|
||||
cid,
|
||||
u.password.getOrElse(Password.empty),
|
||||
u.state,
|
||||
u.email,
|
||||
0,
|
||||
None,
|
||||
now
|
||||
)
|
||||
}
|
||||
|
||||
def changeUser(u: User, cid: Ident): RUser =
|
||||
@ -494,9 +492,8 @@ trait Conversions {
|
||||
Tag(rt.tagId, rt.name, rt.category, rt.created)
|
||||
|
||||
def newTag[F[_]: Sync](t: Tag, cid: Ident): F[RTag] =
|
||||
timeId.map {
|
||||
case (id, now) =>
|
||||
RTag(id, cid, t.name, t.category, now)
|
||||
timeId.map { case (id, now) =>
|
||||
RTag(id, cid, t.name, t.category, now)
|
||||
}
|
||||
|
||||
def changeTag(t: Tag, cid: Ident): RTag =
|
||||
@ -517,9 +514,8 @@ trait Conversions {
|
||||
)
|
||||
|
||||
def newSource[F[_]: Sync](s: Source, cid: Ident): F[RSource] =
|
||||
timeId.map({
|
||||
case (id, now) =>
|
||||
RSource(id, cid, s.abbrev, s.description, 0, s.enabled, s.priority, now, s.folder)
|
||||
timeId.map({ case (id, now) =>
|
||||
RSource(id, cid, s.abbrev, s.description, 0, s.enabled, s.priority, now, s.folder)
|
||||
})
|
||||
|
||||
def changeSource[F[_]: Sync](s: Source, coll: Ident): RSource =
|
||||
@ -540,9 +536,8 @@ trait Conversions {
|
||||
Equipment(re.eid, re.name, re.created)
|
||||
|
||||
def newEquipment[F[_]: Sync](e: Equipment, cid: Ident): F[REquipment] =
|
||||
timeId.map({
|
||||
case (id, now) =>
|
||||
REquipment(id, cid, e.name, now, now)
|
||||
timeId.map({ case (id, now) =>
|
||||
REquipment(id, cid, e.name, now, now)
|
||||
})
|
||||
|
||||
def changeEquipment[F[_]: Sync](e: Equipment, cid: Ident): F[REquipment] =
|
||||
|
@ -18,13 +18,12 @@ object CalEventCheckRoutes {
|
||||
val dsl = new Http4sDsl[F] {}
|
||||
import dsl._
|
||||
|
||||
HttpRoutes.of {
|
||||
case req @ POST -> Root =>
|
||||
for {
|
||||
data <- req.as[CalEventCheck]
|
||||
res <- testEvent(data.event)
|
||||
resp <- Ok(res)
|
||||
} yield resp
|
||||
HttpRoutes.of { case req @ POST -> Root =>
|
||||
for {
|
||||
data <- req.as[CalEventCheck]
|
||||
res <- testEvent(data.event)
|
||||
resp <- Ok(res)
|
||||
} yield resp
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,13 +20,12 @@ object CheckFileRoutes {
|
||||
val dsl = new Http4sDsl[F] with ResponseGenerator[F] {}
|
||||
import dsl._
|
||||
|
||||
HttpRoutes.of {
|
||||
case GET -> Root / checksum =>
|
||||
for {
|
||||
items <-
|
||||
backend.itemSearch.findByFileCollective(checksum, user.account.collective)
|
||||
resp <- Ok(convert(items))
|
||||
} yield resp
|
||||
HttpRoutes.of { case GET -> Root / checksum =>
|
||||
for {
|
||||
items <-
|
||||
backend.itemSearch.findByFileCollective(checksum, user.account.collective)
|
||||
resp <- Ok(convert(items))
|
||||
} yield resp
|
||||
|
||||
}
|
||||
}
|
||||
@ -35,12 +34,11 @@ object CheckFileRoutes {
|
||||
val dsl = new Http4sDsl[F] with ResponseGenerator[F] {}
|
||||
import dsl._
|
||||
|
||||
HttpRoutes.of {
|
||||
case GET -> Root / Ident(id) / checksum =>
|
||||
for {
|
||||
items <- backend.itemSearch.findByFileSource(checksum, id)
|
||||
resp <- Ok(convert(items))
|
||||
} yield resp
|
||||
HttpRoutes.of { case GET -> Root / Ident(id) / checksum =>
|
||||
for {
|
||||
items <- backend.itemSearch.findByFileSource(checksum, id)
|
||||
resp <- Ok(convert(items))
|
||||
} yield resp
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,13 +26,11 @@ object FullTextIndexRoutes {
|
||||
val dsl = Http4sDsl[F]
|
||||
import dsl._
|
||||
|
||||
HttpRoutes.of {
|
||||
case POST -> Root / "reIndex" =>
|
||||
for {
|
||||
res <- backend.fulltext.reindexCollective(user.account).attempt
|
||||
resp <-
|
||||
Ok(Conversions.basicResult(res, "Full-text index will be re-created."))
|
||||
} yield resp
|
||||
HttpRoutes.of { case POST -> Root / "reIndex" =>
|
||||
for {
|
||||
res <- backend.fulltext.reindexCollective(user.account).attempt
|
||||
resp <- Ok(Conversions.basicResult(res, "Full-text index will be re-created."))
|
||||
} yield resp
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,16 +40,14 @@ object FullTextIndexRoutes {
|
||||
val dsl = Http4sDsl[F]
|
||||
import dsl._
|
||||
|
||||
HttpRoutes.of {
|
||||
case POST -> Root / "reIndexAll" / Ident(id) =>
|
||||
for {
|
||||
res <-
|
||||
if (id.nonEmpty && id == cfg.fullTextSearch.recreateKey)
|
||||
backend.fulltext.reindexAll.attempt
|
||||
else Left(new Exception("The provided key is invalid.")).pure[F]
|
||||
resp <-
|
||||
Ok(Conversions.basicResult(res, "Full-text index will be re-created."))
|
||||
} yield resp
|
||||
HttpRoutes.of { case POST -> Root / "reIndexAll" / Ident(id) =>
|
||||
for {
|
||||
res <-
|
||||
if (id.nonEmpty && id == cfg.fullTextSearch.recreateKey)
|
||||
backend.fulltext.reindexAll.attempt
|
||||
else Left(new Exception("The provided key is invalid.")).pure[F]
|
||||
resp <- Ok(Conversions.basicResult(res, "Full-text index will be re-created."))
|
||||
} yield resp
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,17 +14,16 @@ object InfoRoutes {
|
||||
def apply[F[_]: Sync](): HttpRoutes[F] = {
|
||||
val dsl = new Http4sDsl[F] {}
|
||||
import dsl._
|
||||
HttpRoutes.of[F] {
|
||||
case GET -> (Root / "version") =>
|
||||
Ok(
|
||||
VersionInfo(
|
||||
BuildInfo.version,
|
||||
BuildInfo.builtAtMillis,
|
||||
BuildInfo.builtAtString,
|
||||
BuildInfo.gitHeadCommit.getOrElse(""),
|
||||
BuildInfo.gitDescribedVersion.getOrElse("")
|
||||
)
|
||||
HttpRoutes.of[F] { case GET -> (Root / "version") =>
|
||||
Ok(
|
||||
VersionInfo(
|
||||
BuildInfo.version,
|
||||
BuildInfo.builtAtMillis,
|
||||
BuildInfo.builtAtString,
|
||||
BuildInfo.gitHeadCommit.getOrElse(""),
|
||||
BuildInfo.gitDescribedVersion.getOrElse("")
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,12 @@ object LoginRoutes {
|
||||
val dsl: Http4sDsl[F] = new Http4sDsl[F] {}
|
||||
import dsl._
|
||||
|
||||
HttpRoutes.of[F] {
|
||||
case req @ POST -> Root / "login" =>
|
||||
for {
|
||||
up <- req.as[UserPass]
|
||||
res <- S.loginUserPass(cfg.auth)(Login.UserPass(up.account, up.password))
|
||||
resp <- makeResponse(dsl, cfg, res, up.account)
|
||||
} yield resp
|
||||
HttpRoutes.of[F] { case req @ POST -> Root / "login" =>
|
||||
for {
|
||||
up <- req.as[UserPass]
|
||||
res <- S.loginUserPass(cfg.auth)(Login.UserPass(up.account, up.password))
|
||||
resp <- makeResponse(dsl, cfg, res, up.account)
|
||||
} yield resp
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,17 +23,16 @@ object MailSendRoutes {
|
||||
val dsl = new Http4sDsl[F] {}
|
||||
import dsl._
|
||||
|
||||
HttpRoutes.of {
|
||||
case req @ POST -> Root / Ident(name) / Ident(id) =>
|
||||
for {
|
||||
in <- req.as[SimpleMail]
|
||||
mail = convertIn(id, in)
|
||||
res <- mail.traverse(m => backend.mail.sendMail(user.account, name, m))
|
||||
resp <- res.fold(
|
||||
err => Ok(BasicResult(false, s"Invalid mail data: $err")),
|
||||
res => Ok(convertOut(res))
|
||||
)
|
||||
} yield resp
|
||||
HttpRoutes.of { case req @ POST -> Root / Ident(name) / Ident(id) =>
|
||||
for {
|
||||
in <- req.as[SimpleMail]
|
||||
mail = convertIn(id, in)
|
||||
res <- mail.traverse(m => backend.mail.sendMail(user.account, name, m))
|
||||
resp <- res.fold(
|
||||
err => Ok(BasicResult(false, s"Invalid mail data: $err")),
|
||||
res => Ok(convertOut(res))
|
||||
)
|
||||
} yield resp
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,20 +40,18 @@ object TemplateRoutes {
|
||||
import dsl._
|
||||
new InnerRoutes[F] {
|
||||
def doc =
|
||||
HttpRoutes.of[F] {
|
||||
case GET -> Root =>
|
||||
for {
|
||||
templ <- docTemplate
|
||||
resp <- Ok(DocData().render(templ), `Content-Type`(`text/html`))
|
||||
} yield resp
|
||||
HttpRoutes.of[F] { case GET -> Root =>
|
||||
for {
|
||||
templ <- docTemplate
|
||||
resp <- Ok(DocData().render(templ), `Content-Type`(`text/html`))
|
||||
} yield resp
|
||||
}
|
||||
def app =
|
||||
HttpRoutes.of[F] {
|
||||
case GET -> _ =>
|
||||
for {
|
||||
templ <- indexTemplate
|
||||
resp <- Ok(IndexData(cfg).render(templ), `Content-Type`(`text/html`))
|
||||
} yield resp
|
||||
HttpRoutes.of[F] { case GET -> _ =>
|
||||
for {
|
||||
templ <- indexTemplate
|
||||
resp <- Ok(IndexData(cfg).render(templ), `Content-Type`(`text/html`))
|
||||
} yield resp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user