Skip to content

Commit

Permalink
server: Fix SVG backwards compatibility (fixes #238)
Browse files Browse the repository at this point in the history
  • Loading branch information
eliandoran committed Jul 18, 2024
1 parent 824bc47 commit 8b79975
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/becca/entities/bnote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ class BNote extends AbstractBeccaEntity<BNote> {
.map(row => new BAttachment(row));
}

getAttachmentByTitle(title: string): BAttachment {
getAttachmentByTitle(title: string): BAttachment | undefined {
// cannot use SQL to filter by title since it can be encrypted
return this.getAttachments().filter(attachment => attachment.title === title)[0];
}
Expand Down
3 changes: 1 addition & 2 deletions src/routes/api/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ function renderSvgAttachment(image: BNote | BRevision, res: Response, attachment
let svg: string | Buffer = '<svg/>'
const attachment = image.getAttachmentByTitle(attachmentName);

const content = attachment.getContent();
if (attachment) {
svg = content;
svg = attachment.getContent();
} else {
// backwards compatibility, before attachments, the SVG was stored in the main note content as a separate key
const contentSvg = image.getJsonContentSafely()?.svg;
Expand Down

0 comments on commit 8b79975

Please sign in to comment.