server: Fix shadowed fields in becca entities

This commit is contained in:
Elian Doran 2024-07-24 20:39:50 +03:00
parent 709101c540
commit bb19cc216b
No known key found for this signature in database
8 changed files with 6 additions and 15 deletions

View File

@ -8,7 +8,7 @@ import BAttribute from "./entities/battribute.js";
import BBranch from "./entities/bbranch.js";
import BRevision from "./entities/brevision.js";
import BAttachment from "./entities/battachment.js";
import { AttachmentRow, RevisionRow } from './entities/rows.js';
import { AttachmentRow, BlobRow, RevisionRow } from './entities/rows.js';
import BBlob from "./entities/bblob.js";
import BRecentNote from "./entities/brecent_note.js";
import AbstractBeccaEntity from "./entities/abstract_becca_entity.js";
@ -199,7 +199,7 @@ export default class Becca {
return null;
}
const row = sql.getRow<BBlob | null>("SELECT *, LENGTH(content) AS contentLength FROM blobs WHERE blobId = ?", [entity.blobId]);
const row = sql.getRow<BlobRow | null>("SELECT *, LENGTH(content) AS contentLength FROM blobs WHERE blobId = ?", [entity.blobId]);
return row ? new BBlob(row) : null;
}

View File

@ -44,9 +44,6 @@ class BAttachment extends AbstractBeccaEntity<BAttachment> {
title!: string;
type?: keyof typeof attachmentRoleToNoteTypeMapping;
position?: number;
blobId?: string;
isProtected?: boolean;
dateModified?: string;
utcDateScheduledForErasureSince?: string | null;
/** optionally added to the entity */
contentLength?: number;

View File

@ -7,11 +7,8 @@ class BBlob extends AbstractBeccaEntity<BBlob> {
static get primaryKeyName() { return "blobId"; }
static get hashedProperties() { return ["blobId", "content"]; }
blobId!: string;
content!: string | Buffer;
contentLength!: number;
dateModified!: string;
utcDateModified!: string;
constructor(row: BlobRow) {
super();

View File

@ -29,7 +29,6 @@ class BBranch extends AbstractBeccaEntity<BBranch> {
prefix!: string | null;
notePosition!: number;
isExpanded!: boolean;
utcDateModified?: string;
constructor(row?: BranchRow) {
super();

View File

@ -14,7 +14,6 @@ class BOption extends AbstractBeccaEntity<BOption> {
name!: string;
value!: string;
isSynced!: boolean;
constructor(row?: OptionRow) {
super();

View File

@ -15,7 +15,6 @@ class BRecentNote extends AbstractBeccaEntity<BRecentNote> {
noteId!: string;
notePath!: string;
utcDateCreated!: string;
constructor(row: RecentNoteRow) {
super();

View File

@ -33,13 +33,9 @@ class BRevision extends AbstractBeccaEntity<BRevision> {
noteId!: string;
type!: string;
mime!: string;
isProtected!: boolean;
title!: string;
blobId?: string;
dateLastEdited?: string;
dateCreated!: string;
utcDateLastEdited?: string;
utcDateCreated!: string;
contentLength?: number;
content?: string | Buffer;

View File

@ -64,6 +64,10 @@ function getRevision(req: Request) {
function getRevisionFilename(revision: BRevision) {
let filename = utils.formatDownloadTitle(revision.title, revision.type, revision.mime);
if (!revision.dateCreated) {
throw new Error("Missing creation date for revision.");
}
const extension = path.extname(filename);
const date = revision.dateCreated
.substr(0, 19)