mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 10:28:27 +00:00
Store message-id of eml files
This commit is contained in:
@ -2,7 +2,11 @@ CREATE TABLE `attachment_archive` (
|
||||
`id` varchar(254) not null primary key,
|
||||
`file_id` varchar(254) not null,
|
||||
`filename` varchar(254),
|
||||
`message_id` varchar(254),
|
||||
`created` timestamp not null,
|
||||
foreign key (`file_id`) references `filemeta`(`id`),
|
||||
foreign key (`id`) references `attachment`(`attachid`)
|
||||
);
|
||||
|
||||
CREATE INDEX `attachment_archive_message_id_idx`
|
||||
ON `attachment_archive`(`message_id`);
|
||||
|
@ -2,7 +2,11 @@ CREATE TABLE "attachment_archive" (
|
||||
"id" varchar(254) not null primary key,
|
||||
"file_id" varchar(254) not null,
|
||||
"filename" varchar(254),
|
||||
"message_id" varchar(254),
|
||||
"created" timestamp not null,
|
||||
foreign key ("file_id") references "filemeta"("id"),
|
||||
foreign key ("id") references "attachment"("attachid")
|
||||
);
|
||||
|
||||
CREATE INDEX "attachment_archive_message_id_idx"
|
||||
ON "attachment_archive"("message_id");
|
||||
|
@ -14,6 +14,7 @@ case class RAttachmentArchive(
|
||||
id: Ident, //same as RAttachment.id
|
||||
fileId: Ident,
|
||||
name: Option[String],
|
||||
messageId: Option[String],
|
||||
created: Timestamp
|
||||
)
|
||||
|
||||
@ -25,18 +26,19 @@ object RAttachmentArchive {
|
||||
val id = Column("id")
|
||||
val fileId = Column("file_id")
|
||||
val name = Column("filename")
|
||||
val messageId = Column("message_id")
|
||||
val created = Column("created")
|
||||
|
||||
val all = List(id, fileId, name, created)
|
||||
val all = List(id, fileId, name, messageId, created)
|
||||
}
|
||||
|
||||
import Columns._
|
||||
|
||||
def of(ra: RAttachment): RAttachmentArchive =
|
||||
RAttachmentArchive(ra.id, ra.fileId, ra.name, ra.created)
|
||||
def of(ra: RAttachment, mId: Option[String]): RAttachmentArchive =
|
||||
RAttachmentArchive(ra.id, ra.fileId, ra.name, mId, ra.created)
|
||||
|
||||
def insert(v: RAttachmentArchive): ConnectionIO[Int] =
|
||||
insertRow(table, all, fr"${v.id},${v.fileId},${v.name},${v.created}").update.run
|
||||
insertRow(table, all, fr"${v.id},${v.fileId},${v.name},${v.messageId},${v.created}").update.run
|
||||
|
||||
def findById(attachId: Ident): ConnectionIO[Option[RAttachmentArchive]] =
|
||||
selectSimple(all, table, id.is(attachId)).query[RAttachmentArchive].option
|
||||
@ -66,7 +68,9 @@ object RAttachmentArchive {
|
||||
selectSimple(all.map(_.prefix("a")), from, where).query[RAttachmentArchive].option
|
||||
}
|
||||
|
||||
def findByItemWithMeta(id: Ident): ConnectionIO[Vector[(RAttachmentArchive, FileMeta)]] = {
|
||||
def findByItemWithMeta(
|
||||
id: Ident
|
||||
): ConnectionIO[Vector[(RAttachmentArchive, FileMeta)]] = {
|
||||
import bitpeace.sql._
|
||||
|
||||
val aId = Columns.id.prefix("a")
|
||||
|
Reference in New Issue
Block a user