From f4f88d697ad48e8197d1685120643228421ff2d5 Mon Sep 17 00:00:00 2001 From: Thomas Lynch Date: Sat, 28 Jan 2023 14:27:38 +1100 Subject: [PATCH] indent & spacing adjustments --- lib/file/video/videothumbnail.js | 9 +++++---- lib/misc/dotwofactor.js | 6 ++++++ lib/misc/dynamic.js | 4 ++++ lib/post/deletequotes.js | 6 ++++-- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/file/video/videothumbnail.js b/lib/file/video/videothumbnail.js index afc1e9ef..f57d9ee1 100644 --- a/lib/file/video/videothumbnail.js +++ b/lib/file/video/videothumbnail.js @@ -16,10 +16,11 @@ module.exports = (file, geometry, timestamp) => { }); if (timestamp === 0) { //bypass issue with some dumb files like audio album art covert not working with .screenshots - command.inputOptions([ - '-t', - 0 - ]) + command + .inputOptions([ + '-t', + 0 + ]) .outputOptions([ `-vf scale=${geometry.width > geometry.height ? thumbSize + ':-2' : '-2:' + thumbSize}`, '-frames:v 1' diff --git a/lib/misc/dotwofactor.js b/lib/misc/dotwofactor.js index 4edab3c8..391c9933 100644 --- a/lib/misc/dotwofactor.js +++ b/lib/misc/dotwofactor.js @@ -2,18 +2,22 @@ const OTPAuth = require('otpauth') , redis = require(__dirname+'/../redis/redis.js'); module.exports = async (username, totpSecret, userInput) => { + if (!userInput) { return null; } + const totp = new OTPAuth.TOTP({ secret: totpSecret, algorithm: 'SHA256', }); + let delta = totp.validate({ token: userInput, algorithm: 'SHA256', window: 1, }); + if (delta !== null) { const key = `twofactor_success:${username}:${userInput}`; const uses = await redis.incr(key); @@ -22,5 +26,7 @@ module.exports = async (username, totpSecret, userInput) => { return null; } } + return delta; + }; diff --git a/lib/misc/dynamic.js b/lib/misc/dynamic.js index 6f912223..18e0b246 100644 --- a/lib/misc/dynamic.js +++ b/lib/misc/dynamic.js @@ -1,14 +1,18 @@ 'use strict'; module.exports = (req, res, code, page, data) => { + res.status(code); + if (req.body.minimal) { data.minimal = true; } + if (req.headers && req.headers['x-using-xhr'] != null) { //if sending header with js, and not a bypass_minimal page, show modal return res.json(data); } else { return res.render(page, data); } + }; diff --git a/lib/post/deletequotes.js b/lib/post/deletequotes.js index d2ddb9e0..556c0ebf 100644 --- a/lib/post/deletequotes.js +++ b/lib/post/deletequotes.js @@ -8,8 +8,10 @@ module.exports = (deletedPosts, updateQuotePosts) => { const quotesBefore = post.quotes.length; post.quotes = post.quotes.filter(q => q.postId !== ap.postId); if (quotesBefore !== post.quotes.length) { //optimization, probably - post.message = post.message.replace(`>>${ap.postId}`, - `>>${ap.postId}`); + post.message = post.message.replace( + `>>${ap.postId}`, + `>>${ap.postId}` + ); } }); bulkWrites.push({