mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 10:28:27 +00:00
Add a route to get the item preview
This is the first available preview of an attachment wrt position. If all attachments have a preview image, the preview of the first attachment is returned.
This commit is contained in:
@ -41,6 +41,8 @@ trait OItemSearch[F[_]] {
|
||||
collective: Ident
|
||||
): F[Option[AttachmentPreviewData[F]]]
|
||||
|
||||
def findItemPreview(item: Ident, collective: Ident): F[Option[AttachmentPreviewData[F]]]
|
||||
|
||||
def findAttachmentMeta(id: Ident, collective: Ident): F[Option[RAttachmentMeta]]
|
||||
|
||||
def findByFileCollective(checksum: String, collective: Ident): F[Vector[RItem]]
|
||||
@ -188,6 +190,26 @@ object OItemSearch {
|
||||
(None: Option[AttachmentPreviewData[F]]).pure[F]
|
||||
})
|
||||
|
||||
def findItemPreview(
|
||||
item: Ident,
|
||||
collective: Ident
|
||||
): F[Option[AttachmentPreviewData[F]]] =
|
||||
store
|
||||
.transact(RAttachmentPreview.findByItemAndCollective(item, collective))
|
||||
.flatMap({
|
||||
case Some(ra) =>
|
||||
makeBinaryData(ra.fileId) { m =>
|
||||
AttachmentPreviewData[F](
|
||||
ra,
|
||||
m,
|
||||
store.bitpeace.fetchData2(RangeDef.all)(Stream.emit(m))
|
||||
)
|
||||
}
|
||||
|
||||
case None =>
|
||||
(None: Option[AttachmentPreviewData[F]]).pure[F]
|
||||
})
|
||||
|
||||
def findAttachmentArchive(
|
||||
id: Ident,
|
||||
collective: Ident
|
||||
|
Reference in New Issue
Block a user