mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Allow bookmarks in periodic query notification
This commit is contained in:
@ -11,12 +11,12 @@ import cats.syntax.all._
|
||||
|
||||
import docspell.common._
|
||||
import docspell.query.ItemQuery
|
||||
import docspell.store.AddResult
|
||||
import docspell.store.qb.DSL._
|
||||
import docspell.store.qb._
|
||||
|
||||
import doobie._
|
||||
import doobie.implicits._
|
||||
import docspell.store.AddResult
|
||||
|
||||
final case class RQueryBookmark(
|
||||
id: Ident,
|
||||
@ -153,4 +153,25 @@ object RQueryBookmark {
|
||||
bm.cid === account.collective && (bm.userId.isNull || bm.userId.in(users))
|
||||
).build.query[RQueryBookmark].to[Vector]
|
||||
}
|
||||
|
||||
def findByNameOrId(
|
||||
account: AccountId,
|
||||
nameOrId: String
|
||||
): ConnectionIO[Option[RQueryBookmark]] = {
|
||||
val user = RUser.as("u")
|
||||
val bm = RQueryBookmark.as("bm")
|
||||
|
||||
val users = Select(
|
||||
user.uid.s,
|
||||
from(user),
|
||||
user.cid === account.collective && user.login === account.user
|
||||
)
|
||||
Select(
|
||||
select(bm.all),
|
||||
from(bm),
|
||||
bm.cid === account.collective &&
|
||||
(bm.userId.isNull || bm.userId.in(users)) &&
|
||||
(bm.name === nameOrId || bm.id ==== nameOrId)
|
||||
).build.query[RQueryBookmark].option
|
||||
}
|
||||
}
|
||||
|
@ -138,6 +138,23 @@ object RShare {
|
||||
.option
|
||||
})
|
||||
|
||||
def findOneByCollective(
|
||||
cid: Ident,
|
||||
enabled: Option[Boolean],
|
||||
nameOrId: String
|
||||
): ConnectionIO[Option[RShare]] = {
|
||||
val s = RShare.as("s")
|
||||
val u = RUser.as("u")
|
||||
|
||||
Select(
|
||||
select(s.all),
|
||||
from(s).innerJoin(u, u.uid === s.userId),
|
||||
u.cid === cid &&
|
||||
(s.name === nameOrId || s.id ==== nameOrId) &&?
|
||||
enabled.map(e => s.enabled === e)
|
||||
).build.query[RShare].option
|
||||
}
|
||||
|
||||
def findAllByCollective(
|
||||
cid: Ident,
|
||||
ownerLogin: Option[Ident],
|
||||
|
Reference in New Issue
Block a user