Adopt joex to new collective-id

This commit is contained in:
eikek
2022-08-04 13:42:33 +02:00
parent eabcffe71a
commit 816cca7ea2
35 changed files with 194 additions and 121 deletions

View File

@ -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
}

View File

@ -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,

View File

@ -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],