Merge branch 'master' into ts-attempt-over-9000

pull/62/head
tycrek 3 years ago
commit ca73a377c4
No known key found for this signature in database
GPG Key ID: 25D74F3943625263

@ -5,7 +5,7 @@ import fs from 'fs-extra';
import { DateTime } from 'luxon';
const { WebhookClient, MessageEmbed } = require('discord.js');
import { doUpload, processUploaded } from '../storage';
const { maxUploadSize, resourceIdSize, gfyIdSize, resourceIdType } = require('../../config.json');
const { maxUploadSize, resourceIdSize, gfyIdSize, resourceIdType, spaceReplace } = require('../../config.json');
import { path, log, verify, getTrueHttp, getTrueDomain, generateId, formatBytes } from '../utils';
const { CODE_UNAUTHORIZED, CODE_PAYLOAD_TOO_LARGE } = require('../../MagicNumbers.json');
import { data } from '../data';
@ -63,6 +63,9 @@ router.post('/', (req: AssRequest, res: AssResponse, next: Function) => {
color: req.headers['x-ass-og-color']
};
// Fix spaces in originalname
req.file.originalname = req.file.originalname.replace(/\s/g, spaceReplace === '!' ? '' : spaceReplace);
// Save the file information
const resourceId = generateId(generator, resourceIdSize, req.headers['x-ass-gfycat'] || gfyIdSize, req.file!.originalname);
log.debug('Saving data', data.name);

@ -9,6 +9,7 @@ const config = {
resourceIdSize: 12,
gfyIdSize: 2,
resourceIdType: 'random',
spaceReplace: '_',
mediaStrict: false,
viewDirect: false,
frontendName: 'ass-x',
@ -132,6 +133,14 @@ function doSetup() {
pattern: /(original|zws|random|gfycat)/gi, // skipcq: JS-0113
message: 'Must be one of: zws, random, gfycat, original'
},
spaceReplace: {
description: 'Character to replace spaces in filenames with (must be a hyphen -, underscore _, or use ! to remove spaces)',
type: 'string',
default: config.spaceReplace,
required: false,
pattern: /^[-_!]$/gim,
message: 'Must be a - , _ , or !'
},
gfyIdSize: {
description: 'Adjective count for "gfycat" URL type',
type: 'integer',

Loading…
Cancel
Save