From cb5a3bede713eae212a33f4b3ace2836337c03a6 Mon Sep 17 00:00:00 2001 From: Michael DiCarlo Date: Tue, 7 Nov 2023 06:54:50 -0500 Subject: [PATCH 1/2] fix: newgrounds should no longer mutate primary file size --- electron-app/package.json | 2 +- .../websites/newgrounds/newgrounds.service.ts | 30 ++++++++----------- package.json | 2 +- ui/package.json | 2 +- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/electron-app/package.json b/electron-app/package.json index 95fd9141..41a5e10a 100644 --- a/electron-app/package.json +++ b/electron-app/package.json @@ -1,6 +1,6 @@ { "name": "postybirb-plus", - "version": "3.1.33", + "version": "3.1.34", "description": "(ClientServer) PostyBirb is an application that helps artists post art and other multimedia to multiple websites more quickly.", "main": "dist/main.js", "author": "Michael DiCarlo", diff --git a/electron-app/src/server/websites/newgrounds/newgrounds.service.ts b/electron-app/src/server/websites/newgrounds/newgrounds.service.ts index 9f1b68d0..c336c1bc 100644 --- a/electron-app/src/server/websites/newgrounds/newgrounds.service.ts +++ b/electron-app/src/server/websites/newgrounds/newgrounds.service.ts @@ -120,17 +120,20 @@ export class Newgrounds extends Website { return Promise.reject(this.createPostResponse({ additionalInfo: post.body })); } - private async getThumbnail(thumbnail: PostFile, primary: PostFile): Promise { - let thumbfile = thumbnail; + private async getThumbnail( + thumbnail: PostFile | undefined, + primary: PostFile, + ): Promise { + let thumbfile: PostFile = { + value: thumbnail?.value ?? primary.value, + options: { + filename: 'thumbnail.png', + contentType: 'image/png', + }, + }; if (!thumbnail && primary.options.contentType === 'image/gif') { const frame0 = await GifManipulator.getFrame(primary.value); - thumbfile = { - value: frame0, - options: { - filename: 'thumbnail.png', - contentType: 'image/png', - }, - }; + thumbfile.value = frame0; } const scalePx = 600; @@ -158,8 +161,6 @@ export class Newgrounds extends Website { } thumbfile.value = thumb.toPNG(); - thumbfile.options.filename = 'thumbnail.png'; - thumbfile.options.contentType = 'image/png'; return thumbfile; } @@ -215,12 +216,7 @@ export class Newgrounds extends Website { } const { edit_url, project_id } = initRes.body; - - let thumbfile = await this.getThumbnail( - data.thumbnail ? data.thumbnail : data.primary.file, - data.primary.file, - ); - + const thumbfile = await this.getThumbnail(data.thumbnail, data.primary.file); const primaryBuf = nativeImage.createFromBuffer(data.primary.file.value); const size = primaryBuf.getSize(); const fileUploadRes = await Http.post< diff --git a/package.json b/package.json index 0277d57c..7faf2b7e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postybirb-plus", - "version": "3.1.33", + "version": "3.1.34", "description": "PostyBirb is an application that helps artists post art and other multimedia to multiple websites more quickly..", "main": "index.js", "scripts": { diff --git a/ui/package.json b/ui/package.json index b416f072..5097dbe5 100644 --- a/ui/package.json +++ b/ui/package.json @@ -1,6 +1,6 @@ { "name": "postybirb-plus-ui", - "version": "3.1.33", + "version": "3.1.34", "license": "BSD-3-Clause", "private": true, "Author": "Michael DiCarlo", From df8ce86a9a50e06bc01edee28de18aec65f67076 Mon Sep 17 00:00:00 2001 From: Michael DiCarlo Date: Tue, 7 Nov 2023 07:01:58 -0500 Subject: [PATCH 2/2] chore: adds twitter username shortcut back in --- .../parser/section-parsers/description.parser.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/electron-app/src/server/submission/parser/section-parsers/description.parser.ts b/electron-app/src/server/submission/parser/section-parsers/description.parser.ts index e2b8193c..eb37c947 100644 --- a/electron-app/src/server/submission/parser/section-parsers/description.parser.ts +++ b/electron-app/src/server/submission/parser/section-parsers/description.parser.ts @@ -28,6 +28,15 @@ export class DescriptionParser { private settings: SettingsService, ) { this.websiteDescriptionShortcuts = websitesService.getUsernameShortcuts(); + this.websiteDescriptionShortcuts = { + ...this.websiteDescriptionShortcuts, + twitter: [ // injects legacy twitter shortcut back in + { + key: 'tw', + url: 'https://twitter.com/$1', + }, + ], + }; } public async parse(