mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 10:28:27 +00:00
Upgrade code base to CE3
This commit is contained in:
@ -14,8 +14,8 @@ import docspell.store.queue.JobQueue
|
||||
import docspell.store.usertask.UserTaskStore
|
||||
|
||||
import emil.javamail.{JavaMailEmil, Settings}
|
||||
import org.http4s.blaze.client.BlazeClientBuilder
|
||||
import org.http4s.client.Client
|
||||
import org.http4s.client.blaze.BlazeClientBuilder
|
||||
|
||||
trait BackendApp[F[_]] {
|
||||
|
||||
@ -43,12 +43,11 @@ trait BackendApp[F[_]] {
|
||||
|
||||
object BackendApp {
|
||||
|
||||
def create[F[_]: ConcurrentEffect: ContextShift](
|
||||
def create[F[_]: Async](
|
||||
cfg: Config,
|
||||
store: Store[F],
|
||||
httpClient: Client[F],
|
||||
ftsClient: FtsClient[F],
|
||||
blocker: Blocker
|
||||
ftsClient: FtsClient[F]
|
||||
): Resource[F, BackendApp[F]] =
|
||||
for {
|
||||
utStore <- UserTaskStore(store)
|
||||
@ -68,7 +67,7 @@ object BackendApp {
|
||||
itemSearchImpl <- OItemSearch(store)
|
||||
fulltextImpl <- OFulltext(itemSearchImpl, ftsClient, store, queue, joexImpl)
|
||||
javaEmil =
|
||||
JavaMailEmil(blocker, Settings.defaultSettings.copy(debug = cfg.mailDebug))
|
||||
JavaMailEmil(Settings.defaultSettings.copy(debug = cfg.mailDebug))
|
||||
mailImpl <- OMail(store, javaEmil)
|
||||
userTaskImpl <- OUserTask(utStore, queue, joexImpl)
|
||||
folderImpl <- OFolder(store)
|
||||
@ -98,16 +97,15 @@ object BackendApp {
|
||||
val clientSettings = clientSettingsImpl
|
||||
}
|
||||
|
||||
def apply[F[_]: ConcurrentEffect: ContextShift](
|
||||
def apply[F[_]: Async](
|
||||
cfg: Config,
|
||||
connectEC: ExecutionContext,
|
||||
httpClientEc: ExecutionContext,
|
||||
blocker: Blocker
|
||||
httpClientEc: ExecutionContext
|
||||
)(ftsFactory: Client[F] => Resource[F, FtsClient[F]]): Resource[F, BackendApp[F]] =
|
||||
for {
|
||||
store <- Store.create(cfg.jdbc, connectEC, blocker)
|
||||
store <- Store.create(cfg.jdbc, connectEC)
|
||||
httpClient <- BlazeClientBuilder[F](httpClientEc).resource
|
||||
ftsClient <- ftsFactory(httpClient)
|
||||
backend <- create(cfg, store, httpClient, ftsClient, blocker)
|
||||
backend <- create(cfg, store, httpClient, ftsClient)
|
||||
} yield backend
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ object Login {
|
||||
def invalidTime: Result = InvalidTime
|
||||
}
|
||||
|
||||
def apply[F[_]: Effect](store: Store[F]): Resource[F, Login[F]] =
|
||||
def apply[F[_]: Async](store: Store[F]): Resource[F, Login[F]] =
|
||||
Resource.pure[F, Login[F]](new Login[F] {
|
||||
|
||||
private val logF = Logger.log4s(logger)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package docspell.backend.ops
|
||||
|
||||
import cats.data.OptionT
|
||||
import cats.effect.{Effect, Resource}
|
||||
import cats.effect.{Async, Resource}
|
||||
import cats.implicits._
|
||||
|
||||
import docspell.common.AccountId
|
||||
@ -25,7 +25,7 @@ trait OClientSettings[F[_]] {
|
||||
object OClientSettings {
|
||||
private[this] val logger = getLogger
|
||||
|
||||
def apply[F[_]: Effect](store: Store[F]): Resource[F, OClientSettings[F]] =
|
||||
def apply[F[_]: Async](store: Store[F]): Resource[F, OClientSettings[F]] =
|
||||
Resource.pure[F, OClientSettings[F]](new OClientSettings[F] {
|
||||
|
||||
private def getUserId(account: AccountId): OptionT[F, Ident] =
|
||||
@ -58,7 +58,7 @@ object OClientSettings {
|
||||
store.transact(RClientSettings.upsert(clientId, userId, data))
|
||||
)
|
||||
_ <- OptionT.liftF(
|
||||
if (n <= 0) Effect[F].raiseError(new Exception("No rows updated!"))
|
||||
if (n <= 0) Async[F].raiseError(new Exception("No rows updated!"))
|
||||
else ().pure[F]
|
||||
)
|
||||
} yield ()).getOrElse(())
|
||||
|
@ -1,6 +1,6 @@
|
||||
package docspell.backend.ops
|
||||
|
||||
import cats.effect.{Effect, Resource}
|
||||
import cats.effect.{Async, Resource}
|
||||
import cats.implicits._
|
||||
import fs2.Stream
|
||||
|
||||
@ -126,7 +126,7 @@ object OCollective {
|
||||
}
|
||||
}
|
||||
|
||||
def apply[F[_]: Effect](
|
||||
def apply[F[_]: Async](
|
||||
store: Store[F],
|
||||
uts: UserTaskStore[F],
|
||||
queue: JobQueue[F],
|
||||
|
@ -87,7 +87,7 @@ object OCustomFields {
|
||||
collective: Ident
|
||||
)
|
||||
|
||||
def apply[F[_]: Effect](
|
||||
def apply[F[_]: Async](
|
||||
store: Store[F]
|
||||
): Resource[F, OCustomFields[F]] =
|
||||
Resource.pure[F, OCustomFields[F]](new OCustomFields[F] {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package docspell.backend.ops
|
||||
|
||||
import cats.effect.{Effect, Resource}
|
||||
import cats.effect.{Async, Resource}
|
||||
import cats.implicits._
|
||||
|
||||
import docspell.common.{AccountId, Ident}
|
||||
@ -22,7 +22,7 @@ trait OEquipment[F[_]] {
|
||||
|
||||
object OEquipment {
|
||||
|
||||
def apply[F[_]: Effect](store: Store[F]): Resource[F, OEquipment[F]] =
|
||||
def apply[F[_]: Async](store: Store[F]): Resource[F, OEquipment[F]] =
|
||||
Resource.pure[F, OEquipment[F]](new OEquipment[F] {
|
||||
def findAll(account: AccountId, nameQuery: Option[String]): F[Vector[REquipment]] =
|
||||
store.transact(REquipment.findAll(account.collective, nameQuery, _.name))
|
||||
|
@ -55,7 +55,7 @@ object OFolder {
|
||||
type FolderDetail = QFolder.FolderDetail
|
||||
val FolderDetail = QFolder.FolderDetail
|
||||
|
||||
def apply[F[_]: Effect](store: Store[F]): Resource[F, OFolder[F]] =
|
||||
def apply[F[_]](store: Store[F]): Resource[F, OFolder[F]] =
|
||||
Resource.pure[F, OFolder[F]](new OFolder[F] {
|
||||
def findAll(
|
||||
account: AccountId,
|
||||
|
@ -77,7 +77,7 @@ object OFulltext {
|
||||
case class FtsItem(item: ListItem, ftsData: FtsData)
|
||||
case class FtsItemWithTags(item: ListItemWithTags, ftsData: FtsData)
|
||||
|
||||
def apply[F[_]: Effect](
|
||||
def apply[F[_]: Async](
|
||||
itemSearch: OItemSearch[F],
|
||||
fts: FtsClient[F],
|
||||
store: Store[F],
|
||||
|
@ -1,7 +1,7 @@
|
||||
package docspell.backend.ops
|
||||
|
||||
import cats.data.{NonEmptyList, OptionT}
|
||||
import cats.effect.{Effect, Resource}
|
||||
import cats.effect.{Async, Resource}
|
||||
import cats.implicits._
|
||||
|
||||
import docspell.backend.JobFactory
|
||||
@ -191,7 +191,7 @@ trait OItem[F[_]] {
|
||||
|
||||
object OItem {
|
||||
|
||||
def apply[F[_]: Effect](
|
||||
def apply[F[_]: Async](
|
||||
store: Store[F],
|
||||
fts: FtsClient[F],
|
||||
queue: JobQueue[F],
|
||||
|
@ -1,7 +1,7 @@
|
||||
package docspell.backend.ops
|
||||
|
||||
import cats.data.OptionT
|
||||
import cats.effect.{Effect, Resource}
|
||||
import cats.effect.{Async, Resource}
|
||||
import cats.implicits._
|
||||
import fs2.Stream
|
||||
|
||||
@ -118,7 +118,7 @@ object OItemSearch {
|
||||
val fileId = rs.fileId
|
||||
}
|
||||
|
||||
def apply[F[_]: Effect](store: Store[F]): Resource[F, OItemSearch[F]] =
|
||||
def apply[F[_]: Async](store: Store[F]): Resource[F, OItemSearch[F]] =
|
||||
Resource.pure[F, OItemSearch[F]](new OItemSearch[F] {
|
||||
|
||||
def findItem(id: Ident, collective: Ident): F[Option[ItemData]] =
|
||||
|
@ -36,7 +36,7 @@ object OJoex {
|
||||
} yield cancel.success).getOrElse(false)
|
||||
})
|
||||
|
||||
def create[F[_]: ConcurrentEffect](
|
||||
def create[F[_]: Async](
|
||||
ec: ExecutionContext,
|
||||
store: Store[F]
|
||||
): Resource[F, OJoex[F]] =
|
||||
|
@ -141,7 +141,7 @@ object OMail {
|
||||
)
|
||||
}
|
||||
|
||||
def apply[F[_]: Effect](store: Store[F], emil: Emil[F]): Resource[F, OMail[F]] =
|
||||
def apply[F[_]: Async](store: Store[F], emil: Emil[F]): Resource[F, OMail[F]] =
|
||||
Resource.pure[F, OMail[F]](new OMail[F] {
|
||||
def getSmtpSettings(
|
||||
accId: AccountId,
|
||||
|
@ -1,6 +1,6 @@
|
||||
package docspell.backend.ops
|
||||
|
||||
import cats.effect.{Effect, Resource}
|
||||
import cats.effect.{Async, Resource}
|
||||
import cats.implicits._
|
||||
|
||||
import docspell.common.syntax.all._
|
||||
@ -20,7 +20,7 @@ trait ONode[F[_]] {
|
||||
object ONode {
|
||||
private[this] val logger = getLogger
|
||||
|
||||
def apply[F[_]: Effect](store: Store[F]): Resource[F, ONode[F]] =
|
||||
def apply[F[_]: Async](store: Store[F]): Resource[F, ONode[F]] =
|
||||
Resource.pure[F, ONode[F]](new ONode[F] {
|
||||
|
||||
def register(appId: Ident, nodeType: NodeType, uri: LenientUri): F[Unit] =
|
||||
|
@ -1,6 +1,6 @@
|
||||
package docspell.backend.ops
|
||||
|
||||
import cats.effect.{Effect, Resource}
|
||||
import cats.effect.{Async, Resource}
|
||||
import cats.implicits._
|
||||
|
||||
import docspell.backend.ops.OOrganization._
|
||||
@ -49,7 +49,7 @@ object OOrganization {
|
||||
contacts: Seq[RContact]
|
||||
)
|
||||
|
||||
def apply[F[_]: Effect](store: Store[F]): Resource[F, OOrganization[F]] =
|
||||
def apply[F[_]: Async](store: Store[F]): Resource[F, OOrganization[F]] =
|
||||
Resource.pure[F, OOrganization[F]](new OOrganization[F] {
|
||||
|
||||
def findAllOrg(
|
||||
|
@ -1,6 +1,6 @@
|
||||
package docspell.backend.ops
|
||||
|
||||
import cats.effect.{Effect, Resource}
|
||||
import cats.effect.{Async, Resource}
|
||||
import cats.implicits._
|
||||
|
||||
import docspell.common.{AccountId, Ident}
|
||||
@ -22,7 +22,7 @@ trait OSource[F[_]] {
|
||||
|
||||
object OSource {
|
||||
|
||||
def apply[F[_]: Effect](store: Store[F]): Resource[F, OSource[F]] =
|
||||
def apply[F[_]: Async](store: Store[F]): Resource[F, OSource[F]] =
|
||||
Resource.pure[F, OSource[F]](new OSource[F] {
|
||||
def findAll(account: AccountId): F[Vector[SourceData]] =
|
||||
store
|
||||
|
@ -1,6 +1,6 @@
|
||||
package docspell.backend.ops
|
||||
|
||||
import cats.effect.{Effect, Resource}
|
||||
import cats.effect.{Async, Resource}
|
||||
import cats.implicits._
|
||||
|
||||
import docspell.common.{AccountId, Ident}
|
||||
@ -25,7 +25,7 @@ trait OTag[F[_]] {
|
||||
|
||||
object OTag {
|
||||
|
||||
def apply[F[_]: Effect](store: Store[F]): Resource[F, OTag[F]] =
|
||||
def apply[F[_]: Async](store: Store[F]): Resource[F, OTag[F]] =
|
||||
Resource.pure[F, OTag[F]](new OTag[F] {
|
||||
def findAll(account: AccountId, nameQuery: Option[String]): F[Vector[RTag]] =
|
||||
store.transact(RTag.findAll(account.collective, nameQuery, _.name))
|
||||
|
@ -62,7 +62,7 @@ trait OUserTask[F[_]] {
|
||||
|
||||
object OUserTask {
|
||||
|
||||
def apply[F[_]: Effect](
|
||||
def apply[F[_]: Async](
|
||||
store: UserTaskStore[F],
|
||||
queue: JobQueue[F],
|
||||
joex: OJoex[F]
|
||||
|
@ -1,6 +1,6 @@
|
||||
package docspell.backend.signup
|
||||
|
||||
import cats.effect.{Effect, Resource}
|
||||
import cats.effect.{Async, Resource}
|
||||
import cats.implicits._
|
||||
|
||||
import docspell.backend.PasswordCrypt
|
||||
@ -23,7 +23,7 @@ trait OSignup[F[_]] {
|
||||
object OSignup {
|
||||
private[this] val logger = getLogger
|
||||
|
||||
def apply[F[_]: Effect](store: Store[F]): Resource[F, OSignup[F]] =
|
||||
def apply[F[_]: Async](store: Store[F]): Resource[F, OSignup[F]] =
|
||||
Resource.pure[F, OSignup[F]](new OSignup[F] {
|
||||
|
||||
def newInvite(cfg: Config)(password: Password): F[NewInviteResult] =
|
||||
@ -35,7 +35,7 @@ object OSignup {
|
||||
.transact(RInvitation.insertNew)
|
||||
.map(ri => NewInviteResult.success(ri.id))
|
||||
else
|
||||
Effect[F].pure(NewInviteResult.invitationClosed)
|
||||
Async[F].pure(NewInviteResult.invitationClosed)
|
||||
|
||||
def register(cfg: Config)(data: RegisterData): F[SignupResult] =
|
||||
cfg.mode match {
|
||||
|
Reference in New Issue
Block a user