From a2aa4d58bc2fc2458c40cda2b1a2352228078631 Mon Sep 17 00:00:00 2001 From: Josh Moore Date: Mon, 7 Feb 2022 18:27:35 -0700 Subject: [PATCH 1/6] Added shitty patch for `webp` failing to upload (#111) --- src/thumbnails.ts | 2 +- src/vibrant.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/thumbnails.ts b/src/thumbnails.ts index 33b8748..752258b 100644 --- a/src/thumbnails.ts +++ b/src/thumbnails.ts @@ -84,6 +84,6 @@ function getImageThumbnail(file: FileData) { */ export default (file: FileData): Promise => new Promise((resolve, reject) => - (file.is.video ? getVideoThumbnail : file.is.image ? getImageThumbnail : () => Promise.resolve())(file) + (file.is.video ? getVideoThumbnail : (file.is.image && !file.mimetype.includes('webp')) ? getImageThumbnail : () => Promise.resolve())(file) .then(() => resolve((file.is.video || file.is.image) ? getNewName(file.randomId) : file.is.audio ? 'views/ass-audio-icon.png' : 'views/ass-file-icon.png')) .catch(reject)); diff --git a/src/vibrant.ts b/src/vibrant.ts index dd02b77..b81510c 100644 --- a/src/vibrant.ts +++ b/src/vibrant.ts @@ -26,4 +26,4 @@ function getVibrant(file: FileData, resolve: Function, reject: Function) { * @param {*} file The file to get a colour from * @returns The Vibrant colour as a Hex value (or random Hex value for videos) */ -export default (file: FileData): Promise => new Promise((resolve, reject) => !file.is.image ? resolve(randomHexColour()) : getVibrant(file, resolve, reject)); // skipcq: JS-0229 +export default (file: FileData): Promise => new Promise((resolve, reject) => (!file.is.image || file.mimetype.includes('webp')) ? resolve(randomHexColour()) : getVibrant(file, resolve, reject)); // skipcq: JS-0229 From fc82a6d6b33e19756b0cfbdfa3b9320a1c7e4a19 Mon Sep 17 00:00:00 2001 From: Josh Moore Date: Mon, 7 Feb 2022 20:30:15 -0700 Subject: [PATCH 2/6] Fix crash if file is missing from`uploads/` (closes #103) (#112) --- src/routers/resource.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/routers/resource.ts b/src/routers/resource.ts index e3c1573..94d445c 100644 --- a/src/routers/resource.ts +++ b/src/routers/resource.ts @@ -74,10 +74,12 @@ router.get('/direct*', (req: AssRequest, res: AssResponse, next) => data.get(req sia: () => SkynetDownload(fileData) .then((stream) => stream.pipe(res)) .then(() => SkynetDelete(fileData)), - local: () => { - res.header('Accept-Ranges', 'bytes').header('Content-Length', `${fileData.size}`).type(fileData.mimetype); - fs.createReadStream(fileData.path).pipe(res); - } + local: () => fs.pathExists(path(fileData.path)) + .then((exists) => { + if (!exists) throw new Error('File does not exist'); + res.header('Accept-Ranges', 'bytes').header('Content-Length', `${fileData.size}`).type(fileData.mimetype); + fs.createReadStream(fileData.path).pipe(res); + }) }; return uploaders[fileData.randomId.startsWith('sia://') ? 'sia' : s3enabled ? 's3' : 'local'](); From 161c3f865e43f16a7f659866d1b509fbfde7793c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 8 Feb 2022 03:45:54 +0000 Subject: [PATCH 3/6] better error handling for rm and curl (#104) Co-authored-by: Josh Moore --- flameshot_example.sh | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/flameshot_example.sh b/flameshot_example.sh index d87e3a0..e40981e 100644 --- a/flameshot_example.sh +++ b/flameshot_example.sh @@ -5,16 +5,23 @@ KEY="" # Your ass upload token DOMAIN="" # Your upload domain (without http:// or https://) flameshot config -f "$IMAGENAME" # Make sure that Flameshot names the file correctly -flameshot gui -r -p "$IMAGEPATH" # Prompt the screenshot GUI +flameshot gui -r -p "$IMAGEPATH" > /dev/null # Prompt the screenshot GUI, also append the random gibberish to /dev/null -# Upload the image and copy the response URL -URL=$(curl -X POST \ - -H "Content-Type: multipart/form-data" \ - -H "Accept: application/json" \ - -H "User-Agent: ShareX/13.4.0" \ - -H "Authorization: $KEY" \ - -F "file=@$IMAGEPATH$IMAGENAME.png" "https://$DOMAIN/" | grep -Po '(?<="resource":")[^"]+') -# printf instead of echo as echo appends a newline -printf "%s" "$URL" | xclip -sel clip +FILE="$IMAGEPATH$IMAGENAME.png" # File path and file name combined -rm "$IMAGEPATH$IMAGENAME.png" # Delete the image locally +# Check if file exists to handle Curl and rm errors +# then upload the image and copy the response URL +if [ -f "$FILE" ]; then + echo "$FILE exists." + URL=$(curl -X POST \ + -H "Content-Type: multipart/form-data" \ + -H "Accept: application/json" \ + -H "User-Agent: ShareX/13.4.0" \ + -H "Authorization: $KEY" \ + -F "file=@$IMAGEPATH$IMAGENAME.png" "https://$DOMAIN/" | grep -Po '(?<="resource":")[^"]+') + # printf instead of echo as echo appends a newline + printf "%s" "$URL" | xclip -sel clip + rm "$IMAGEPATH$IMAGENAME.png" # Delete the image locally +else + echo "Aborted." +fi From 1ec26c3bde4dd80b3c04b32062d7cc00e73bc517 Mon Sep 17 00:00:00 2001 From: Josh Moore Date: Mon, 21 Feb 2022 15:05:57 -0700 Subject: [PATCH 4/6] Fixed list items in README --- .github/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/README.md b/.github/README.md index 7b5829c..f2c05d3 100644 --- a/.github/README.md +++ b/.github/README.md @@ -51,7 +51,7 @@ ass was designed with developers in mind. If you are a developer & want somethin - Download & delete resources - Fully customizable Discord embeds - Built-in web viewer with video & audio player -- Embed images, gifs, & images directly in Discord +- Embed images, gifs, & videos directly in Discord - Personal upload log using customizable Discord Webhooks - macOS/Linux support with alternative clients such as [Flameshot] ([script for ass]) & [MagicCap] - **Multiple URL styles** From 86c5999ca5f9104ec94fd26fa35c7d252187de9b Mon Sep 17 00:00:00 2001 From: Josh Moore Date: Mon, 14 Mar 2022 12:31:18 -0600 Subject: [PATCH 5/6] Properly support Node 16 (#119) --- .github/README.md | 4 ++-- .github/workflows/ts-build.yml | 4 ++-- Dockerfile | 4 ++-- package-lock.json | 22 +++++++++++----------- package.json | 6 +++--- tsconfig.json | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/README.md b/.github/README.md index f2c05d3..eec4137 100644 --- a/.github/README.md +++ b/.github/README.md @@ -192,7 +192,7 @@ docker-compose up --force-recreate --build -d && docker image prune -f # && dock Expand for local installation steps
-1. You should have **Node.js 14.17** & **npm 8 or later** installed. +1. You should have **Node.js 16** & **npm 8 or later** installed. 2. Clone this repo using `git clone https://github.com/tycrek/ass.git && cd ass/` 3. Run `npm i -g typescript` to install TypeScript globally 4. Run `npm i --save-dev` to install the required dependencies (`--save-dev` is **required** for compilation) @@ -403,7 +403,7 @@ ass has a number of pre-made npm scripts for you to use. **All** of these script | `docker-resetup` | Alias for `docker-compose exec ass npm run setup && docker-compose restart` | [tlog Socket plugin]: https://github.com/tycrek/tlog#socket -[`FORCE_COLOR`]: https://nodejs.org/dist/latest-v14.x/docs/api/cli.html#cli_force_color_1_2_3 +[`FORCE_COLOR`]: https://nodejs.org/dist/latest-v16.x/docs/api/cli.html#cli_force_color_1_2_3 ## Flameshot users (Linux) diff --git a/.github/workflows/ts-build.yml b/.github/workflows/ts-build.yml index 7abb43a..6aa8ce4 100644 --- a/.github/workflows/ts-build.yml +++ b/.github/workflows/ts-build.yml @@ -12,11 +12,11 @@ jobs: # Checkout repo - uses: actions/checkout@v2 - # Set up Node 14 + # Set up Node 16 - name: Setup Node.js environment uses: actions/setup-node@v2.4.1 with: - node-version: 14.17.5 + node-version: 16.14.0 # Install npm 8 & TypeScript - name: Install global packages diff --git a/Dockerfile b/Dockerfile index b9e3e40..ca73b36 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,8 +3,8 @@ # - tycrek (https://tycrek.com/) # - Zusier (https://github.com/Zusier) -# Node 14 image -FROM node:14.17.5 +# Node 16 image +FROM node:16.14.0 # Set working directory WORKDIR /opt/ass/ diff --git a/package-lock.json b/package-lock.json index fe75069..d605556 100755 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "ISC", "dependencies": { "@skynetlabs/skynet-nodejs": "^2.3.0", - "@tsconfig/node14": "^1.0.1", + "@tsconfig/node16": "^1.0.1", "@tycrek/express-nofavicon": "^1.0.3", "@tycrek/isprod": "^2.0.2", "@tycrek/log": "^0.5.9", @@ -55,8 +55,8 @@ "@types/ws": "^7.4.7" }, "engines": { - "node": ">=14.7.x <16", - "npm": ">=8.1.x" + "node": ">=16.14.x", + "npm": ">=8.3.x" }, "funding": { "type": "patreon", @@ -600,10 +600,10 @@ "node": ">=4.0.0" } }, - "node_modules/@tsconfig/node14": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.1.tgz", - "integrity": "sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg==" + "node_modules/@tsconfig/node16": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.2.tgz", + "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==" }, "node_modules/@tycrek/express-nofavicon": { "version": "1.0.3", @@ -4399,10 +4399,10 @@ } } }, - "@tsconfig/node14": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.1.tgz", - "integrity": "sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg==" + "@tsconfig/node16": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.2.tgz", + "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==" }, "@tycrek/express-nofavicon": { "version": "1.0.3", diff --git a/package.json b/package.json index d2a3881..9e1e0e6 100755 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "description": "The superior self-hosted ShareX server", "main": "ass.js", "engines": { - "node": ">=14.7.x <16", - "npm": ">=8.1.x" + "node": ">=16.14.x", + "npm": ">=8.3.x" }, "scripts": { "dev": "npm run build && npm start", @@ -38,7 +38,7 @@ }, "dependencies": { "@skynetlabs/skynet-nodejs": "^2.3.0", - "@tsconfig/node14": "^1.0.1", + "@tsconfig/node16": "^1.0.1", "@tycrek/express-nofavicon": "^1.0.3", "@tycrek/isprod": "^2.0.2", "@tycrek/log": "^0.5.9", diff --git a/tsconfig.json b/tsconfig.json index aac1aca..52fa7f8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "@tsconfig/node14/tsconfig.json", + "extends": "@tsconfig/node16/tsconfig.json", "compilerOptions": { "outDir": "./dist", "lib": [ From 681789c2ef3f76db6d8a8320cc6cbb02d15c926f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Mar 2022 12:37:24 -0600 Subject: [PATCH 6/6] Bump node-fetch from 2.6.5 to 2.6.7 (#120) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 22 +++++++++++++++------- package.json | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) mode change 100755 => 100644 package-lock.json mode change 100755 => 100644 package.json diff --git a/package-lock.json b/package-lock.json old mode 100755 new mode 100644 index d605556..765ca4d --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,7 @@ "jimp": "^0.16.1", "luxon": "^2.0.2", "marked": "^3.0.7", - "node-fetch": "^2.6.5", + "node-fetch": "^2.6.7", "node-vibrant": "^3.1.6", "prompt": "^1.2.0", "pug": "^3.0.2", @@ -2543,14 +2543,22 @@ "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==" }, "node_modules/node-fetch": { - "version": "2.6.5", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.5.tgz", - "integrity": "sha512-mmlIVHJEu5rnIxgEgez6b9GgWXbkZj5YZ7fx+2r94a2E+Uirsp6HsPTPlomfdHtpt/B0cdKviwkoaM6pyvUOpQ==", + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", "dependencies": { "whatwg-url": "^5.0.0" }, "engines": { "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } } }, "node_modules/node-vibrant": { @@ -5967,9 +5975,9 @@ "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==" }, "node-fetch": { - "version": "2.6.5", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.5.tgz", - "integrity": "sha512-mmlIVHJEu5rnIxgEgez6b9GgWXbkZj5YZ7fx+2r94a2E+Uirsp6HsPTPlomfdHtpt/B0cdKviwkoaM6pyvUOpQ==", + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", "requires": { "whatwg-url": "^5.0.0" } diff --git a/package.json b/package.json old mode 100755 new mode 100644 index 9e1e0e6..4c574c4 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "jimp": "^0.16.1", "luxon": "^2.0.2", "marked": "^3.0.7", - "node-fetch": "^2.6.5", + "node-fetch": "^2.6.7", "node-vibrant": "^3.1.6", "prompt": "^1.2.0", "pug": "^3.0.2",