Include archive infos in item detail

This commit is contained in:
Eike Kettner 2020-03-22 21:35:50 +01:00
parent cbc95b11e6
commit 7e6eec9533
3 changed files with 14 additions and 2 deletions

View File

@ -1897,6 +1897,7 @@ components:
- updated - updated
- attachments - attachments
- sources - sources
- archives
- tags - tags
properties: properties:
id: id:
@ -1947,6 +1948,10 @@ components:
type: array type: array
items: items:
$ref: "#/components/schemas/AttachmentSource" $ref: "#/components/schemas/AttachmentSource"
archives:
type: array
items:
$ref: "#/components/schemas/AttachmentSource"
tags: tags:
type: array type: array
items: items:

View File

@ -86,6 +86,7 @@ trait Conversions {
data.item.notes, data.item.notes,
data.attachments.map((mkAttachment(data) _).tupled).toList, data.attachments.map((mkAttachment(data) _).tupled).toList,
data.sources.map((mkAttachmentSource _).tupled).toList, data.sources.map((mkAttachmentSource _).tupled).toList,
data.archives.map((mkAttachmentArchive _).tupled).toList,
data.tags.map(mkTag).toList data.tags.map(mkTag).toList
) )
@ -97,6 +98,9 @@ trait Conversions {
def mkAttachmentSource(ra: RAttachmentSource, m: FileMeta): AttachmentSource = def mkAttachmentSource(ra: RAttachmentSource, m: FileMeta): AttachmentSource =
AttachmentSource(ra.id, ra.name, m.length, MimeType.unsafe(m.mimetype.asString)) AttachmentSource(ra.id, ra.name, m.length, MimeType.unsafe(m.mimetype.asString))
def mkAttachmentArchive(ra: RAttachmentArchive, m: FileMeta): AttachmentSource =
AttachmentSource(ra.id, ra.name, m.length, MimeType.unsafe(m.mimetype.asString))
// item list // item list
def mkQuery(m: ItemSearch, coll: Ident): OItem.Query = def mkQuery(m: ItemSearch, coll: Ident): OItem.Query =

View File

@ -24,7 +24,8 @@ object QItem {
inReplyTo: Option[IdRef], inReplyTo: Option[IdRef],
tags: Vector[RTag], tags: Vector[RTag],
attachments: Vector[(RAttachment, FileMeta)], attachments: Vector[(RAttachment, FileMeta)],
sources: Vector[(RAttachmentSource, FileMeta)] sources: Vector[(RAttachmentSource, FileMeta)],
archives: Vector[(RAttachmentArchive, FileMeta)]
) { ) {
def filterCollective(coll: Ident): Option[ItemData] = def filterCollective(coll: Ident): Option[ItemData] =
@ -76,6 +77,7 @@ object QItem {
.option .option
val attachs = RAttachment.findByItemWithMeta(id) val attachs = RAttachment.findByItemWithMeta(id)
val sources = RAttachmentSource.findByItemWithMeta(id) val sources = RAttachmentSource.findByItemWithMeta(id)
val archives = RAttachmentArchive.findByItemWithMeta(id)
val tags = RTag.findByItem(id) val tags = RTag.findByItem(id)
@ -83,8 +85,9 @@ object QItem {
data <- q data <- q
att <- attachs att <- attachs
srcs <- sources srcs <- sources
arch <- archives
ts <- tags ts <- tags
} yield data.map(d => ItemData(d._1, d._2, d._3, d._4, d._5, d._6, ts, att, srcs)) } yield data.map(d => ItemData(d._1, d._2, d._3, d._4, d._5, d._6, ts, att, srcs, arch))
} }
case class ListItem( case class ListItem(