mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Adopt joex to new collective-id
This commit is contained in:
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2020 Eike K. & Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package db.migration.data
|
||||
|
||||
import db.migration.data.DownloadZipArgs.DownloadRequest
|
||||
import docspell.common._
|
||||
import docspell.query.ItemQuery.Expr.ValidItemStates
|
||||
import docspell.query.{ItemQuery, ItemQueryParser}
|
||||
import docspell.store.queries.Query
|
||||
import io.circe.generic.semiauto.{deriveDecoder, deriveEncoder}
|
||||
import io.circe.{Decoder, Encoder}
|
||||
|
||||
/** @deprecated replaced with a version using `AccountInfo` */
|
||||
final case class DownloadZipArgs(accountId: AccountId, req: DownloadRequest)
|
||||
|
||||
object DownloadZipArgs {
|
||||
val taskName: Ident = Ident.unsafe("download-query-zip")
|
||||
|
||||
final case class DownloadRequest(
|
||||
query: ItemQuery,
|
||||
fileType: DownloadAllType,
|
||||
maxFiles: Int,
|
||||
maxSize: ByteSize
|
||||
) {
|
||||
def toQuery(account: AccountInfo): Query =
|
||||
Query
|
||||
.all(account)
|
||||
.withFix(_.andQuery(ValidItemStates))
|
||||
.withCond(_ => Query.QueryExpr(query.expr))
|
||||
|
||||
def itemQueryString =
|
||||
ItemQueryParser.asString(query.expr)
|
||||
}
|
||||
object DownloadRequest {
|
||||
implicit val itemQueryDecoder: Decoder[ItemQuery] =
|
||||
Decoder.decodeString.emap(str => ItemQueryParser.parse(str).left.map(_.render))
|
||||
|
||||
implicit val itemQueryEncoder: Encoder[ItemQuery] =
|
||||
Encoder.encodeString.contramap(q =>
|
||||
q.raw.getOrElse(ItemQueryParser.unsafeAsString(q.expr))
|
||||
)
|
||||
|
||||
implicit val jsonDecoder: Decoder[DownloadRequest] =
|
||||
deriveDecoder
|
||||
|
||||
implicit val jsonEncoder: Encoder[DownloadRequest] =
|
||||
deriveEncoder
|
||||
}
|
||||
|
||||
implicit val jsonEncoder: Encoder[DownloadZipArgs] =
|
||||
deriveEncoder
|
||||
implicit val jsonDecoder: Decoder[DownloadZipArgs] =
|
||||
deriveDecoder
|
||||
}
|
@ -202,7 +202,7 @@ object RNotificationChannel {
|
||||
s"Looking up user smtp for ${userId.id} and ${conn.id}"
|
||||
)
|
||||
)
|
||||
mailConn <- OptionT(RUserEmail.getByUser(userId, conn))
|
||||
mailConn <- OptionT(RUserEmail.getByName(userId, conn))
|
||||
rec = RNotificationChannelMail(
|
||||
id,
|
||||
userId,
|
||||
|
@ -175,13 +175,6 @@ object RUserEmail {
|
||||
run(select(t.all), from(t), t.uid === userId).query[RUserEmail].to[Vector]
|
||||
}
|
||||
|
||||
def getByUser(userId: Ident, name: Ident): ConnectionIO[Option[RUserEmail]] = {
|
||||
val t = Table(None)
|
||||
run(select(t.all), from(t), t.uid === userId && t.name === name)
|
||||
.query[RUserEmail]
|
||||
.option
|
||||
}
|
||||
|
||||
private def findByAccount0(
|
||||
userId: Ident,
|
||||
nameQ: Option[String],
|
||||
|
@ -57,10 +57,10 @@ class TempFtsOpsTest extends DatabaseTest {
|
||||
|
||||
def prepareItems(store: Store[IO]) =
|
||||
for {
|
||||
_ <- store.transact(RCollective.insert(makeCollective(CollectiveId(2))))
|
||||
_ <- store.transact(RUser.insert(makeUser(CollectiveId(2))))
|
||||
cid <- store.transact(RCollective.insert(makeCollective))
|
||||
_ <- store.transact(RUser.insert(makeUser(cid)))
|
||||
items = (0 until 200)
|
||||
.map(makeItem(_, CollectiveId(2)))
|
||||
.map(makeItem(_, cid))
|
||||
.toList
|
||||
_ <- items.traverse(i => store.transact(RItem.insert(i)))
|
||||
} yield ()
|
||||
@ -184,9 +184,9 @@ class TempFtsOpsTest extends DatabaseTest {
|
||||
Timestamp(Instant.now)
|
||||
)
|
||||
|
||||
def makeCollective(cid: CollectiveId): RCollective =
|
||||
def makeCollective: RCollective =
|
||||
RCollective(
|
||||
cid,
|
||||
CollectiveId.unknown,
|
||||
DocspellSystem.account.collective,
|
||||
CollectiveState.Active,
|
||||
Language.English,
|
||||
|
Reference in New Issue
Block a user