From dff7600c917044d7942aa081d80649221332e422 Mon Sep 17 00:00:00 2001 From: tycrek Date: Tue, 6 Apr 2021 15:33:06 -0600 Subject: [PATCH] added Discord compat mode --- README.md | 1 + ass.js | 5 +++-- setup.js | 9 ++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2c40516..4c5a4aa 100755 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ This project is still very young, so don't expect *everything* to be perfect yet - ✔️ Token authorization via HTTP `Authorization` header - ✔️ Upload images, videos, files +- ✔️ Discord compatibility mode for video embed - ❌ Thumbnail support - ✔️ Delete support - ❌ Multiple database types (JSON, Mongo, MySQL, PostgreSQL, etc. Currently uses JSON) diff --git a/ass.js b/ass.js index 2efbff7..38c1f83 100755 --- a/ass.js +++ b/ass.js @@ -7,7 +7,7 @@ try { } // Load the config -const { host, port, domain, useSsl, resourceIdSize, resourceIdType } = require('./config.json'); +const { host, port, domain, useSsl, resourceIdSize, resourceIdType, discordMode } = require('./config.json'); //#region Imports const fs = require('fs-extra'); @@ -66,8 +66,9 @@ function startup() { let http = ('http').concat(useSsl ? 's' : '').concat('://'); let trueDomain = domain.concat((port != 80 || port != 443) ? `:${port}` : ''); + let discordCompat = (discordMode && req.file.mimetype == 'video/mp4') ? '.mp4' : ''; res.type('json').send({ - resource: `${http}${trueDomain}/${resourceId}`, + resource: `${http}${trueDomain}/${resourceId}${discordCompat}`, delete: `${http}${trueDomain}/delete/${req.file.filename}` }); }); diff --git a/setup.js b/setup.js index 43cb596..62a137c 100644 --- a/setup.js +++ b/setup.js @@ -14,7 +14,8 @@ const config = { domain: 'upload.example.com', useSsl: true, resourceIdSize: 12, - resourceIdType: 'zws' + resourceIdType: 'zws', + discordMode: false }; // Schema for setup prompts @@ -57,6 +58,12 @@ const setupSchema = { require: false, pattern: /(original|zws|random)/gi, message: 'Must be one of: original, zws, random' + }, + discordMode: { + description: 'Discord Mode (will automatically attach .mp4 to your video URLs so Discord embeds them properly)', + type: 'boolean', + default: config.discordMode, + required: false } } };