api upload min tags
This commit is contained in:
@@ -227,8 +227,8 @@ export default router => {
|
||||
}
|
||||
const tags = tagsRaw ? tagsRaw.split(',').map(t => t.trim()).filter(t => t.length > 0 && !['sfw', 'nsfw', 'nsfl'].includes(t.toLowerCase())) : [];
|
||||
const minTags = getMinTags();
|
||||
// In shitpost mode tags are optional
|
||||
if (!is_shitpost && tags.length < minTags) {
|
||||
// In shitpost mode tags are optional; skip entirely when minTags is 0
|
||||
if (!is_shitpost && minTags > 0 && tags.length < minTags) {
|
||||
return res.json({ success: false, msg: `At least ${minTags} tag${minTags !== 1 ? 's' : ''} required` }, 400);
|
||||
}
|
||||
|
||||
|
||||
@@ -158,11 +158,11 @@ export const handleUpload = async (req, res, self) => {
|
||||
const minTags = getMinTags();
|
||||
// In shitpost mode, tags are optional by default — unless shitpost_min_tags is configured.
|
||||
const shitpostMinTags = is_shitpost ? (parseInt(cfg.websrv.shitpost_min_tags) || 0) : 0;
|
||||
if (!is_shitpost && tags.length < minTags) {
|
||||
return sendJson(res, { success: false, msg: `At least ${minTags} tags are required` }, 400);
|
||||
if (!is_shitpost && minTags > 0 && tags.length < minTags) {
|
||||
return sendJson(res, { success: false, msg: `At least ${minTags} tag${minTags !== 1 ? 's' : ''} required` }, 400);
|
||||
}
|
||||
if (is_shitpost && shitpostMinTags > 0 && tags.length < shitpostMinTags) {
|
||||
return sendJson(res, { success: false, msg: `At least ${shitpostMinTags} tag${shitpostMinTags !== 1 ? 's' : ''} are required` }, 400);
|
||||
return sendJson(res, { success: false, msg: `At least ${shitpostMinTags} tag${shitpostMinTags !== 1 ? 's' : ''} required` }, 400);
|
||||
}
|
||||
|
||||
// Validate MIME type
|
||||
|
||||
Reference in New Issue
Block a user