2014-11-15 23:22:57 -05:00
|
|
|
'use strict';
|
|
|
|
|
|
2019-08-19 23:17:43 -04:00
|
|
|
const nconf = require('nconf');
|
2026-01-19 18:40:48 -05:00
|
|
|
const winston = require('winston');
|
2019-08-19 23:17:43 -04:00
|
|
|
const validator = require('validator');
|
|
|
|
|
const querystring = require('querystring');
|
2019-10-04 22:00:37 -04:00
|
|
|
const _ = require('lodash');
|
2022-02-01 21:43:09 -05:00
|
|
|
const chalk = require('chalk');
|
2019-08-19 23:17:43 -04:00
|
|
|
|
2021-07-09 11:40:05 -04:00
|
|
|
const translator = require('../translator');
|
2019-08-19 23:17:43 -04:00
|
|
|
const user = require('../user');
|
|
|
|
|
const privileges = require('../privileges');
|
|
|
|
|
const categories = require('../categories');
|
|
|
|
|
const plugins = require('../plugins');
|
|
|
|
|
const meta = require('../meta');
|
2021-09-20 10:11:25 -04:00
|
|
|
const middlewareHelpers = require('../middleware/helpers');
|
2022-05-31 14:56:36 -04:00
|
|
|
const utils = require('../utils');
|
2019-08-19 23:17:43 -04:00
|
|
|
|
|
|
|
|
const helpers = module.exports;
|
2014-11-15 23:22:57 -05:00
|
|
|
|
2020-10-26 10:43:18 -04:00
|
|
|
const relative_path = nconf.get('relative_path');
|
|
|
|
|
const url = nconf.get('url');
|
|
|
|
|
|
2020-06-04 01:14:46 -04:00
|
|
|
helpers.noScriptErrors = async function (req, res, error, httpStatus) {
|
2017-07-20 08:51:04 -04:00
|
|
|
if (req.body.noscript !== 'true') {
|
2021-09-21 17:04:17 -04:00
|
|
|
if (typeof error === 'string') {
|
2026-01-19 18:40:48 -05:00
|
|
|
winston.error(`${new Error(error).stack}`);
|
2021-09-21 17:04:17 -04:00
|
|
|
return res.status(httpStatus).send(error);
|
|
|
|
|
}
|
2026-01-19 18:40:48 -05:00
|
|
|
winston.error(`${new Error(JSON.stringify(error)).stack}`);
|
2021-09-21 17:04:17 -04:00
|
|
|
return res.status(httpStatus).json(error);
|
2017-07-20 08:51:04 -04:00
|
|
|
}
|
2021-04-18 21:38:47 -04:00
|
|
|
const middleware = require('../middleware');
|
2019-08-19 23:17:43 -04:00
|
|
|
const httpStatusString = httpStatus.toString();
|
2020-06-04 01:14:46 -04:00
|
|
|
await middleware.buildHeaderAsync(req, res);
|
|
|
|
|
res.status(httpStatus).render(httpStatusString, {
|
|
|
|
|
path: req.path,
|
|
|
|
|
loggedIn: req.loggedIn,
|
|
|
|
|
error: error,
|
|
|
|
|
returnLink: true,
|
2021-02-03 23:59:08 -07:00
|
|
|
title: `[[global:${httpStatusString}.title]]`,
|
2017-07-20 08:51:04 -04:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2018-06-18 14:37:32 -04:00
|
|
|
helpers.terms = {
|
2026-01-15 16:47:28 -05:00
|
|
|
alltime: 'alltime',
|
2018-06-18 14:37:32 -04:00
|
|
|
daily: 'day',
|
|
|
|
|
weekly: 'week',
|
|
|
|
|
monthly: 'month',
|
|
|
|
|
};
|
|
|
|
|
|
2020-09-13 19:41:39 -04:00
|
|
|
helpers.buildQueryString = function (query, key, value) {
|
2020-10-26 10:43:18 -04:00
|
|
|
const queryObj = { ...query };
|
2020-09-13 19:41:39 -04:00
|
|
|
if (value) {
|
|
|
|
|
queryObj[key] = value;
|
|
|
|
|
} else {
|
|
|
|
|
delete queryObj[key];
|
2018-06-18 14:37:32 -04:00
|
|
|
}
|
2020-09-13 19:41:39 -04:00
|
|
|
delete queryObj._;
|
2021-02-03 23:59:08 -07:00
|
|
|
return Object.keys(queryObj).length ? `?${querystring.stringify(queryObj)}` : '';
|
2018-06-18 14:37:32 -04:00
|
|
|
};
|
|
|
|
|
|
2020-06-30 11:34:32 -04:00
|
|
|
helpers.addLinkTags = function (params) {
|
|
|
|
|
params.res.locals.linkTags = params.res.locals.linkTags || [];
|
2023-06-30 20:51:03 -04:00
|
|
|
const page = params.page > 1 ? `?page=${params.page}` : '';
|
2020-06-30 11:34:32 -04:00
|
|
|
params.res.locals.linkTags.push({
|
|
|
|
|
rel: 'canonical',
|
2023-06-30 20:51:03 -04:00
|
|
|
href: `${url}/${params.url}${page}`,
|
2020-06-30 11:34:32 -04:00
|
|
|
});
|
|
|
|
|
|
2021-02-04 00:01:39 -07:00
|
|
|
params.tags.forEach((rel) => {
|
2021-02-03 23:59:08 -07:00
|
|
|
rel.href = `${url}/${params.url}${rel.href}`;
|
2020-06-30 11:34:32 -04:00
|
|
|
params.res.locals.linkTags.push(rel);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2018-06-18 14:37:32 -04:00
|
|
|
helpers.buildFilters = function (url, filter, query) {
|
2017-10-19 13:53:05 -04:00
|
|
|
return [{
|
|
|
|
|
name: '[[unread:all-topics]]',
|
2020-09-13 19:41:39 -04:00
|
|
|
url: url + helpers.buildQueryString(query, 'filter', ''),
|
2017-10-19 13:53:05 -04:00
|
|
|
selected: filter === '',
|
|
|
|
|
filter: '',
|
2020-07-08 14:09:10 -04:00
|
|
|
icon: 'fa-book',
|
2017-10-19 13:53:05 -04:00
|
|
|
}, {
|
|
|
|
|
name: '[[unread:new-topics]]',
|
2020-09-13 19:41:39 -04:00
|
|
|
url: url + helpers.buildQueryString(query, 'filter', 'new'),
|
2017-10-19 13:53:05 -04:00
|
|
|
selected: filter === 'new',
|
|
|
|
|
filter: 'new',
|
2020-07-08 14:09:10 -04:00
|
|
|
icon: 'fa-clock-o',
|
2017-10-19 13:53:05 -04:00
|
|
|
}, {
|
|
|
|
|
name: '[[unread:watched-topics]]',
|
2020-09-13 19:41:39 -04:00
|
|
|
url: url + helpers.buildQueryString(query, 'filter', 'watched'),
|
2017-10-19 13:53:05 -04:00
|
|
|
selected: filter === 'watched',
|
|
|
|
|
filter: 'watched',
|
2020-07-08 14:09:10 -04:00
|
|
|
icon: 'fa-bell-o',
|
2017-10-19 13:53:05 -04:00
|
|
|
}, {
|
|
|
|
|
name: '[[unread:unreplied-topics]]',
|
2020-09-13 19:41:39 -04:00
|
|
|
url: url + helpers.buildQueryString(query, 'filter', 'unreplied'),
|
2017-10-19 13:53:05 -04:00
|
|
|
selected: filter === 'unreplied',
|
|
|
|
|
filter: 'unreplied',
|
2020-07-08 14:09:10 -04:00
|
|
|
icon: 'fa-reply',
|
2017-10-19 13:53:05 -04:00
|
|
|
}];
|
|
|
|
|
};
|
|
|
|
|
|
2018-06-18 14:37:32 -04:00
|
|
|
helpers.buildTerms = function (url, term, query) {
|
|
|
|
|
return [{
|
|
|
|
|
name: '[[recent:alltime]]',
|
2026-01-15 16:47:28 -05:00
|
|
|
url: url + helpers.buildQueryString(query, 'term', 'alltime'),
|
2018-06-18 14:37:32 -04:00
|
|
|
selected: term === 'alltime',
|
|
|
|
|
term: 'alltime',
|
|
|
|
|
}, {
|
|
|
|
|
name: '[[recent:day]]',
|
2020-09-13 19:41:39 -04:00
|
|
|
url: url + helpers.buildQueryString(query, 'term', 'daily'),
|
2018-06-18 14:37:32 -04:00
|
|
|
selected: term === 'day',
|
|
|
|
|
term: 'day',
|
|
|
|
|
}, {
|
|
|
|
|
name: '[[recent:week]]',
|
2020-09-13 19:41:39 -04:00
|
|
|
url: url + helpers.buildQueryString(query, 'term', 'weekly'),
|
2018-06-18 14:37:32 -04:00
|
|
|
selected: term === 'week',
|
|
|
|
|
term: 'week',
|
|
|
|
|
}, {
|
|
|
|
|
name: '[[recent:month]]',
|
2020-09-13 19:41:39 -04:00
|
|
|
url: url + helpers.buildQueryString(query, 'term', 'monthly'),
|
2018-06-18 14:37:32 -04:00
|
|
|
selected: term === 'month',
|
|
|
|
|
term: 'month',
|
|
|
|
|
}];
|
|
|
|
|
};
|
|
|
|
|
|
2020-06-04 01:14:46 -04:00
|
|
|
helpers.notAllowed = async function (req, res, error) {
|
2021-07-21 13:27:21 -04:00
|
|
|
({ error } = await plugins.hooks.fire('filter:helpers.notAllowed', { req, res, error }));
|
2020-06-04 01:14:46 -04:00
|
|
|
|
2022-04-04 17:34:52 -04:00
|
|
|
await plugins.hooks.fire('response:helpers.notAllowed', { req, res, error });
|
|
|
|
|
if (res.headersSent) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-04 01:14:46 -04:00
|
|
|
if (req.loggedIn || req.uid === -1) {
|
|
|
|
|
if (res.locals.isAPI) {
|
2021-09-20 10:41:26 -04:00
|
|
|
if (req.originalUrl.startsWith(`${relative_path}/api/v3`)) {
|
2024-10-23 16:57:23 -04:00
|
|
|
await helpers.formatApiResponse(403, res, error);
|
2021-09-20 10:11:25 -04:00
|
|
|
} else {
|
|
|
|
|
res.status(403).json({
|
|
|
|
|
path: req.path.replace(/^\/api/, ''),
|
|
|
|
|
loggedIn: req.loggedIn,
|
|
|
|
|
error: error,
|
|
|
|
|
title: '[[global:403.title]]',
|
|
|
|
|
bodyClass: middlewareHelpers.buildBodyClass(req, res),
|
|
|
|
|
});
|
|
|
|
|
}
|
2014-11-15 23:22:57 -05:00
|
|
|
} else {
|
2021-04-18 21:38:47 -04:00
|
|
|
const middleware = require('../middleware');
|
2020-06-04 01:14:46 -04:00
|
|
|
await middleware.buildHeaderAsync(req, res);
|
|
|
|
|
res.status(403).render('403', {
|
|
|
|
|
path: req.path,
|
|
|
|
|
loggedIn: req.loggedIn,
|
2021-07-21 13:27:21 -04:00
|
|
|
error,
|
2020-06-04 01:14:46 -04:00
|
|
|
title: '[[global:403.title]]',
|
|
|
|
|
});
|
2014-11-15 23:22:57 -05:00
|
|
|
}
|
2020-06-04 01:14:46 -04:00
|
|
|
} else if (res.locals.isAPI) {
|
|
|
|
|
req.session.returnTo = req.url.replace(/^\/api/, '');
|
2024-10-23 16:32:11 -04:00
|
|
|
await helpers.formatApiResponse(401, res, error);
|
2020-06-04 01:14:46 -04:00
|
|
|
} else {
|
|
|
|
|
req.session.returnTo = req.url;
|
2021-03-09 20:49:54 -05:00
|
|
|
res.redirect(`${relative_path}/login${req.path.startsWith('/admin') ? '?local=1' : ''}`);
|
2020-06-04 01:14:46 -04:00
|
|
|
}
|
2014-11-15 23:22:57 -05:00
|
|
|
};
|
|
|
|
|
|
2020-08-06 10:48:35 -04:00
|
|
|
helpers.redirect = function (res, url, permanent) {
|
2020-12-03 10:29:18 -05:00
|
|
|
// this is used by sso plugins to redirect to the auth route
|
2020-12-03 17:20:03 -05:00
|
|
|
// { external: '/auth/sso' } or { external: 'https://domain/auth/sso' }
|
2020-12-03 10:29:18 -05:00
|
|
|
if (url.hasOwnProperty('external')) {
|
2024-10-23 15:25:16 -04:00
|
|
|
const redirectUrl = prependRelativePath(url.external);
|
2020-12-03 17:20:03 -05:00
|
|
|
if (res.locals.isAPI) {
|
2025-01-22 12:42:16 -05:00
|
|
|
res.set('X-Redirect', encodeURIComponent(redirectUrl)).status(200).json({ external: redirectUrl });
|
2020-12-03 17:20:03 -05:00
|
|
|
} else {
|
|
|
|
|
res.redirect(permanent ? 308 : 307, redirectUrl);
|
|
|
|
|
}
|
|
|
|
|
return;
|
2020-12-03 10:29:18 -05:00
|
|
|
}
|
2020-12-03 17:20:03 -05:00
|
|
|
|
2020-11-14 19:56:01 -05:00
|
|
|
if (res.locals.isAPI) {
|
2025-01-22 12:42:16 -05:00
|
|
|
res.set('X-Redirect', encodeURIComponent(url)).status(200).json(url);
|
2015-03-09 18:22:44 -04:00
|
|
|
} else {
|
2024-10-23 15:25:16 -04:00
|
|
|
res.redirect(permanent ? 308 : 307, prependRelativePath(url));
|
2015-03-09 18:22:44 -04:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2020-12-03 17:20:03 -05:00
|
|
|
function prependRelativePath(url) {
|
|
|
|
|
return url.startsWith('http://') || url.startsWith('https://') ?
|
|
|
|
|
url : relative_path + url;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-19 23:17:43 -04:00
|
|
|
helpers.buildCategoryBreadcrumbs = async function (cid) {
|
|
|
|
|
const breadcrumbs = [];
|
2014-12-11 22:55:00 -05:00
|
|
|
|
2019-08-19 23:17:43 -04:00
|
|
|
while (parseInt(cid, 10)) {
|
|
|
|
|
/* eslint-disable no-await-in-loop */
|
|
|
|
|
const data = await categories.getCategoryFields(cid, ['name', 'slug', 'parentCid', 'disabled', 'isSection']);
|
|
|
|
|
if (!data.disabled && !data.isSection) {
|
2016-04-21 11:40:40 -04:00
|
|
|
breadcrumbs.unshift({
|
2019-08-19 23:17:43 -04:00
|
|
|
text: String(data.name),
|
2023-10-11 13:03:43 -04:00
|
|
|
url: `${url}/category/${data.slug}`,
|
2020-03-26 12:04:04 -04:00
|
|
|
cid: cid,
|
2016-04-21 11:40:40 -04:00
|
|
|
});
|
|
|
|
|
}
|
2019-08-19 23:17:43 -04:00
|
|
|
cid = data.parentCid;
|
|
|
|
|
}
|
|
|
|
|
if (meta.config.homePageRoute && meta.config.homePageRoute !== 'categories') {
|
2015-01-29 01:06:48 -05:00
|
|
|
breadcrumbs.unshift({
|
2019-08-19 23:17:43 -04:00
|
|
|
text: '[[global:header.categories]]',
|
2023-10-11 13:03:43 -04:00
|
|
|
url: `${url}/categories`,
|
2014-12-11 22:55:00 -05:00
|
|
|
});
|
2019-08-19 23:17:43 -04:00
|
|
|
}
|
2015-01-29 01:06:48 -05:00
|
|
|
|
2019-08-19 23:17:43 -04:00
|
|
|
breadcrumbs.unshift({
|
2023-10-11 12:36:33 -04:00
|
|
|
text: meta.config.homePageTitle || '[[global:home]]',
|
2023-10-11 13:03:43 -04:00
|
|
|
url: url,
|
2015-01-29 01:06:48 -05:00
|
|
|
});
|
2019-08-19 23:17:43 -04:00
|
|
|
|
|
|
|
|
return breadcrumbs;
|
2015-01-29 01:06:48 -05:00
|
|
|
};
|
|
|
|
|
|
2016-10-13 11:43:39 +02:00
|
|
|
helpers.buildBreadcrumbs = function (crumbs) {
|
2019-08-19 23:17:43 -04:00
|
|
|
const breadcrumbs = [
|
2015-01-29 01:06:48 -05:00
|
|
|
{
|
2023-10-11 12:36:33 -04:00
|
|
|
text: meta.config.homePageTitle || '[[global:home]]',
|
2023-10-11 13:03:43 -04:00
|
|
|
url: url,
|
2017-02-17 19:31:21 -07:00
|
|
|
},
|
2015-01-29 01:06:48 -05:00
|
|
|
];
|
|
|
|
|
|
2021-02-04 00:01:39 -07:00
|
|
|
crumbs.forEach((crumb) => {
|
2015-01-29 01:06:48 -05:00
|
|
|
if (crumb) {
|
|
|
|
|
if (crumb.url) {
|
2023-10-11 13:03:43 -04:00
|
|
|
crumb.url = `${utils.isRelativeUrl(crumb.url) ? `${url}/` : ''}${crumb.url}`;
|
2015-01-29 01:06:48 -05:00
|
|
|
}
|
|
|
|
|
breadcrumbs.push(crumb);
|
|
|
|
|
}
|
2014-12-11 22:55:00 -05:00
|
|
|
});
|
2015-01-29 01:06:48 -05:00
|
|
|
|
|
|
|
|
return breadcrumbs;
|
2014-12-11 22:55:00 -05:00
|
|
|
};
|
2014-11-15 23:22:57 -05:00
|
|
|
|
2016-10-13 11:43:39 +02:00
|
|
|
helpers.buildTitle = function (pageTitle) {
|
2023-05-16 13:05:03 -04:00
|
|
|
pageTitle = pageTitle || '';
|
|
|
|
|
const titleLayout = meta.config.titleLayout || `${pageTitle ? '{pageTitle} | ' : ''}{browserTitle}`;
|
2015-09-23 01:59:13 -04:00
|
|
|
|
2019-08-19 23:17:43 -04:00
|
|
|
const browserTitle = validator.escape(String(meta.config.browserTitle || meta.config.title || 'NodeBB'));
|
2023-05-16 13:05:03 -04:00
|
|
|
|
2019-08-19 23:17:43 -04:00
|
|
|
const title = titleLayout.replace('{pageTitle}', () => pageTitle).replace('{browserTitle}', () => browserTitle);
|
2015-09-23 01:59:13 -04:00
|
|
|
return title;
|
|
|
|
|
};
|
|
|
|
|
|
2019-08-19 23:17:43 -04:00
|
|
|
helpers.getCategories = async function (set, uid, privilege, selectedCid) {
|
|
|
|
|
const cids = await categories.getCidsByPrivilege(set, uid, privilege);
|
2021-11-23 19:47:29 -05:00
|
|
|
return await getCategoryData(cids, uid, selectedCid, Object.values(categories.watchStates), privilege);
|
2018-08-17 16:39:50 -04:00
|
|
|
};
|
|
|
|
|
|
2020-10-02 16:35:20 -04:00
|
|
|
helpers.getCategoriesByStates = async function (uid, selectedCid, states, privilege = 'topics:read') {
|
2019-10-04 22:00:37 -04:00
|
|
|
const cids = await categories.getAllCidsFromSet('categories:cid');
|
2020-10-02 16:35:20 -04:00
|
|
|
return await getCategoryData(cids, uid, selectedCid, states, privilege);
|
2018-08-17 16:39:50 -04:00
|
|
|
};
|
|
|
|
|
|
2020-10-02 16:35:20 -04:00
|
|
|
async function getCategoryData(cids, uid, selectedCid, states, privilege) {
|
2021-11-23 19:47:29 -05:00
|
|
|
const [visibleCategories, selectData] = await Promise.all([
|
|
|
|
|
helpers.getVisibleCategories({
|
|
|
|
|
cids, uid, states, privilege, showLinks: false,
|
|
|
|
|
}),
|
|
|
|
|
helpers.getSelectedCategory(selectedCid),
|
|
|
|
|
]);
|
2019-10-04 22:00:37 -04:00
|
|
|
|
2020-10-02 16:35:20 -04:00
|
|
|
const categoriesData = categories.buildForSelectCategories(visibleCategories, ['disabledClass']);
|
2019-09-20 19:04:47 -04:00
|
|
|
|
2021-02-04 00:01:39 -07:00
|
|
|
categoriesData.forEach((category) => {
|
2021-11-23 19:47:29 -05:00
|
|
|
category.selected = selectData.selectedCids.includes(category.cid);
|
2019-08-19 23:17:43 -04:00
|
|
|
});
|
2021-11-23 19:47:29 -05:00
|
|
|
selectData.selectedCids.sort((a, b) => a - b);
|
2019-09-20 17:21:32 -04:00
|
|
|
return {
|
2019-09-20 19:04:47 -04:00
|
|
|
categories: categoriesData,
|
2021-11-23 19:47:29 -05:00
|
|
|
selectedCategory: selectData.selectedCategory,
|
|
|
|
|
selectedCids: selectData.selectedCids,
|
2019-09-20 17:21:32 -04:00
|
|
|
};
|
2016-11-03 13:06:21 +03:00
|
|
|
}
|
2019-07-03 12:48:26 -04:00
|
|
|
|
2021-02-07 15:09:52 -05:00
|
|
|
helpers.getVisibleCategories = async function (params) {
|
2021-02-06 14:10:15 -07:00
|
|
|
const { cids, uid, privilege } = params;
|
2021-02-07 15:09:52 -05:00
|
|
|
const states = params.states || [categories.watchStates.watching, categories.watchStates.notwatching];
|
|
|
|
|
const showLinks = !!params.showLinks;
|
|
|
|
|
|
|
|
|
|
let [allowed, watchState, categoriesData, isAdmin, isModerator] = await Promise.all([
|
|
|
|
|
privileges.categories.isUserAllowedTo(privilege, cids, uid),
|
|
|
|
|
categories.getWatchState(cids, uid),
|
|
|
|
|
categories.getCategoriesData(cids),
|
|
|
|
|
user.isAdministrator(uid),
|
|
|
|
|
user.isModerator(uid, cids),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const filtered = await plugins.hooks.fire('filter:helpers.getVisibleCategories', {
|
|
|
|
|
uid: uid,
|
|
|
|
|
allowed: allowed,
|
|
|
|
|
watchState: watchState,
|
|
|
|
|
categoriesData: categoriesData,
|
|
|
|
|
isModerator: isModerator,
|
|
|
|
|
isAdmin: isAdmin,
|
|
|
|
|
});
|
|
|
|
|
({ allowed, watchState, categoriesData, isModerator, isAdmin } = filtered);
|
|
|
|
|
|
|
|
|
|
categories.getTree(categoriesData, params.parentCid);
|
|
|
|
|
|
|
|
|
|
const cidToAllowed = _.zipObject(cids, allowed.map((allowed, i) => isAdmin || isModerator[i] || allowed));
|
|
|
|
|
const cidToCategory = _.zipObject(cids, categoriesData);
|
|
|
|
|
const cidToWatchState = _.zipObject(cids, watchState);
|
|
|
|
|
|
2021-02-04 00:01:39 -07:00
|
|
|
return categoriesData.filter((c) => {
|
2021-02-07 15:09:52 -05:00
|
|
|
if (!c) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
const hasVisibleChildren = checkVisibleChildren(c, cidToAllowed, cidToWatchState, states);
|
2021-02-04 02:07:29 -07:00
|
|
|
const isCategoryVisible = (
|
|
|
|
|
cidToAllowed[c.cid] &&
|
|
|
|
|
(showLinks || !c.link) &&
|
|
|
|
|
!c.disabled &&
|
|
|
|
|
states.includes(cidToWatchState[c.cid])
|
|
|
|
|
);
|
2021-02-07 15:09:52 -05:00
|
|
|
const shouldBeRemoved = !hasVisibleChildren && !isCategoryVisible;
|
|
|
|
|
const shouldBeDisaplayedAsDisabled = hasVisibleChildren && !isCategoryVisible;
|
|
|
|
|
|
|
|
|
|
if (shouldBeDisaplayedAsDisabled) {
|
|
|
|
|
c.disabledClass = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (shouldBeRemoved && c.parent && c.parent.cid && cidToCategory[c.parent.cid]) {
|
|
|
|
|
cidToCategory[c.parent.cid].children = cidToCategory[c.parent.cid].children.filter(child => child.cid !== c.cid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return !shouldBeRemoved;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2021-11-23 19:47:29 -05:00
|
|
|
helpers.getSelectedCategory = async function (cids) {
|
|
|
|
|
if (cids && !Array.isArray(cids)) {
|
|
|
|
|
cids = [cids];
|
2021-02-07 15:09:52 -05:00
|
|
|
}
|
2021-11-23 19:47:29 -05:00
|
|
|
cids = cids && cids.map(cid => parseInt(cid, 10));
|
|
|
|
|
let selectedCategories = await categories.getCategoriesData(cids);
|
|
|
|
|
const selectedCids = selectedCategories.map(c => c && c.cid).filter(Boolean);
|
2021-02-07 15:09:52 -05:00
|
|
|
if (selectedCategories.length > 1) {
|
|
|
|
|
selectedCategories = {
|
|
|
|
|
icon: 'fa-plus',
|
|
|
|
|
name: '[[unread:multiple-categories-selected]]',
|
|
|
|
|
bgColor: '#ddd',
|
|
|
|
|
};
|
2021-11-23 19:47:29 -05:00
|
|
|
} else if (selectedCategories.length === 1 && selectedCategories[0]) {
|
2021-02-07 15:09:52 -05:00
|
|
|
selectedCategories = selectedCategories[0];
|
|
|
|
|
} else {
|
|
|
|
|
selectedCategories = null;
|
|
|
|
|
}
|
|
|
|
|
return {
|
2021-11-23 19:47:29 -05:00
|
|
|
selectedCids: selectedCids,
|
2021-02-07 15:09:52 -05:00
|
|
|
selectedCategory: selectedCategories,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
Bootstrap5 (#10894)
* chore: up deps
* chore: up composer
* fix(deps): bump 2factor to v7
* chore: up harmony
* chore: up harmony
* fix: missing await
* feat: allow middlewares to pass in template values via res.locals
* feat: buildAccountData middleware automatically added ot all account routes
* fix: properly allow values in res.locals.templateValues to be added to the template data
* refactor: user/blocks
* refactor(accounts): categories and consent
* feat: automatically 404 if exposeUid or exposeGroupName come up empty
* refactor: remove calls to getUserDataByUserSlug for most account routes, since it is populated via middleware now
* fix: allow exposeUid and exposeGroupName to work with slugs with mixed capitalization
* fix: move reputation removal check to accountHelpers method
* test: skip i18n tests if ref branch when present is not develop
* fix(deps): bump theme versions
* fix(deps): bump ntfy and 2factor
* chore: up harmony
* fix: add missing return
* fix: #11191, only focus on search input on md environments and up
* feat: allow file uploads on mobile chat
closes https://github.com/NodeBB/NodeBB/issues/11217
* chore: up themes
* chore: add lang string
* fix(deps): bump ntfy to 1.0.15
* refactor: use new if/each syntax
* chore: up composer
* fix: regression from user helper refactor
* chore: up harmony
* chore: up composer
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: fix composer version
* feat: add increment helper
* chore: up harmony
* fix: #11228 no timestamps in future :hourglass:
* chore: up harmony
* check config.theme as well
fire action:posts.loaded after processing dom
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up themes
* chore: up harmony
* remove extra class
* refactor: move these to core from harmony
* chore: up widgets
* chore: up widgets
* height auto
* fix: closes #11238
* dont focus inputs, annoying on mobile
* fix: dont focus twice, only focus on chat input on desktop
dont wrap widget footer in row
* chore: up harmony
* chore: up harmony
* update chat window
* chore: up themes
* fix cache buster for skins
* chat fixes
* chore: up harmony
* chore: up composer
* refactor: change hook logs to debug
* fix: scroll to post right after adding to dom
* fix: hash scrolling and highlighting correct post
* test: re-enable read API schema tests
* fix: add back schema changes for 179faa2270f2ad955dcc4a7b04755acce59e6ffd and c3920ccb10d8ead2dcd9914bb1784bed3f6adfd4
* fix: schema changes from 488f0978a4aa1ca1e4d2a1f2e8c7ef7a681f2f27
* fix: schema changes for f4cf482a874701ce80c0f306c49d8788cec66f87
* fix: schema update for be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 69c96078ea78ee2c45885a90a6f6a59f9042a33c
* fix: schema changes for d1364c313021e48a879a818b24947e1457c062f7
* fix: schema changes for 84ff1152f7552dd866e25a90972d970b9861107e
* fix: schema changes for b860c2605c209e0650ef98f4c80d842ea23a51ce
* fix: schema changes for 23cb67a1126481848fac39aafd1e253441e76d7f
* fix: schema changes for b916e42f400dac8aa51670b15e439f87f0eb8939
* fix: schema change for a9bbb586fcb3a1c61b5fb69052236e78cdf7d743
* fix: schema changes for 4b738c8cd36c936a1dbe2bb900c694bf6c5520ec
* fix: schema changes for 58b5781cea9acb129e6604a82ab5a5bfc0d8394d
* fix: schema changes for 794bf01b21709c4be06584d576d706b3d6342057
* fix: schema changes for 80ea12c1c1963f5b39fb64841e4f3c8da3c87af2, e368feef51e0766f119c9710fb4db8f64724725c, and 52ead114bec961c62fa2eb0786540e229f6e4873
* fix: composer-default object in config?
* fix: schema changes for 9acdc6808c070555352951c651921df181b10993 and 093093420027999df3c67bf0ea6024f6dbf81d2d
* fix: schema changes for c0a52924f1f7ef8caeaacda67363ac269b56042c
* fix: schema change for aba420a3f3b774e949c2539c73f3dc0e1ae79a38, move loggedInUser to optional props
* fix: schema changes for 8c67031609da30d788561459f8bb76e9a69253de
* fix: schema changes for 27e53b42f3ce48fa61d3754375715cd41ffe808d
* fix: schema changes for 28359665187b0a3b9ec6226dca1234ebdbd725a5
* fix: breaking test for email confirmation API call
* fix: schema changes for refactored search page
* fix: schema changes for user object
* fix: schema changes for 9f531f957e08eabb4bae844ddd67bde14d9b59f0
* fix: schema changes for c4042c70decd628e5b880bd109515b47e4e16164 and 23175110a29640e6fa052db1079bfedb34a61055
* fix: schema changes for 9b3616b10392e247974eb0c1e6225a1582bf6c69
* fix: schema changes for 5afd5de07d42fd33f039a6f85ded3b4992200e5a
* fix: schema change for 1d7baf12171cffbd3af8914bef4e6297d1160d49
* fix: schema changes for 57bfb37c55a839662144e684875003ab52315ecc and be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 6e86b4afa20d662af8b9f1c07518df2d8c258105 and 3efad2e13b7319eb9a1f4fda7af047be43ebc11f and 68f66223e73a72f378f193c83a9b5546bede2cda
* fix: allowing optional qs prop in pagination keys (not sure why this didn't break before)
* fix: re-login on email change
* fix: schema changes for c926358d734a2fa410de87f4e4a91744215fc14a
* fix: schema changes for 388a8270c9882892bad5c8141f65da8d59eac0fd
* fix: schema change for 2658bcc821c22e137a6eeb9bb74098856a642eaf
* fix: no need to call account middlewares for chats routes
* fix: schema changes for 71743affc3e58dc85d4ffa15ce043d4d9ddd3d67
* fix: final schema changes
* test: support for anyOf and oneOf
* fix: check thumb
* dont scroll to top on back press
* remove group log
* fix: add top margin to merged and deleted alerts
* chore: up widgets
* fix: improve fix-lists mixin
* chore: up harmony/composer
* feat: allow hiding quicksearch results during search
* dont record searches made by composer
* chore: up 54
* chore: up spam be gone
* feat: add prev/next page and page count into mobile paginator
* chore: up harmony
* chore: up harmony
* use old style for IS
* fix: hide entire toolbar row if no posts or not singlePost
* fix: updated messaging for post-queue template, #11206
* fix: btn-sm on post queue back button
* fix: bump harmony, closes #11206
* fix: remove unused alert module import
* fix: bump harmony
* fix: bump harmony
* chore: up harmony
* refactor: IS scrolltop
* fix: update users:search-user-for-chat source string
* feat: support for mark-read toggle on chats dropdown and recent chats list
* feat: api v3 calls to mark chat read/unread
* feat: send event:chats.mark socket event on mark read or unread
* refactor: allow frontend to mark chats as unread, use new API v3 routes instead of socket calls, better frontend event handling
* docs: openapi schema updates for chat marking
* fix: allow unread state toggling in chats dropdown too
* fix: issue where repeated openings of the chats dropdown would continually add events for mark-read/unread
* fix: debug log
* refactor: move userSearch filter to a module
* feat(routes): allow remounting /categories (#11230)
* feat: send flags count to frontend on flags list page
* refactor: filter form client-side js to extract out some logic
* fix: applyFilters to not take any arguments, update selectedCids in updateButton instead of onHidden
* fix: use userFilter module for assignee, reporterId, targetUid
* fix(openapi): schema changes for updated flags page
* fix: dont allow adding duplicates to userFilter
* use same var
* remove log
* fix: closes #11282
* feat: lang key for x-topics
* chore: up harmony
* chore: up emoji
* chore: up harmony
* fix: update userFilter to allow new option `selectedBlock`
* fix: wrong block name passed to userFilter
* fix: https://github.com/NodeBB/NodeBB/issues/11283
* fix: chats, allow multiple dropdowns like in harmony
* chore: up harmony
* refactor: flag note adding/editing, closes #11285
* fix: remove old prepareEdit logic
* chore: add caveat about hacky code block in userFilter module
* fix: placeholders for userFilter module
* refactor: navigator so it works with multiple thumbs/navigators
* chore: up harmony
* fix: closes #11287, destroy quick reply autocomplete
on navigation
* fix: filter disabled categories on user categories page count
* chore: up harmony
* docs: update openapi spec to include info about passing in timestamps for topic creation, removing timestamp as valid request param for topic replying
* fix: send back null values on ACP search dashboard for startDate and endDate if not expicitly passed in, fix tests
* fix: tweak table order in ACP dash searches
* fix: only invoke navigator click drag on left mouse button
* feat: add back unread indicator to navigator
* clear bookmark on mark unread
* fix: navigator crash on ajaxify
* better thumb top calculation
* fix: reset user bookmark when topic is marked unread
* Revert "fix: reset user bookmark when topic is marked unread"
This reverts commit 9bcd85c2c6848c3d325d32027261809da6e11c9e.
* fix: update unread indicator on scroll, add unread count
* chore: bump harmony
* fix: crash on navigator unread update when backing out of a topic
* fix: closes #11183
* fix: update topics:recent zset when rescheduling a topic
* fix: dupe quote button, increase delay, hide immediately on empty selection
* fix: navigator not showing up on first load
* refactor: remove glance
assorted fixes to navigator
dont reduce remaning count if user scrolls down and up quickly
only call topic.navigatorCallback when index changes
* more sanity checks for bookmark
dont allow setting bookmark higher than topic postcount
* closes #11218, :train:
* Revert "fix: update topics:recent zset when rescheduling a topic"
This reverts commit 737973cca9e94b6cb3867492a09e1e0b1af391d5.
* fix: #11306, show proper error if queued post doesn't exist
was showing no-privileges if someone else accepted the post
* https://github.com/NodeBB/NodeBB/issues/11307
dont use li
* chore: up harmony
* chore: bump version string
* fix: copy paste fail
* feat: closes #7382, tag filtering
add client side support for filtering by tags on /category, /recent and /unread
* chore: up harmony
* chore: up harmony
* Revert "fix: add back req.query fallback for backwards compatibility" [breaking]
This reverts commit cf6cc2c454dc35c330393c62ee8ce67b42d8eefb.
This commit is no longer required as passing in a CSRF token via query parameter is no longer supported as of NodeBB v3.x
This is a breaking change.
* fix: pass csrf token in form data, re: NodeBB/NodeBB#11309
* chore: up deps
* fix: tests, use x-csrf-token query param removed
* test: fix csrf_token
* lint: remove unused
* feat: add itemprop="image" to avatar helper
* fix: get chat upload button in chat modal
* breaking: remove deprecated socket.io methods
* test: update messaging tests to not use sockets
* fix: parent post links
* fix: prevent post tooltip if mouse leaves before data/tpl is loaded
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up harmony
* fix: nested replies indices
* fix(deps): bump 2factor
* feat: add loggedIn user to all api routes
* chore: up themes
* refactor: audit admin v3 write api routes as per #11321
* refactor: audit category v3 write api routes as per #11321 [breaking]
docs: fix open api spec for #11321
* refactor: audit chat v3 write api routes as per #11321
* refactor: audit files v3 write api routes as per #11321
* refactor: audit flags v3 write api routes as per #11321
* refactor: audit posts v3 write api routes as per #11321
* refactor: audit topics v3 write api routes as per #11321
* refactor: audit users v3 write api routes as per #11321
* fix: lang string
* remove min height
* fix: empty topic/labels taking up space
* fix: tag filtering when changing filter to watched topics
or changing popular time limit to month
* chore: up harmony
* fix: closes #11354, show no post error if queued post already accepted/rejected
* test: #11354
* test: #11354
* fix(deps): bump 2factor
* fix: #11357 clear cache on thumb remove
* fix: thumb remove on windows, closes #11357
* test: openapi for thumbs
* test: fix openapi
---------
Co-authored-by: Julian Lam <julian@nodebb.org>
Co-authored-by: Opliko <opliko.reg@protonmail.com>
2023-03-17 11:58:31 -04:00
|
|
|
helpers.getSelectedTag = function (tags) {
|
|
|
|
|
if (tags && !Array.isArray(tags)) {
|
|
|
|
|
tags = [tags];
|
|
|
|
|
}
|
|
|
|
|
tags = tags || [];
|
2025-04-07 13:23:22 -04:00
|
|
|
const tagData = tags.map(t => String(t));
|
Bootstrap5 (#10894)
* chore: up deps
* chore: up composer
* fix(deps): bump 2factor to v7
* chore: up harmony
* chore: up harmony
* fix: missing await
* feat: allow middlewares to pass in template values via res.locals
* feat: buildAccountData middleware automatically added ot all account routes
* fix: properly allow values in res.locals.templateValues to be added to the template data
* refactor: user/blocks
* refactor(accounts): categories and consent
* feat: automatically 404 if exposeUid or exposeGroupName come up empty
* refactor: remove calls to getUserDataByUserSlug for most account routes, since it is populated via middleware now
* fix: allow exposeUid and exposeGroupName to work with slugs with mixed capitalization
* fix: move reputation removal check to accountHelpers method
* test: skip i18n tests if ref branch when present is not develop
* fix(deps): bump theme versions
* fix(deps): bump ntfy and 2factor
* chore: up harmony
* fix: add missing return
* fix: #11191, only focus on search input on md environments and up
* feat: allow file uploads on mobile chat
closes https://github.com/NodeBB/NodeBB/issues/11217
* chore: up themes
* chore: add lang string
* fix(deps): bump ntfy to 1.0.15
* refactor: use new if/each syntax
* chore: up composer
* fix: regression from user helper refactor
* chore: up harmony
* chore: up composer
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: fix composer version
* feat: add increment helper
* chore: up harmony
* fix: #11228 no timestamps in future :hourglass:
* chore: up harmony
* check config.theme as well
fire action:posts.loaded after processing dom
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up themes
* chore: up harmony
* remove extra class
* refactor: move these to core from harmony
* chore: up widgets
* chore: up widgets
* height auto
* fix: closes #11238
* dont focus inputs, annoying on mobile
* fix: dont focus twice, only focus on chat input on desktop
dont wrap widget footer in row
* chore: up harmony
* chore: up harmony
* update chat window
* chore: up themes
* fix cache buster for skins
* chat fixes
* chore: up harmony
* chore: up composer
* refactor: change hook logs to debug
* fix: scroll to post right after adding to dom
* fix: hash scrolling and highlighting correct post
* test: re-enable read API schema tests
* fix: add back schema changes for 179faa2270f2ad955dcc4a7b04755acce59e6ffd and c3920ccb10d8ead2dcd9914bb1784bed3f6adfd4
* fix: schema changes from 488f0978a4aa1ca1e4d2a1f2e8c7ef7a681f2f27
* fix: schema changes for f4cf482a874701ce80c0f306c49d8788cec66f87
* fix: schema update for be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 69c96078ea78ee2c45885a90a6f6a59f9042a33c
* fix: schema changes for d1364c313021e48a879a818b24947e1457c062f7
* fix: schema changes for 84ff1152f7552dd866e25a90972d970b9861107e
* fix: schema changes for b860c2605c209e0650ef98f4c80d842ea23a51ce
* fix: schema changes for 23cb67a1126481848fac39aafd1e253441e76d7f
* fix: schema changes for b916e42f400dac8aa51670b15e439f87f0eb8939
* fix: schema change for a9bbb586fcb3a1c61b5fb69052236e78cdf7d743
* fix: schema changes for 4b738c8cd36c936a1dbe2bb900c694bf6c5520ec
* fix: schema changes for 58b5781cea9acb129e6604a82ab5a5bfc0d8394d
* fix: schema changes for 794bf01b21709c4be06584d576d706b3d6342057
* fix: schema changes for 80ea12c1c1963f5b39fb64841e4f3c8da3c87af2, e368feef51e0766f119c9710fb4db8f64724725c, and 52ead114bec961c62fa2eb0786540e229f6e4873
* fix: composer-default object in config?
* fix: schema changes for 9acdc6808c070555352951c651921df181b10993 and 093093420027999df3c67bf0ea6024f6dbf81d2d
* fix: schema changes for c0a52924f1f7ef8caeaacda67363ac269b56042c
* fix: schema change for aba420a3f3b774e949c2539c73f3dc0e1ae79a38, move loggedInUser to optional props
* fix: schema changes for 8c67031609da30d788561459f8bb76e9a69253de
* fix: schema changes for 27e53b42f3ce48fa61d3754375715cd41ffe808d
* fix: schema changes for 28359665187b0a3b9ec6226dca1234ebdbd725a5
* fix: breaking test for email confirmation API call
* fix: schema changes for refactored search page
* fix: schema changes for user object
* fix: schema changes for 9f531f957e08eabb4bae844ddd67bde14d9b59f0
* fix: schema changes for c4042c70decd628e5b880bd109515b47e4e16164 and 23175110a29640e6fa052db1079bfedb34a61055
* fix: schema changes for 9b3616b10392e247974eb0c1e6225a1582bf6c69
* fix: schema changes for 5afd5de07d42fd33f039a6f85ded3b4992200e5a
* fix: schema change for 1d7baf12171cffbd3af8914bef4e6297d1160d49
* fix: schema changes for 57bfb37c55a839662144e684875003ab52315ecc and be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 6e86b4afa20d662af8b9f1c07518df2d8c258105 and 3efad2e13b7319eb9a1f4fda7af047be43ebc11f and 68f66223e73a72f378f193c83a9b5546bede2cda
* fix: allowing optional qs prop in pagination keys (not sure why this didn't break before)
* fix: re-login on email change
* fix: schema changes for c926358d734a2fa410de87f4e4a91744215fc14a
* fix: schema changes for 388a8270c9882892bad5c8141f65da8d59eac0fd
* fix: schema change for 2658bcc821c22e137a6eeb9bb74098856a642eaf
* fix: no need to call account middlewares for chats routes
* fix: schema changes for 71743affc3e58dc85d4ffa15ce043d4d9ddd3d67
* fix: final schema changes
* test: support for anyOf and oneOf
* fix: check thumb
* dont scroll to top on back press
* remove group log
* fix: add top margin to merged and deleted alerts
* chore: up widgets
* fix: improve fix-lists mixin
* chore: up harmony/composer
* feat: allow hiding quicksearch results during search
* dont record searches made by composer
* chore: up 54
* chore: up spam be gone
* feat: add prev/next page and page count into mobile paginator
* chore: up harmony
* chore: up harmony
* use old style for IS
* fix: hide entire toolbar row if no posts or not singlePost
* fix: updated messaging for post-queue template, #11206
* fix: btn-sm on post queue back button
* fix: bump harmony, closes #11206
* fix: remove unused alert module import
* fix: bump harmony
* fix: bump harmony
* chore: up harmony
* refactor: IS scrolltop
* fix: update users:search-user-for-chat source string
* feat: support for mark-read toggle on chats dropdown and recent chats list
* feat: api v3 calls to mark chat read/unread
* feat: send event:chats.mark socket event on mark read or unread
* refactor: allow frontend to mark chats as unread, use new API v3 routes instead of socket calls, better frontend event handling
* docs: openapi schema updates for chat marking
* fix: allow unread state toggling in chats dropdown too
* fix: issue where repeated openings of the chats dropdown would continually add events for mark-read/unread
* fix: debug log
* refactor: move userSearch filter to a module
* feat(routes): allow remounting /categories (#11230)
* feat: send flags count to frontend on flags list page
* refactor: filter form client-side js to extract out some logic
* fix: applyFilters to not take any arguments, update selectedCids in updateButton instead of onHidden
* fix: use userFilter module for assignee, reporterId, targetUid
* fix(openapi): schema changes for updated flags page
* fix: dont allow adding duplicates to userFilter
* use same var
* remove log
* fix: closes #11282
* feat: lang key for x-topics
* chore: up harmony
* chore: up emoji
* chore: up harmony
* fix: update userFilter to allow new option `selectedBlock`
* fix: wrong block name passed to userFilter
* fix: https://github.com/NodeBB/NodeBB/issues/11283
* fix: chats, allow multiple dropdowns like in harmony
* chore: up harmony
* refactor: flag note adding/editing, closes #11285
* fix: remove old prepareEdit logic
* chore: add caveat about hacky code block in userFilter module
* fix: placeholders for userFilter module
* refactor: navigator so it works with multiple thumbs/navigators
* chore: up harmony
* fix: closes #11287, destroy quick reply autocomplete
on navigation
* fix: filter disabled categories on user categories page count
* chore: up harmony
* docs: update openapi spec to include info about passing in timestamps for topic creation, removing timestamp as valid request param for topic replying
* fix: send back null values on ACP search dashboard for startDate and endDate if not expicitly passed in, fix tests
* fix: tweak table order in ACP dash searches
* fix: only invoke navigator click drag on left mouse button
* feat: add back unread indicator to navigator
* clear bookmark on mark unread
* fix: navigator crash on ajaxify
* better thumb top calculation
* fix: reset user bookmark when topic is marked unread
* Revert "fix: reset user bookmark when topic is marked unread"
This reverts commit 9bcd85c2c6848c3d325d32027261809da6e11c9e.
* fix: update unread indicator on scroll, add unread count
* chore: bump harmony
* fix: crash on navigator unread update when backing out of a topic
* fix: closes #11183
* fix: update topics:recent zset when rescheduling a topic
* fix: dupe quote button, increase delay, hide immediately on empty selection
* fix: navigator not showing up on first load
* refactor: remove glance
assorted fixes to navigator
dont reduce remaning count if user scrolls down and up quickly
only call topic.navigatorCallback when index changes
* more sanity checks for bookmark
dont allow setting bookmark higher than topic postcount
* closes #11218, :train:
* Revert "fix: update topics:recent zset when rescheduling a topic"
This reverts commit 737973cca9e94b6cb3867492a09e1e0b1af391d5.
* fix: #11306, show proper error if queued post doesn't exist
was showing no-privileges if someone else accepted the post
* https://github.com/NodeBB/NodeBB/issues/11307
dont use li
* chore: up harmony
* chore: bump version string
* fix: copy paste fail
* feat: closes #7382, tag filtering
add client side support for filtering by tags on /category, /recent and /unread
* chore: up harmony
* chore: up harmony
* Revert "fix: add back req.query fallback for backwards compatibility" [breaking]
This reverts commit cf6cc2c454dc35c330393c62ee8ce67b42d8eefb.
This commit is no longer required as passing in a CSRF token via query parameter is no longer supported as of NodeBB v3.x
This is a breaking change.
* fix: pass csrf token in form data, re: NodeBB/NodeBB#11309
* chore: up deps
* fix: tests, use x-csrf-token query param removed
* test: fix csrf_token
* lint: remove unused
* feat: add itemprop="image" to avatar helper
* fix: get chat upload button in chat modal
* breaking: remove deprecated socket.io methods
* test: update messaging tests to not use sockets
* fix: parent post links
* fix: prevent post tooltip if mouse leaves before data/tpl is loaded
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up harmony
* fix: nested replies indices
* fix(deps): bump 2factor
* feat: add loggedIn user to all api routes
* chore: up themes
* refactor: audit admin v3 write api routes as per #11321
* refactor: audit category v3 write api routes as per #11321 [breaking]
docs: fix open api spec for #11321
* refactor: audit chat v3 write api routes as per #11321
* refactor: audit files v3 write api routes as per #11321
* refactor: audit flags v3 write api routes as per #11321
* refactor: audit posts v3 write api routes as per #11321
* refactor: audit topics v3 write api routes as per #11321
* refactor: audit users v3 write api routes as per #11321
* fix: lang string
* remove min height
* fix: empty topic/labels taking up space
* fix: tag filtering when changing filter to watched topics
or changing popular time limit to month
* chore: up harmony
* fix: closes #11354, show no post error if queued post already accepted/rejected
* test: #11354
* test: #11354
* fix(deps): bump 2factor
* fix: #11357 clear cache on thumb remove
* fix: thumb remove on windows, closes #11357
* test: openapi for thumbs
* test: fix openapi
---------
Co-authored-by: Julian Lam <julian@nodebb.org>
Co-authored-by: Opliko <opliko.reg@protonmail.com>
2023-03-17 11:58:31 -04:00
|
|
|
let selectedTag = null;
|
|
|
|
|
if (tagData.length) {
|
|
|
|
|
selectedTag = {
|
2025-04-07 13:23:22 -04:00
|
|
|
label: validator.escape(tagData.join(', ')),
|
Bootstrap5 (#10894)
* chore: up deps
* chore: up composer
* fix(deps): bump 2factor to v7
* chore: up harmony
* chore: up harmony
* fix: missing await
* feat: allow middlewares to pass in template values via res.locals
* feat: buildAccountData middleware automatically added ot all account routes
* fix: properly allow values in res.locals.templateValues to be added to the template data
* refactor: user/blocks
* refactor(accounts): categories and consent
* feat: automatically 404 if exposeUid or exposeGroupName come up empty
* refactor: remove calls to getUserDataByUserSlug for most account routes, since it is populated via middleware now
* fix: allow exposeUid and exposeGroupName to work with slugs with mixed capitalization
* fix: move reputation removal check to accountHelpers method
* test: skip i18n tests if ref branch when present is not develop
* fix(deps): bump theme versions
* fix(deps): bump ntfy and 2factor
* chore: up harmony
* fix: add missing return
* fix: #11191, only focus on search input on md environments and up
* feat: allow file uploads on mobile chat
closes https://github.com/NodeBB/NodeBB/issues/11217
* chore: up themes
* chore: add lang string
* fix(deps): bump ntfy to 1.0.15
* refactor: use new if/each syntax
* chore: up composer
* fix: regression from user helper refactor
* chore: up harmony
* chore: up composer
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: fix composer version
* feat: add increment helper
* chore: up harmony
* fix: #11228 no timestamps in future :hourglass:
* chore: up harmony
* check config.theme as well
fire action:posts.loaded after processing dom
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up themes
* chore: up harmony
* remove extra class
* refactor: move these to core from harmony
* chore: up widgets
* chore: up widgets
* height auto
* fix: closes #11238
* dont focus inputs, annoying on mobile
* fix: dont focus twice, only focus on chat input on desktop
dont wrap widget footer in row
* chore: up harmony
* chore: up harmony
* update chat window
* chore: up themes
* fix cache buster for skins
* chat fixes
* chore: up harmony
* chore: up composer
* refactor: change hook logs to debug
* fix: scroll to post right after adding to dom
* fix: hash scrolling and highlighting correct post
* test: re-enable read API schema tests
* fix: add back schema changes for 179faa2270f2ad955dcc4a7b04755acce59e6ffd and c3920ccb10d8ead2dcd9914bb1784bed3f6adfd4
* fix: schema changes from 488f0978a4aa1ca1e4d2a1f2e8c7ef7a681f2f27
* fix: schema changes for f4cf482a874701ce80c0f306c49d8788cec66f87
* fix: schema update for be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 69c96078ea78ee2c45885a90a6f6a59f9042a33c
* fix: schema changes for d1364c313021e48a879a818b24947e1457c062f7
* fix: schema changes for 84ff1152f7552dd866e25a90972d970b9861107e
* fix: schema changes for b860c2605c209e0650ef98f4c80d842ea23a51ce
* fix: schema changes for 23cb67a1126481848fac39aafd1e253441e76d7f
* fix: schema changes for b916e42f400dac8aa51670b15e439f87f0eb8939
* fix: schema change for a9bbb586fcb3a1c61b5fb69052236e78cdf7d743
* fix: schema changes for 4b738c8cd36c936a1dbe2bb900c694bf6c5520ec
* fix: schema changes for 58b5781cea9acb129e6604a82ab5a5bfc0d8394d
* fix: schema changes for 794bf01b21709c4be06584d576d706b3d6342057
* fix: schema changes for 80ea12c1c1963f5b39fb64841e4f3c8da3c87af2, e368feef51e0766f119c9710fb4db8f64724725c, and 52ead114bec961c62fa2eb0786540e229f6e4873
* fix: composer-default object in config?
* fix: schema changes for 9acdc6808c070555352951c651921df181b10993 and 093093420027999df3c67bf0ea6024f6dbf81d2d
* fix: schema changes for c0a52924f1f7ef8caeaacda67363ac269b56042c
* fix: schema change for aba420a3f3b774e949c2539c73f3dc0e1ae79a38, move loggedInUser to optional props
* fix: schema changes for 8c67031609da30d788561459f8bb76e9a69253de
* fix: schema changes for 27e53b42f3ce48fa61d3754375715cd41ffe808d
* fix: schema changes for 28359665187b0a3b9ec6226dca1234ebdbd725a5
* fix: breaking test for email confirmation API call
* fix: schema changes for refactored search page
* fix: schema changes for user object
* fix: schema changes for 9f531f957e08eabb4bae844ddd67bde14d9b59f0
* fix: schema changes for c4042c70decd628e5b880bd109515b47e4e16164 and 23175110a29640e6fa052db1079bfedb34a61055
* fix: schema changes for 9b3616b10392e247974eb0c1e6225a1582bf6c69
* fix: schema changes for 5afd5de07d42fd33f039a6f85ded3b4992200e5a
* fix: schema change for 1d7baf12171cffbd3af8914bef4e6297d1160d49
* fix: schema changes for 57bfb37c55a839662144e684875003ab52315ecc and be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 6e86b4afa20d662af8b9f1c07518df2d8c258105 and 3efad2e13b7319eb9a1f4fda7af047be43ebc11f and 68f66223e73a72f378f193c83a9b5546bede2cda
* fix: allowing optional qs prop in pagination keys (not sure why this didn't break before)
* fix: re-login on email change
* fix: schema changes for c926358d734a2fa410de87f4e4a91744215fc14a
* fix: schema changes for 388a8270c9882892bad5c8141f65da8d59eac0fd
* fix: schema change for 2658bcc821c22e137a6eeb9bb74098856a642eaf
* fix: no need to call account middlewares for chats routes
* fix: schema changes for 71743affc3e58dc85d4ffa15ce043d4d9ddd3d67
* fix: final schema changes
* test: support for anyOf and oneOf
* fix: check thumb
* dont scroll to top on back press
* remove group log
* fix: add top margin to merged and deleted alerts
* chore: up widgets
* fix: improve fix-lists mixin
* chore: up harmony/composer
* feat: allow hiding quicksearch results during search
* dont record searches made by composer
* chore: up 54
* chore: up spam be gone
* feat: add prev/next page and page count into mobile paginator
* chore: up harmony
* chore: up harmony
* use old style for IS
* fix: hide entire toolbar row if no posts or not singlePost
* fix: updated messaging for post-queue template, #11206
* fix: btn-sm on post queue back button
* fix: bump harmony, closes #11206
* fix: remove unused alert module import
* fix: bump harmony
* fix: bump harmony
* chore: up harmony
* refactor: IS scrolltop
* fix: update users:search-user-for-chat source string
* feat: support for mark-read toggle on chats dropdown and recent chats list
* feat: api v3 calls to mark chat read/unread
* feat: send event:chats.mark socket event on mark read or unread
* refactor: allow frontend to mark chats as unread, use new API v3 routes instead of socket calls, better frontend event handling
* docs: openapi schema updates for chat marking
* fix: allow unread state toggling in chats dropdown too
* fix: issue where repeated openings of the chats dropdown would continually add events for mark-read/unread
* fix: debug log
* refactor: move userSearch filter to a module
* feat(routes): allow remounting /categories (#11230)
* feat: send flags count to frontend on flags list page
* refactor: filter form client-side js to extract out some logic
* fix: applyFilters to not take any arguments, update selectedCids in updateButton instead of onHidden
* fix: use userFilter module for assignee, reporterId, targetUid
* fix(openapi): schema changes for updated flags page
* fix: dont allow adding duplicates to userFilter
* use same var
* remove log
* fix: closes #11282
* feat: lang key for x-topics
* chore: up harmony
* chore: up emoji
* chore: up harmony
* fix: update userFilter to allow new option `selectedBlock`
* fix: wrong block name passed to userFilter
* fix: https://github.com/NodeBB/NodeBB/issues/11283
* fix: chats, allow multiple dropdowns like in harmony
* chore: up harmony
* refactor: flag note adding/editing, closes #11285
* fix: remove old prepareEdit logic
* chore: add caveat about hacky code block in userFilter module
* fix: placeholders for userFilter module
* refactor: navigator so it works with multiple thumbs/navigators
* chore: up harmony
* fix: closes #11287, destroy quick reply autocomplete
on navigation
* fix: filter disabled categories on user categories page count
* chore: up harmony
* docs: update openapi spec to include info about passing in timestamps for topic creation, removing timestamp as valid request param for topic replying
* fix: send back null values on ACP search dashboard for startDate and endDate if not expicitly passed in, fix tests
* fix: tweak table order in ACP dash searches
* fix: only invoke navigator click drag on left mouse button
* feat: add back unread indicator to navigator
* clear bookmark on mark unread
* fix: navigator crash on ajaxify
* better thumb top calculation
* fix: reset user bookmark when topic is marked unread
* Revert "fix: reset user bookmark when topic is marked unread"
This reverts commit 9bcd85c2c6848c3d325d32027261809da6e11c9e.
* fix: update unread indicator on scroll, add unread count
* chore: bump harmony
* fix: crash on navigator unread update when backing out of a topic
* fix: closes #11183
* fix: update topics:recent zset when rescheduling a topic
* fix: dupe quote button, increase delay, hide immediately on empty selection
* fix: navigator not showing up on first load
* refactor: remove glance
assorted fixes to navigator
dont reduce remaning count if user scrolls down and up quickly
only call topic.navigatorCallback when index changes
* more sanity checks for bookmark
dont allow setting bookmark higher than topic postcount
* closes #11218, :train:
* Revert "fix: update topics:recent zset when rescheduling a topic"
This reverts commit 737973cca9e94b6cb3867492a09e1e0b1af391d5.
* fix: #11306, show proper error if queued post doesn't exist
was showing no-privileges if someone else accepted the post
* https://github.com/NodeBB/NodeBB/issues/11307
dont use li
* chore: up harmony
* chore: bump version string
* fix: copy paste fail
* feat: closes #7382, tag filtering
add client side support for filtering by tags on /category, /recent and /unread
* chore: up harmony
* chore: up harmony
* Revert "fix: add back req.query fallback for backwards compatibility" [breaking]
This reverts commit cf6cc2c454dc35c330393c62ee8ce67b42d8eefb.
This commit is no longer required as passing in a CSRF token via query parameter is no longer supported as of NodeBB v3.x
This is a breaking change.
* fix: pass csrf token in form data, re: NodeBB/NodeBB#11309
* chore: up deps
* fix: tests, use x-csrf-token query param removed
* test: fix csrf_token
* lint: remove unused
* feat: add itemprop="image" to avatar helper
* fix: get chat upload button in chat modal
* breaking: remove deprecated socket.io methods
* test: update messaging tests to not use sockets
* fix: parent post links
* fix: prevent post tooltip if mouse leaves before data/tpl is loaded
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up harmony
* fix: nested replies indices
* fix(deps): bump 2factor
* feat: add loggedIn user to all api routes
* chore: up themes
* refactor: audit admin v3 write api routes as per #11321
* refactor: audit category v3 write api routes as per #11321 [breaking]
docs: fix open api spec for #11321
* refactor: audit chat v3 write api routes as per #11321
* refactor: audit files v3 write api routes as per #11321
* refactor: audit flags v3 write api routes as per #11321
* refactor: audit posts v3 write api routes as per #11321
* refactor: audit topics v3 write api routes as per #11321
* refactor: audit users v3 write api routes as per #11321
* fix: lang string
* remove min height
* fix: empty topic/labels taking up space
* fix: tag filtering when changing filter to watched topics
or changing popular time limit to month
* chore: up harmony
* fix: closes #11354, show no post error if queued post already accepted/rejected
* test: #11354
* test: #11354
* fix(deps): bump 2factor
* fix: #11357 clear cache on thumb remove
* fix: thumb remove on windows, closes #11357
* test: openapi for thumbs
* test: fix openapi
---------
Co-authored-by: Julian Lam <julian@nodebb.org>
Co-authored-by: Opliko <opliko.reg@protonmail.com>
2023-03-17 11:58:31 -04:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
selectedTags: tagData,
|
|
|
|
|
selectedTag: selectedTag,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-02-07 15:09:52 -05:00
|
|
|
helpers.trimChildren = function (category) {
|
2022-06-20 16:40:24 -04:00
|
|
|
if (category && Array.isArray(category.children)) {
|
2021-02-07 15:09:52 -05:00
|
|
|
category.children = category.children.slice(0, category.subCategoriesPerPage);
|
2021-02-04 00:01:39 -07:00
|
|
|
category.children.forEach((child) => {
|
2022-06-20 16:40:24 -04:00
|
|
|
if (category.isSection) {
|
|
|
|
|
helpers.trimChildren(child);
|
|
|
|
|
} else {
|
|
|
|
|
child.children = undefined;
|
|
|
|
|
}
|
2021-02-07 15:09:52 -05:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
helpers.setCategoryTeaser = function (category) {
|
|
|
|
|
if (Array.isArray(category.posts) && category.posts.length && category.posts[0]) {
|
Bootstrap5 (#10894)
* chore: up deps
* chore: up composer
* fix(deps): bump 2factor to v7
* chore: up harmony
* chore: up harmony
* fix: missing await
* feat: allow middlewares to pass in template values via res.locals
* feat: buildAccountData middleware automatically added ot all account routes
* fix: properly allow values in res.locals.templateValues to be added to the template data
* refactor: user/blocks
* refactor(accounts): categories and consent
* feat: automatically 404 if exposeUid or exposeGroupName come up empty
* refactor: remove calls to getUserDataByUserSlug for most account routes, since it is populated via middleware now
* fix: allow exposeUid and exposeGroupName to work with slugs with mixed capitalization
* fix: move reputation removal check to accountHelpers method
* test: skip i18n tests if ref branch when present is not develop
* fix(deps): bump theme versions
* fix(deps): bump ntfy and 2factor
* chore: up harmony
* fix: add missing return
* fix: #11191, only focus on search input on md environments and up
* feat: allow file uploads on mobile chat
closes https://github.com/NodeBB/NodeBB/issues/11217
* chore: up themes
* chore: add lang string
* fix(deps): bump ntfy to 1.0.15
* refactor: use new if/each syntax
* chore: up composer
* fix: regression from user helper refactor
* chore: up harmony
* chore: up composer
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: fix composer version
* feat: add increment helper
* chore: up harmony
* fix: #11228 no timestamps in future :hourglass:
* chore: up harmony
* check config.theme as well
fire action:posts.loaded after processing dom
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up themes
* chore: up harmony
* remove extra class
* refactor: move these to core from harmony
* chore: up widgets
* chore: up widgets
* height auto
* fix: closes #11238
* dont focus inputs, annoying on mobile
* fix: dont focus twice, only focus on chat input on desktop
dont wrap widget footer in row
* chore: up harmony
* chore: up harmony
* update chat window
* chore: up themes
* fix cache buster for skins
* chat fixes
* chore: up harmony
* chore: up composer
* refactor: change hook logs to debug
* fix: scroll to post right after adding to dom
* fix: hash scrolling and highlighting correct post
* test: re-enable read API schema tests
* fix: add back schema changes for 179faa2270f2ad955dcc4a7b04755acce59e6ffd and c3920ccb10d8ead2dcd9914bb1784bed3f6adfd4
* fix: schema changes from 488f0978a4aa1ca1e4d2a1f2e8c7ef7a681f2f27
* fix: schema changes for f4cf482a874701ce80c0f306c49d8788cec66f87
* fix: schema update for be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 69c96078ea78ee2c45885a90a6f6a59f9042a33c
* fix: schema changes for d1364c313021e48a879a818b24947e1457c062f7
* fix: schema changes for 84ff1152f7552dd866e25a90972d970b9861107e
* fix: schema changes for b860c2605c209e0650ef98f4c80d842ea23a51ce
* fix: schema changes for 23cb67a1126481848fac39aafd1e253441e76d7f
* fix: schema changes for b916e42f400dac8aa51670b15e439f87f0eb8939
* fix: schema change for a9bbb586fcb3a1c61b5fb69052236e78cdf7d743
* fix: schema changes for 4b738c8cd36c936a1dbe2bb900c694bf6c5520ec
* fix: schema changes for 58b5781cea9acb129e6604a82ab5a5bfc0d8394d
* fix: schema changes for 794bf01b21709c4be06584d576d706b3d6342057
* fix: schema changes for 80ea12c1c1963f5b39fb64841e4f3c8da3c87af2, e368feef51e0766f119c9710fb4db8f64724725c, and 52ead114bec961c62fa2eb0786540e229f6e4873
* fix: composer-default object in config?
* fix: schema changes for 9acdc6808c070555352951c651921df181b10993 and 093093420027999df3c67bf0ea6024f6dbf81d2d
* fix: schema changes for c0a52924f1f7ef8caeaacda67363ac269b56042c
* fix: schema change for aba420a3f3b774e949c2539c73f3dc0e1ae79a38, move loggedInUser to optional props
* fix: schema changes for 8c67031609da30d788561459f8bb76e9a69253de
* fix: schema changes for 27e53b42f3ce48fa61d3754375715cd41ffe808d
* fix: schema changes for 28359665187b0a3b9ec6226dca1234ebdbd725a5
* fix: breaking test for email confirmation API call
* fix: schema changes for refactored search page
* fix: schema changes for user object
* fix: schema changes for 9f531f957e08eabb4bae844ddd67bde14d9b59f0
* fix: schema changes for c4042c70decd628e5b880bd109515b47e4e16164 and 23175110a29640e6fa052db1079bfedb34a61055
* fix: schema changes for 9b3616b10392e247974eb0c1e6225a1582bf6c69
* fix: schema changes for 5afd5de07d42fd33f039a6f85ded3b4992200e5a
* fix: schema change for 1d7baf12171cffbd3af8914bef4e6297d1160d49
* fix: schema changes for 57bfb37c55a839662144e684875003ab52315ecc and be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 6e86b4afa20d662af8b9f1c07518df2d8c258105 and 3efad2e13b7319eb9a1f4fda7af047be43ebc11f and 68f66223e73a72f378f193c83a9b5546bede2cda
* fix: allowing optional qs prop in pagination keys (not sure why this didn't break before)
* fix: re-login on email change
* fix: schema changes for c926358d734a2fa410de87f4e4a91744215fc14a
* fix: schema changes for 388a8270c9882892bad5c8141f65da8d59eac0fd
* fix: schema change for 2658bcc821c22e137a6eeb9bb74098856a642eaf
* fix: no need to call account middlewares for chats routes
* fix: schema changes for 71743affc3e58dc85d4ffa15ce043d4d9ddd3d67
* fix: final schema changes
* test: support for anyOf and oneOf
* fix: check thumb
* dont scroll to top on back press
* remove group log
* fix: add top margin to merged and deleted alerts
* chore: up widgets
* fix: improve fix-lists mixin
* chore: up harmony/composer
* feat: allow hiding quicksearch results during search
* dont record searches made by composer
* chore: up 54
* chore: up spam be gone
* feat: add prev/next page and page count into mobile paginator
* chore: up harmony
* chore: up harmony
* use old style for IS
* fix: hide entire toolbar row if no posts or not singlePost
* fix: updated messaging for post-queue template, #11206
* fix: btn-sm on post queue back button
* fix: bump harmony, closes #11206
* fix: remove unused alert module import
* fix: bump harmony
* fix: bump harmony
* chore: up harmony
* refactor: IS scrolltop
* fix: update users:search-user-for-chat source string
* feat: support for mark-read toggle on chats dropdown and recent chats list
* feat: api v3 calls to mark chat read/unread
* feat: send event:chats.mark socket event on mark read or unread
* refactor: allow frontend to mark chats as unread, use new API v3 routes instead of socket calls, better frontend event handling
* docs: openapi schema updates for chat marking
* fix: allow unread state toggling in chats dropdown too
* fix: issue where repeated openings of the chats dropdown would continually add events for mark-read/unread
* fix: debug log
* refactor: move userSearch filter to a module
* feat(routes): allow remounting /categories (#11230)
* feat: send flags count to frontend on flags list page
* refactor: filter form client-side js to extract out some logic
* fix: applyFilters to not take any arguments, update selectedCids in updateButton instead of onHidden
* fix: use userFilter module for assignee, reporterId, targetUid
* fix(openapi): schema changes for updated flags page
* fix: dont allow adding duplicates to userFilter
* use same var
* remove log
* fix: closes #11282
* feat: lang key for x-topics
* chore: up harmony
* chore: up emoji
* chore: up harmony
* fix: update userFilter to allow new option `selectedBlock`
* fix: wrong block name passed to userFilter
* fix: https://github.com/NodeBB/NodeBB/issues/11283
* fix: chats, allow multiple dropdowns like in harmony
* chore: up harmony
* refactor: flag note adding/editing, closes #11285
* fix: remove old prepareEdit logic
* chore: add caveat about hacky code block in userFilter module
* fix: placeholders for userFilter module
* refactor: navigator so it works with multiple thumbs/navigators
* chore: up harmony
* fix: closes #11287, destroy quick reply autocomplete
on navigation
* fix: filter disabled categories on user categories page count
* chore: up harmony
* docs: update openapi spec to include info about passing in timestamps for topic creation, removing timestamp as valid request param for topic replying
* fix: send back null values on ACP search dashboard for startDate and endDate if not expicitly passed in, fix tests
* fix: tweak table order in ACP dash searches
* fix: only invoke navigator click drag on left mouse button
* feat: add back unread indicator to navigator
* clear bookmark on mark unread
* fix: navigator crash on ajaxify
* better thumb top calculation
* fix: reset user bookmark when topic is marked unread
* Revert "fix: reset user bookmark when topic is marked unread"
This reverts commit 9bcd85c2c6848c3d325d32027261809da6e11c9e.
* fix: update unread indicator on scroll, add unread count
* chore: bump harmony
* fix: crash on navigator unread update when backing out of a topic
* fix: closes #11183
* fix: update topics:recent zset when rescheduling a topic
* fix: dupe quote button, increase delay, hide immediately on empty selection
* fix: navigator not showing up on first load
* refactor: remove glance
assorted fixes to navigator
dont reduce remaning count if user scrolls down and up quickly
only call topic.navigatorCallback when index changes
* more sanity checks for bookmark
dont allow setting bookmark higher than topic postcount
* closes #11218, :train:
* Revert "fix: update topics:recent zset when rescheduling a topic"
This reverts commit 737973cca9e94b6cb3867492a09e1e0b1af391d5.
* fix: #11306, show proper error if queued post doesn't exist
was showing no-privileges if someone else accepted the post
* https://github.com/NodeBB/NodeBB/issues/11307
dont use li
* chore: up harmony
* chore: bump version string
* fix: copy paste fail
* feat: closes #7382, tag filtering
add client side support for filtering by tags on /category, /recent and /unread
* chore: up harmony
* chore: up harmony
* Revert "fix: add back req.query fallback for backwards compatibility" [breaking]
This reverts commit cf6cc2c454dc35c330393c62ee8ce67b42d8eefb.
This commit is no longer required as passing in a CSRF token via query parameter is no longer supported as of NodeBB v3.x
This is a breaking change.
* fix: pass csrf token in form data, re: NodeBB/NodeBB#11309
* chore: up deps
* fix: tests, use x-csrf-token query param removed
* test: fix csrf_token
* lint: remove unused
* feat: add itemprop="image" to avatar helper
* fix: get chat upload button in chat modal
* breaking: remove deprecated socket.io methods
* test: update messaging tests to not use sockets
* fix: parent post links
* fix: prevent post tooltip if mouse leaves before data/tpl is loaded
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up harmony
* fix: nested replies indices
* fix(deps): bump 2factor
* feat: add loggedIn user to all api routes
* chore: up themes
* refactor: audit admin v3 write api routes as per #11321
* refactor: audit category v3 write api routes as per #11321 [breaking]
docs: fix open api spec for #11321
* refactor: audit chat v3 write api routes as per #11321
* refactor: audit files v3 write api routes as per #11321
* refactor: audit flags v3 write api routes as per #11321
* refactor: audit posts v3 write api routes as per #11321
* refactor: audit topics v3 write api routes as per #11321
* refactor: audit users v3 write api routes as per #11321
* fix: lang string
* remove min height
* fix: empty topic/labels taking up space
* fix: tag filtering when changing filter to watched topics
or changing popular time limit to month
* chore: up harmony
* fix: closes #11354, show no post error if queued post already accepted/rejected
* test: #11354
* test: #11354
* fix(deps): bump 2factor
* fix: #11357 clear cache on thumb remove
* fix: thumb remove on windows, closes #11357
* test: openapi for thumbs
* test: fix openapi
---------
Co-authored-by: Julian Lam <julian@nodebb.org>
Co-authored-by: Opliko <opliko.reg@protonmail.com>
2023-03-17 11:58:31 -04:00
|
|
|
const post = category.posts[0];
|
2021-02-07 15:09:52 -05:00
|
|
|
category.teaser = {
|
2026-02-16 08:48:21 -05:00
|
|
|
url: `${nconf.get('relative_path')}/post/${encodeURIComponent(post.pid)}`,
|
Bootstrap5 (#10894)
* chore: up deps
* chore: up composer
* fix(deps): bump 2factor to v7
* chore: up harmony
* chore: up harmony
* fix: missing await
* feat: allow middlewares to pass in template values via res.locals
* feat: buildAccountData middleware automatically added ot all account routes
* fix: properly allow values in res.locals.templateValues to be added to the template data
* refactor: user/blocks
* refactor(accounts): categories and consent
* feat: automatically 404 if exposeUid or exposeGroupName come up empty
* refactor: remove calls to getUserDataByUserSlug for most account routes, since it is populated via middleware now
* fix: allow exposeUid and exposeGroupName to work with slugs with mixed capitalization
* fix: move reputation removal check to accountHelpers method
* test: skip i18n tests if ref branch when present is not develop
* fix(deps): bump theme versions
* fix(deps): bump ntfy and 2factor
* chore: up harmony
* fix: add missing return
* fix: #11191, only focus on search input on md environments and up
* feat: allow file uploads on mobile chat
closes https://github.com/NodeBB/NodeBB/issues/11217
* chore: up themes
* chore: add lang string
* fix(deps): bump ntfy to 1.0.15
* refactor: use new if/each syntax
* chore: up composer
* fix: regression from user helper refactor
* chore: up harmony
* chore: up composer
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: fix composer version
* feat: add increment helper
* chore: up harmony
* fix: #11228 no timestamps in future :hourglass:
* chore: up harmony
* check config.theme as well
fire action:posts.loaded after processing dom
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up themes
* chore: up harmony
* remove extra class
* refactor: move these to core from harmony
* chore: up widgets
* chore: up widgets
* height auto
* fix: closes #11238
* dont focus inputs, annoying on mobile
* fix: dont focus twice, only focus on chat input on desktop
dont wrap widget footer in row
* chore: up harmony
* chore: up harmony
* update chat window
* chore: up themes
* fix cache buster for skins
* chat fixes
* chore: up harmony
* chore: up composer
* refactor: change hook logs to debug
* fix: scroll to post right after adding to dom
* fix: hash scrolling and highlighting correct post
* test: re-enable read API schema tests
* fix: add back schema changes for 179faa2270f2ad955dcc4a7b04755acce59e6ffd and c3920ccb10d8ead2dcd9914bb1784bed3f6adfd4
* fix: schema changes from 488f0978a4aa1ca1e4d2a1f2e8c7ef7a681f2f27
* fix: schema changes for f4cf482a874701ce80c0f306c49d8788cec66f87
* fix: schema update for be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 69c96078ea78ee2c45885a90a6f6a59f9042a33c
* fix: schema changes for d1364c313021e48a879a818b24947e1457c062f7
* fix: schema changes for 84ff1152f7552dd866e25a90972d970b9861107e
* fix: schema changes for b860c2605c209e0650ef98f4c80d842ea23a51ce
* fix: schema changes for 23cb67a1126481848fac39aafd1e253441e76d7f
* fix: schema changes for b916e42f400dac8aa51670b15e439f87f0eb8939
* fix: schema change for a9bbb586fcb3a1c61b5fb69052236e78cdf7d743
* fix: schema changes for 4b738c8cd36c936a1dbe2bb900c694bf6c5520ec
* fix: schema changes for 58b5781cea9acb129e6604a82ab5a5bfc0d8394d
* fix: schema changes for 794bf01b21709c4be06584d576d706b3d6342057
* fix: schema changes for 80ea12c1c1963f5b39fb64841e4f3c8da3c87af2, e368feef51e0766f119c9710fb4db8f64724725c, and 52ead114bec961c62fa2eb0786540e229f6e4873
* fix: composer-default object in config?
* fix: schema changes for 9acdc6808c070555352951c651921df181b10993 and 093093420027999df3c67bf0ea6024f6dbf81d2d
* fix: schema changes for c0a52924f1f7ef8caeaacda67363ac269b56042c
* fix: schema change for aba420a3f3b774e949c2539c73f3dc0e1ae79a38, move loggedInUser to optional props
* fix: schema changes for 8c67031609da30d788561459f8bb76e9a69253de
* fix: schema changes for 27e53b42f3ce48fa61d3754375715cd41ffe808d
* fix: schema changes for 28359665187b0a3b9ec6226dca1234ebdbd725a5
* fix: breaking test for email confirmation API call
* fix: schema changes for refactored search page
* fix: schema changes for user object
* fix: schema changes for 9f531f957e08eabb4bae844ddd67bde14d9b59f0
* fix: schema changes for c4042c70decd628e5b880bd109515b47e4e16164 and 23175110a29640e6fa052db1079bfedb34a61055
* fix: schema changes for 9b3616b10392e247974eb0c1e6225a1582bf6c69
* fix: schema changes for 5afd5de07d42fd33f039a6f85ded3b4992200e5a
* fix: schema change for 1d7baf12171cffbd3af8914bef4e6297d1160d49
* fix: schema changes for 57bfb37c55a839662144e684875003ab52315ecc and be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 6e86b4afa20d662af8b9f1c07518df2d8c258105 and 3efad2e13b7319eb9a1f4fda7af047be43ebc11f and 68f66223e73a72f378f193c83a9b5546bede2cda
* fix: allowing optional qs prop in pagination keys (not sure why this didn't break before)
* fix: re-login on email change
* fix: schema changes for c926358d734a2fa410de87f4e4a91744215fc14a
* fix: schema changes for 388a8270c9882892bad5c8141f65da8d59eac0fd
* fix: schema change for 2658bcc821c22e137a6eeb9bb74098856a642eaf
* fix: no need to call account middlewares for chats routes
* fix: schema changes for 71743affc3e58dc85d4ffa15ce043d4d9ddd3d67
* fix: final schema changes
* test: support for anyOf and oneOf
* fix: check thumb
* dont scroll to top on back press
* remove group log
* fix: add top margin to merged and deleted alerts
* chore: up widgets
* fix: improve fix-lists mixin
* chore: up harmony/composer
* feat: allow hiding quicksearch results during search
* dont record searches made by composer
* chore: up 54
* chore: up spam be gone
* feat: add prev/next page and page count into mobile paginator
* chore: up harmony
* chore: up harmony
* use old style for IS
* fix: hide entire toolbar row if no posts or not singlePost
* fix: updated messaging for post-queue template, #11206
* fix: btn-sm on post queue back button
* fix: bump harmony, closes #11206
* fix: remove unused alert module import
* fix: bump harmony
* fix: bump harmony
* chore: up harmony
* refactor: IS scrolltop
* fix: update users:search-user-for-chat source string
* feat: support for mark-read toggle on chats dropdown and recent chats list
* feat: api v3 calls to mark chat read/unread
* feat: send event:chats.mark socket event on mark read or unread
* refactor: allow frontend to mark chats as unread, use new API v3 routes instead of socket calls, better frontend event handling
* docs: openapi schema updates for chat marking
* fix: allow unread state toggling in chats dropdown too
* fix: issue where repeated openings of the chats dropdown would continually add events for mark-read/unread
* fix: debug log
* refactor: move userSearch filter to a module
* feat(routes): allow remounting /categories (#11230)
* feat: send flags count to frontend on flags list page
* refactor: filter form client-side js to extract out some logic
* fix: applyFilters to not take any arguments, update selectedCids in updateButton instead of onHidden
* fix: use userFilter module for assignee, reporterId, targetUid
* fix(openapi): schema changes for updated flags page
* fix: dont allow adding duplicates to userFilter
* use same var
* remove log
* fix: closes #11282
* feat: lang key for x-topics
* chore: up harmony
* chore: up emoji
* chore: up harmony
* fix: update userFilter to allow new option `selectedBlock`
* fix: wrong block name passed to userFilter
* fix: https://github.com/NodeBB/NodeBB/issues/11283
* fix: chats, allow multiple dropdowns like in harmony
* chore: up harmony
* refactor: flag note adding/editing, closes #11285
* fix: remove old prepareEdit logic
* chore: add caveat about hacky code block in userFilter module
* fix: placeholders for userFilter module
* refactor: navigator so it works with multiple thumbs/navigators
* chore: up harmony
* fix: closes #11287, destroy quick reply autocomplete
on navigation
* fix: filter disabled categories on user categories page count
* chore: up harmony
* docs: update openapi spec to include info about passing in timestamps for topic creation, removing timestamp as valid request param for topic replying
* fix: send back null values on ACP search dashboard for startDate and endDate if not expicitly passed in, fix tests
* fix: tweak table order in ACP dash searches
* fix: only invoke navigator click drag on left mouse button
* feat: add back unread indicator to navigator
* clear bookmark on mark unread
* fix: navigator crash on ajaxify
* better thumb top calculation
* fix: reset user bookmark when topic is marked unread
* Revert "fix: reset user bookmark when topic is marked unread"
This reverts commit 9bcd85c2c6848c3d325d32027261809da6e11c9e.
* fix: update unread indicator on scroll, add unread count
* chore: bump harmony
* fix: crash on navigator unread update when backing out of a topic
* fix: closes #11183
* fix: update topics:recent zset when rescheduling a topic
* fix: dupe quote button, increase delay, hide immediately on empty selection
* fix: navigator not showing up on first load
* refactor: remove glance
assorted fixes to navigator
dont reduce remaning count if user scrolls down and up quickly
only call topic.navigatorCallback when index changes
* more sanity checks for bookmark
dont allow setting bookmark higher than topic postcount
* closes #11218, :train:
* Revert "fix: update topics:recent zset when rescheduling a topic"
This reverts commit 737973cca9e94b6cb3867492a09e1e0b1af391d5.
* fix: #11306, show proper error if queued post doesn't exist
was showing no-privileges if someone else accepted the post
* https://github.com/NodeBB/NodeBB/issues/11307
dont use li
* chore: up harmony
* chore: bump version string
* fix: copy paste fail
* feat: closes #7382, tag filtering
add client side support for filtering by tags on /category, /recent and /unread
* chore: up harmony
* chore: up harmony
* Revert "fix: add back req.query fallback for backwards compatibility" [breaking]
This reverts commit cf6cc2c454dc35c330393c62ee8ce67b42d8eefb.
This commit is no longer required as passing in a CSRF token via query parameter is no longer supported as of NodeBB v3.x
This is a breaking change.
* fix: pass csrf token in form data, re: NodeBB/NodeBB#11309
* chore: up deps
* fix: tests, use x-csrf-token query param removed
* test: fix csrf_token
* lint: remove unused
* feat: add itemprop="image" to avatar helper
* fix: get chat upload button in chat modal
* breaking: remove deprecated socket.io methods
* test: update messaging tests to not use sockets
* fix: parent post links
* fix: prevent post tooltip if mouse leaves before data/tpl is loaded
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up harmony
* fix: nested replies indices
* fix(deps): bump 2factor
* feat: add loggedIn user to all api routes
* chore: up themes
* refactor: audit admin v3 write api routes as per #11321
* refactor: audit category v3 write api routes as per #11321 [breaking]
docs: fix open api spec for #11321
* refactor: audit chat v3 write api routes as per #11321
* refactor: audit files v3 write api routes as per #11321
* refactor: audit flags v3 write api routes as per #11321
* refactor: audit posts v3 write api routes as per #11321
* refactor: audit topics v3 write api routes as per #11321
* refactor: audit users v3 write api routes as per #11321
* fix: lang string
* remove min height
* fix: empty topic/labels taking up space
* fix: tag filtering when changing filter to watched topics
or changing popular time limit to month
* chore: up harmony
* fix: closes #11354, show no post error if queued post already accepted/rejected
* test: #11354
* test: #11354
* fix(deps): bump 2factor
* fix: #11357 clear cache on thumb remove
* fix: thumb remove on windows, closes #11357
* test: openapi for thumbs
* test: fix openapi
---------
Co-authored-by: Julian Lam <julian@nodebb.org>
Co-authored-by: Opliko <opliko.reg@protonmail.com>
2023-03-17 11:58:31 -04:00
|
|
|
timestampISO: post.timestampISO,
|
|
|
|
|
pid: post.pid,
|
2024-04-12 11:44:00 -04:00
|
|
|
tid: post.tid,
|
Bootstrap5 (#10894)
* chore: up deps
* chore: up composer
* fix(deps): bump 2factor to v7
* chore: up harmony
* chore: up harmony
* fix: missing await
* feat: allow middlewares to pass in template values via res.locals
* feat: buildAccountData middleware automatically added ot all account routes
* fix: properly allow values in res.locals.templateValues to be added to the template data
* refactor: user/blocks
* refactor(accounts): categories and consent
* feat: automatically 404 if exposeUid or exposeGroupName come up empty
* refactor: remove calls to getUserDataByUserSlug for most account routes, since it is populated via middleware now
* fix: allow exposeUid and exposeGroupName to work with slugs with mixed capitalization
* fix: move reputation removal check to accountHelpers method
* test: skip i18n tests if ref branch when present is not develop
* fix(deps): bump theme versions
* fix(deps): bump ntfy and 2factor
* chore: up harmony
* fix: add missing return
* fix: #11191, only focus on search input on md environments and up
* feat: allow file uploads on mobile chat
closes https://github.com/NodeBB/NodeBB/issues/11217
* chore: up themes
* chore: add lang string
* fix(deps): bump ntfy to 1.0.15
* refactor: use new if/each syntax
* chore: up composer
* fix: regression from user helper refactor
* chore: up harmony
* chore: up composer
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: fix composer version
* feat: add increment helper
* chore: up harmony
* fix: #11228 no timestamps in future :hourglass:
* chore: up harmony
* check config.theme as well
fire action:posts.loaded after processing dom
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up themes
* chore: up harmony
* remove extra class
* refactor: move these to core from harmony
* chore: up widgets
* chore: up widgets
* height auto
* fix: closes #11238
* dont focus inputs, annoying on mobile
* fix: dont focus twice, only focus on chat input on desktop
dont wrap widget footer in row
* chore: up harmony
* chore: up harmony
* update chat window
* chore: up themes
* fix cache buster for skins
* chat fixes
* chore: up harmony
* chore: up composer
* refactor: change hook logs to debug
* fix: scroll to post right after adding to dom
* fix: hash scrolling and highlighting correct post
* test: re-enable read API schema tests
* fix: add back schema changes for 179faa2270f2ad955dcc4a7b04755acce59e6ffd and c3920ccb10d8ead2dcd9914bb1784bed3f6adfd4
* fix: schema changes from 488f0978a4aa1ca1e4d2a1f2e8c7ef7a681f2f27
* fix: schema changes for f4cf482a874701ce80c0f306c49d8788cec66f87
* fix: schema update for be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 69c96078ea78ee2c45885a90a6f6a59f9042a33c
* fix: schema changes for d1364c313021e48a879a818b24947e1457c062f7
* fix: schema changes for 84ff1152f7552dd866e25a90972d970b9861107e
* fix: schema changes for b860c2605c209e0650ef98f4c80d842ea23a51ce
* fix: schema changes for 23cb67a1126481848fac39aafd1e253441e76d7f
* fix: schema changes for b916e42f400dac8aa51670b15e439f87f0eb8939
* fix: schema change for a9bbb586fcb3a1c61b5fb69052236e78cdf7d743
* fix: schema changes for 4b738c8cd36c936a1dbe2bb900c694bf6c5520ec
* fix: schema changes for 58b5781cea9acb129e6604a82ab5a5bfc0d8394d
* fix: schema changes for 794bf01b21709c4be06584d576d706b3d6342057
* fix: schema changes for 80ea12c1c1963f5b39fb64841e4f3c8da3c87af2, e368feef51e0766f119c9710fb4db8f64724725c, and 52ead114bec961c62fa2eb0786540e229f6e4873
* fix: composer-default object in config?
* fix: schema changes for 9acdc6808c070555352951c651921df181b10993 and 093093420027999df3c67bf0ea6024f6dbf81d2d
* fix: schema changes for c0a52924f1f7ef8caeaacda67363ac269b56042c
* fix: schema change for aba420a3f3b774e949c2539c73f3dc0e1ae79a38, move loggedInUser to optional props
* fix: schema changes for 8c67031609da30d788561459f8bb76e9a69253de
* fix: schema changes for 27e53b42f3ce48fa61d3754375715cd41ffe808d
* fix: schema changes for 28359665187b0a3b9ec6226dca1234ebdbd725a5
* fix: breaking test for email confirmation API call
* fix: schema changes for refactored search page
* fix: schema changes for user object
* fix: schema changes for 9f531f957e08eabb4bae844ddd67bde14d9b59f0
* fix: schema changes for c4042c70decd628e5b880bd109515b47e4e16164 and 23175110a29640e6fa052db1079bfedb34a61055
* fix: schema changes for 9b3616b10392e247974eb0c1e6225a1582bf6c69
* fix: schema changes for 5afd5de07d42fd33f039a6f85ded3b4992200e5a
* fix: schema change for 1d7baf12171cffbd3af8914bef4e6297d1160d49
* fix: schema changes for 57bfb37c55a839662144e684875003ab52315ecc and be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 6e86b4afa20d662af8b9f1c07518df2d8c258105 and 3efad2e13b7319eb9a1f4fda7af047be43ebc11f and 68f66223e73a72f378f193c83a9b5546bede2cda
* fix: allowing optional qs prop in pagination keys (not sure why this didn't break before)
* fix: re-login on email change
* fix: schema changes for c926358d734a2fa410de87f4e4a91744215fc14a
* fix: schema changes for 388a8270c9882892bad5c8141f65da8d59eac0fd
* fix: schema change for 2658bcc821c22e137a6eeb9bb74098856a642eaf
* fix: no need to call account middlewares for chats routes
* fix: schema changes for 71743affc3e58dc85d4ffa15ce043d4d9ddd3d67
* fix: final schema changes
* test: support for anyOf and oneOf
* fix: check thumb
* dont scroll to top on back press
* remove group log
* fix: add top margin to merged and deleted alerts
* chore: up widgets
* fix: improve fix-lists mixin
* chore: up harmony/composer
* feat: allow hiding quicksearch results during search
* dont record searches made by composer
* chore: up 54
* chore: up spam be gone
* feat: add prev/next page and page count into mobile paginator
* chore: up harmony
* chore: up harmony
* use old style for IS
* fix: hide entire toolbar row if no posts or not singlePost
* fix: updated messaging for post-queue template, #11206
* fix: btn-sm on post queue back button
* fix: bump harmony, closes #11206
* fix: remove unused alert module import
* fix: bump harmony
* fix: bump harmony
* chore: up harmony
* refactor: IS scrolltop
* fix: update users:search-user-for-chat source string
* feat: support for mark-read toggle on chats dropdown and recent chats list
* feat: api v3 calls to mark chat read/unread
* feat: send event:chats.mark socket event on mark read or unread
* refactor: allow frontend to mark chats as unread, use new API v3 routes instead of socket calls, better frontend event handling
* docs: openapi schema updates for chat marking
* fix: allow unread state toggling in chats dropdown too
* fix: issue where repeated openings of the chats dropdown would continually add events for mark-read/unread
* fix: debug log
* refactor: move userSearch filter to a module
* feat(routes): allow remounting /categories (#11230)
* feat: send flags count to frontend on flags list page
* refactor: filter form client-side js to extract out some logic
* fix: applyFilters to not take any arguments, update selectedCids in updateButton instead of onHidden
* fix: use userFilter module for assignee, reporterId, targetUid
* fix(openapi): schema changes for updated flags page
* fix: dont allow adding duplicates to userFilter
* use same var
* remove log
* fix: closes #11282
* feat: lang key for x-topics
* chore: up harmony
* chore: up emoji
* chore: up harmony
* fix: update userFilter to allow new option `selectedBlock`
* fix: wrong block name passed to userFilter
* fix: https://github.com/NodeBB/NodeBB/issues/11283
* fix: chats, allow multiple dropdowns like in harmony
* chore: up harmony
* refactor: flag note adding/editing, closes #11285
* fix: remove old prepareEdit logic
* chore: add caveat about hacky code block in userFilter module
* fix: placeholders for userFilter module
* refactor: navigator so it works with multiple thumbs/navigators
* chore: up harmony
* fix: closes #11287, destroy quick reply autocomplete
on navigation
* fix: filter disabled categories on user categories page count
* chore: up harmony
* docs: update openapi spec to include info about passing in timestamps for topic creation, removing timestamp as valid request param for topic replying
* fix: send back null values on ACP search dashboard for startDate and endDate if not expicitly passed in, fix tests
* fix: tweak table order in ACP dash searches
* fix: only invoke navigator click drag on left mouse button
* feat: add back unread indicator to navigator
* clear bookmark on mark unread
* fix: navigator crash on ajaxify
* better thumb top calculation
* fix: reset user bookmark when topic is marked unread
* Revert "fix: reset user bookmark when topic is marked unread"
This reverts commit 9bcd85c2c6848c3d325d32027261809da6e11c9e.
* fix: update unread indicator on scroll, add unread count
* chore: bump harmony
* fix: crash on navigator unread update when backing out of a topic
* fix: closes #11183
* fix: update topics:recent zset when rescheduling a topic
* fix: dupe quote button, increase delay, hide immediately on empty selection
* fix: navigator not showing up on first load
* refactor: remove glance
assorted fixes to navigator
dont reduce remaning count if user scrolls down and up quickly
only call topic.navigatorCallback when index changes
* more sanity checks for bookmark
dont allow setting bookmark higher than topic postcount
* closes #11218, :train:
* Revert "fix: update topics:recent zset when rescheduling a topic"
This reverts commit 737973cca9e94b6cb3867492a09e1e0b1af391d5.
* fix: #11306, show proper error if queued post doesn't exist
was showing no-privileges if someone else accepted the post
* https://github.com/NodeBB/NodeBB/issues/11307
dont use li
* chore: up harmony
* chore: bump version string
* fix: copy paste fail
* feat: closes #7382, tag filtering
add client side support for filtering by tags on /category, /recent and /unread
* chore: up harmony
* chore: up harmony
* Revert "fix: add back req.query fallback for backwards compatibility" [breaking]
This reverts commit cf6cc2c454dc35c330393c62ee8ce67b42d8eefb.
This commit is no longer required as passing in a CSRF token via query parameter is no longer supported as of NodeBB v3.x
This is a breaking change.
* fix: pass csrf token in form data, re: NodeBB/NodeBB#11309
* chore: up deps
* fix: tests, use x-csrf-token query param removed
* test: fix csrf_token
* lint: remove unused
* feat: add itemprop="image" to avatar helper
* fix: get chat upload button in chat modal
* breaking: remove deprecated socket.io methods
* test: update messaging tests to not use sockets
* fix: parent post links
* fix: prevent post tooltip if mouse leaves before data/tpl is loaded
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up harmony
* fix: nested replies indices
* fix(deps): bump 2factor
* feat: add loggedIn user to all api routes
* chore: up themes
* refactor: audit admin v3 write api routes as per #11321
* refactor: audit category v3 write api routes as per #11321 [breaking]
docs: fix open api spec for #11321
* refactor: audit chat v3 write api routes as per #11321
* refactor: audit files v3 write api routes as per #11321
* refactor: audit flags v3 write api routes as per #11321
* refactor: audit posts v3 write api routes as per #11321
* refactor: audit topics v3 write api routes as per #11321
* refactor: audit users v3 write api routes as per #11321
* fix: lang string
* remove min height
* fix: empty topic/labels taking up space
* fix: tag filtering when changing filter to watched topics
or changing popular time limit to month
* chore: up harmony
* fix: closes #11354, show no post error if queued post already accepted/rejected
* test: #11354
* test: #11354
* fix(deps): bump 2factor
* fix: #11357 clear cache on thumb remove
* fix: thumb remove on windows, closes #11357
* test: openapi for thumbs
* test: fix openapi
---------
Co-authored-by: Julian Lam <julian@nodebb.org>
Co-authored-by: Opliko <opliko.reg@protonmail.com>
2023-03-17 11:58:31 -04:00
|
|
|
index: post.index,
|
|
|
|
|
topic: post.topic,
|
|
|
|
|
user: post.user,
|
2021-02-07 15:09:52 -05:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2019-10-30 12:47:01 -04:00
|
|
|
function checkVisibleChildren(c, cidToAllowed, cidToWatchState, states) {
|
|
|
|
|
if (!c || !Array.isArray(c.children)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2021-02-07 15:09:52 -05:00
|
|
|
return c.children.some(c => !c.disabled && (
|
2021-02-04 02:07:29 -07:00
|
|
|
(cidToAllowed[c.cid] && states.includes(cidToWatchState[c.cid])) ||
|
|
|
|
|
checkVisibleChildren(c, cidToAllowed, cidToWatchState, states)
|
2019-10-30 12:47:01 -04:00
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-14 16:27:58 -04:00
|
|
|
helpers.getHomePageRoutes = async function (uid) {
|
|
|
|
|
const routes = [
|
|
|
|
|
{
|
|
|
|
|
route: 'categories',
|
|
|
|
|
name: 'Categories',
|
|
|
|
|
},
|
2026-03-18 10:28:54 -04:00
|
|
|
{
|
|
|
|
|
route: 'world',
|
|
|
|
|
name: 'World',
|
|
|
|
|
},
|
2019-08-14 16:27:58 -04:00
|
|
|
{
|
|
|
|
|
route: 'unread',
|
|
|
|
|
name: 'Unread',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
route: 'recent',
|
|
|
|
|
name: 'Recent',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
route: 'top',
|
|
|
|
|
name: 'Top',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
route: 'popular',
|
|
|
|
|
name: 'Popular',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
route: 'custom',
|
|
|
|
|
name: 'Custom',
|
|
|
|
|
},
|
2021-02-07 15:09:52 -05:00
|
|
|
];
|
|
|
|
|
const data = await plugins.hooks.fire('filter:homepage.get', {
|
|
|
|
|
uid: uid,
|
|
|
|
|
routes: routes,
|
|
|
|
|
});
|
2019-08-14 16:27:58 -04:00
|
|
|
return data.routes;
|
|
|
|
|
};
|
|
|
|
|
|
2020-03-26 20:25:23 -04:00
|
|
|
helpers.formatApiResponse = async (statusCode, res, payload) => {
|
2020-11-06 11:55:04 -05:00
|
|
|
if (res.req.method === 'HEAD') {
|
|
|
|
|
return res.sendStatus(statusCode);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-16 10:34:37 -04:00
|
|
|
if (String(statusCode).startsWith('2')) {
|
2022-03-18 11:56:16 -04:00
|
|
|
if (res.req.loggedIn) {
|
|
|
|
|
res.set('cache-control', 'private');
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-22 15:46:34 -04:00
|
|
|
let code = 'ok';
|
|
|
|
|
let message = 'OK';
|
|
|
|
|
switch (statusCode) {
|
|
|
|
|
case 202:
|
|
|
|
|
code = 'accepted';
|
|
|
|
|
message = 'Accepted';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 204:
|
|
|
|
|
code = 'no-content';
|
|
|
|
|
message = 'No Content';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-16 10:34:37 -04:00
|
|
|
res.status(statusCode).json({
|
2022-08-22 15:46:34 -04:00
|
|
|
status: { code, message },
|
2020-03-26 20:25:23 -04:00
|
|
|
response: payload || {},
|
|
|
|
|
});
|
2023-08-19 16:40:43 -04:00
|
|
|
} else if (payload instanceof Error || typeof payload === 'string') {
|
|
|
|
|
const message = payload instanceof Error ? payload.message : payload;
|
2020-11-24 10:26:09 -05:00
|
|
|
const response = {};
|
2020-03-31 17:06:13 -04:00
|
|
|
|
2020-10-15 20:23:19 -04:00
|
|
|
// Update status code based on some common error codes
|
2022-05-03 11:14:10 -04:00
|
|
|
switch (message) {
|
2020-11-24 13:28:05 -05:00
|
|
|
case '[[error:user-banned]]':
|
|
|
|
|
Object.assign(response, await generateBannedResponse(res));
|
|
|
|
|
// intentional fall through
|
2020-11-24 10:26:09 -05:00
|
|
|
|
2020-10-15 20:23:19 -04:00
|
|
|
case '[[error:no-privileges]]':
|
|
|
|
|
statusCode = 403;
|
|
|
|
|
break;
|
2020-10-16 09:21:26 -04:00
|
|
|
|
|
|
|
|
case '[[error:invalid-uid]]':
|
|
|
|
|
statusCode = 401;
|
|
|
|
|
break;
|
Bootstrap5 (#10894)
* chore: up deps
* chore: up composer
* fix(deps): bump 2factor to v7
* chore: up harmony
* chore: up harmony
* fix: missing await
* feat: allow middlewares to pass in template values via res.locals
* feat: buildAccountData middleware automatically added ot all account routes
* fix: properly allow values in res.locals.templateValues to be added to the template data
* refactor: user/blocks
* refactor(accounts): categories and consent
* feat: automatically 404 if exposeUid or exposeGroupName come up empty
* refactor: remove calls to getUserDataByUserSlug for most account routes, since it is populated via middleware now
* fix: allow exposeUid and exposeGroupName to work with slugs with mixed capitalization
* fix: move reputation removal check to accountHelpers method
* test: skip i18n tests if ref branch when present is not develop
* fix(deps): bump theme versions
* fix(deps): bump ntfy and 2factor
* chore: up harmony
* fix: add missing return
* fix: #11191, only focus on search input on md environments and up
* feat: allow file uploads on mobile chat
closes https://github.com/NodeBB/NodeBB/issues/11217
* chore: up themes
* chore: add lang string
* fix(deps): bump ntfy to 1.0.15
* refactor: use new if/each syntax
* chore: up composer
* fix: regression from user helper refactor
* chore: up harmony
* chore: up composer
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: fix composer version
* feat: add increment helper
* chore: up harmony
* fix: #11228 no timestamps in future :hourglass:
* chore: up harmony
* check config.theme as well
fire action:posts.loaded after processing dom
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up themes
* chore: up harmony
* remove extra class
* refactor: move these to core from harmony
* chore: up widgets
* chore: up widgets
* height auto
* fix: closes #11238
* dont focus inputs, annoying on mobile
* fix: dont focus twice, only focus on chat input on desktop
dont wrap widget footer in row
* chore: up harmony
* chore: up harmony
* update chat window
* chore: up themes
* fix cache buster for skins
* chat fixes
* chore: up harmony
* chore: up composer
* refactor: change hook logs to debug
* fix: scroll to post right after adding to dom
* fix: hash scrolling and highlighting correct post
* test: re-enable read API schema tests
* fix: add back schema changes for 179faa2270f2ad955dcc4a7b04755acce59e6ffd and c3920ccb10d8ead2dcd9914bb1784bed3f6adfd4
* fix: schema changes from 488f0978a4aa1ca1e4d2a1f2e8c7ef7a681f2f27
* fix: schema changes for f4cf482a874701ce80c0f306c49d8788cec66f87
* fix: schema update for be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 69c96078ea78ee2c45885a90a6f6a59f9042a33c
* fix: schema changes for d1364c313021e48a879a818b24947e1457c062f7
* fix: schema changes for 84ff1152f7552dd866e25a90972d970b9861107e
* fix: schema changes for b860c2605c209e0650ef98f4c80d842ea23a51ce
* fix: schema changes for 23cb67a1126481848fac39aafd1e253441e76d7f
* fix: schema changes for b916e42f400dac8aa51670b15e439f87f0eb8939
* fix: schema change for a9bbb586fcb3a1c61b5fb69052236e78cdf7d743
* fix: schema changes for 4b738c8cd36c936a1dbe2bb900c694bf6c5520ec
* fix: schema changes for 58b5781cea9acb129e6604a82ab5a5bfc0d8394d
* fix: schema changes for 794bf01b21709c4be06584d576d706b3d6342057
* fix: schema changes for 80ea12c1c1963f5b39fb64841e4f3c8da3c87af2, e368feef51e0766f119c9710fb4db8f64724725c, and 52ead114bec961c62fa2eb0786540e229f6e4873
* fix: composer-default object in config?
* fix: schema changes for 9acdc6808c070555352951c651921df181b10993 and 093093420027999df3c67bf0ea6024f6dbf81d2d
* fix: schema changes for c0a52924f1f7ef8caeaacda67363ac269b56042c
* fix: schema change for aba420a3f3b774e949c2539c73f3dc0e1ae79a38, move loggedInUser to optional props
* fix: schema changes for 8c67031609da30d788561459f8bb76e9a69253de
* fix: schema changes for 27e53b42f3ce48fa61d3754375715cd41ffe808d
* fix: schema changes for 28359665187b0a3b9ec6226dca1234ebdbd725a5
* fix: breaking test for email confirmation API call
* fix: schema changes for refactored search page
* fix: schema changes for user object
* fix: schema changes for 9f531f957e08eabb4bae844ddd67bde14d9b59f0
* fix: schema changes for c4042c70decd628e5b880bd109515b47e4e16164 and 23175110a29640e6fa052db1079bfedb34a61055
* fix: schema changes for 9b3616b10392e247974eb0c1e6225a1582bf6c69
* fix: schema changes for 5afd5de07d42fd33f039a6f85ded3b4992200e5a
* fix: schema change for 1d7baf12171cffbd3af8914bef4e6297d1160d49
* fix: schema changes for 57bfb37c55a839662144e684875003ab52315ecc and be6bbabd0e2551fbe9571dcf3ee40ad721764543
* fix: schema changes for 6e86b4afa20d662af8b9f1c07518df2d8c258105 and 3efad2e13b7319eb9a1f4fda7af047be43ebc11f and 68f66223e73a72f378f193c83a9b5546bede2cda
* fix: allowing optional qs prop in pagination keys (not sure why this didn't break before)
* fix: re-login on email change
* fix: schema changes for c926358d734a2fa410de87f4e4a91744215fc14a
* fix: schema changes for 388a8270c9882892bad5c8141f65da8d59eac0fd
* fix: schema change for 2658bcc821c22e137a6eeb9bb74098856a642eaf
* fix: no need to call account middlewares for chats routes
* fix: schema changes for 71743affc3e58dc85d4ffa15ce043d4d9ddd3d67
* fix: final schema changes
* test: support for anyOf and oneOf
* fix: check thumb
* dont scroll to top on back press
* remove group log
* fix: add top margin to merged and deleted alerts
* chore: up widgets
* fix: improve fix-lists mixin
* chore: up harmony/composer
* feat: allow hiding quicksearch results during search
* dont record searches made by composer
* chore: up 54
* chore: up spam be gone
* feat: add prev/next page and page count into mobile paginator
* chore: up harmony
* chore: up harmony
* use old style for IS
* fix: hide entire toolbar row if no posts or not singlePost
* fix: updated messaging for post-queue template, #11206
* fix: btn-sm on post queue back button
* fix: bump harmony, closes #11206
* fix: remove unused alert module import
* fix: bump harmony
* fix: bump harmony
* chore: up harmony
* refactor: IS scrolltop
* fix: update users:search-user-for-chat source string
* feat: support for mark-read toggle on chats dropdown and recent chats list
* feat: api v3 calls to mark chat read/unread
* feat: send event:chats.mark socket event on mark read or unread
* refactor: allow frontend to mark chats as unread, use new API v3 routes instead of socket calls, better frontend event handling
* docs: openapi schema updates for chat marking
* fix: allow unread state toggling in chats dropdown too
* fix: issue where repeated openings of the chats dropdown would continually add events for mark-read/unread
* fix: debug log
* refactor: move userSearch filter to a module
* feat(routes): allow remounting /categories (#11230)
* feat: send flags count to frontend on flags list page
* refactor: filter form client-side js to extract out some logic
* fix: applyFilters to not take any arguments, update selectedCids in updateButton instead of onHidden
* fix: use userFilter module for assignee, reporterId, targetUid
* fix(openapi): schema changes for updated flags page
* fix: dont allow adding duplicates to userFilter
* use same var
* remove log
* fix: closes #11282
* feat: lang key for x-topics
* chore: up harmony
* chore: up emoji
* chore: up harmony
* fix: update userFilter to allow new option `selectedBlock`
* fix: wrong block name passed to userFilter
* fix: https://github.com/NodeBB/NodeBB/issues/11283
* fix: chats, allow multiple dropdowns like in harmony
* chore: up harmony
* refactor: flag note adding/editing, closes #11285
* fix: remove old prepareEdit logic
* chore: add caveat about hacky code block in userFilter module
* fix: placeholders for userFilter module
* refactor: navigator so it works with multiple thumbs/navigators
* chore: up harmony
* fix: closes #11287, destroy quick reply autocomplete
on navigation
* fix: filter disabled categories on user categories page count
* chore: up harmony
* docs: update openapi spec to include info about passing in timestamps for topic creation, removing timestamp as valid request param for topic replying
* fix: send back null values on ACP search dashboard for startDate and endDate if not expicitly passed in, fix tests
* fix: tweak table order in ACP dash searches
* fix: only invoke navigator click drag on left mouse button
* feat: add back unread indicator to navigator
* clear bookmark on mark unread
* fix: navigator crash on ajaxify
* better thumb top calculation
* fix: reset user bookmark when topic is marked unread
* Revert "fix: reset user bookmark when topic is marked unread"
This reverts commit 9bcd85c2c6848c3d325d32027261809da6e11c9e.
* fix: update unread indicator on scroll, add unread count
* chore: bump harmony
* fix: crash on navigator unread update when backing out of a topic
* fix: closes #11183
* fix: update topics:recent zset when rescheduling a topic
* fix: dupe quote button, increase delay, hide immediately on empty selection
* fix: navigator not showing up on first load
* refactor: remove glance
assorted fixes to navigator
dont reduce remaning count if user scrolls down and up quickly
only call topic.navigatorCallback when index changes
* more sanity checks for bookmark
dont allow setting bookmark higher than topic postcount
* closes #11218, :train:
* Revert "fix: update topics:recent zset when rescheduling a topic"
This reverts commit 737973cca9e94b6cb3867492a09e1e0b1af391d5.
* fix: #11306, show proper error if queued post doesn't exist
was showing no-privileges if someone else accepted the post
* https://github.com/NodeBB/NodeBB/issues/11307
dont use li
* chore: up harmony
* chore: bump version string
* fix: copy paste fail
* feat: closes #7382, tag filtering
add client side support for filtering by tags on /category, /recent and /unread
* chore: up harmony
* chore: up harmony
* Revert "fix: add back req.query fallback for backwards compatibility" [breaking]
This reverts commit cf6cc2c454dc35c330393c62ee8ce67b42d8eefb.
This commit is no longer required as passing in a CSRF token via query parameter is no longer supported as of NodeBB v3.x
This is a breaking change.
* fix: pass csrf token in form data, re: NodeBB/NodeBB#11309
* chore: up deps
* fix: tests, use x-csrf-token query param removed
* test: fix csrf_token
* lint: remove unused
* feat: add itemprop="image" to avatar helper
* fix: get chat upload button in chat modal
* breaking: remove deprecated socket.io methods
* test: update messaging tests to not use sockets
* fix: parent post links
* fix: prevent post tooltip if mouse leaves before data/tpl is loaded
* chore: up harmony
* chore: up harmony
* chore: up harmony
* chore: up harmony
* fix: nested replies indices
* fix(deps): bump 2factor
* feat: add loggedIn user to all api routes
* chore: up themes
* refactor: audit admin v3 write api routes as per #11321
* refactor: audit category v3 write api routes as per #11321 [breaking]
docs: fix open api spec for #11321
* refactor: audit chat v3 write api routes as per #11321
* refactor: audit files v3 write api routes as per #11321
* refactor: audit flags v3 write api routes as per #11321
* refactor: audit posts v3 write api routes as per #11321
* refactor: audit topics v3 write api routes as per #11321
* refactor: audit users v3 write api routes as per #11321
* fix: lang string
* remove min height
* fix: empty topic/labels taking up space
* fix: tag filtering when changing filter to watched topics
or changing popular time limit to month
* chore: up harmony
* fix: closes #11354, show no post error if queued post already accepted/rejected
* test: #11354
* test: #11354
* fix(deps): bump 2factor
* fix: #11357 clear cache on thumb remove
* fix: thumb remove on windows, closes #11357
* test: openapi for thumbs
* test: fix openapi
---------
Co-authored-by: Julian Lam <julian@nodebb.org>
Co-authored-by: Opliko <opliko.reg@protonmail.com>
2023-03-17 11:58:31 -04:00
|
|
|
|
|
|
|
|
case '[[error:no-topic]]':
|
|
|
|
|
statusCode = 404;
|
|
|
|
|
break;
|
2020-10-15 20:23:19 -04:00
|
|
|
}
|
|
|
|
|
|
2022-05-03 11:14:10 -04:00
|
|
|
if (message.startsWith('[[error:required-parameters-missing, ')) {
|
|
|
|
|
const params = message.slice('[[error:required-parameters-missing, '.length, -2).split(' ');
|
|
|
|
|
Object.assign(response, { params });
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-15 21:23:23 -04:00
|
|
|
const returnPayload = await helpers.generateError(statusCode, message, res);
|
2020-11-24 10:26:09 -05:00
|
|
|
returnPayload.response = response;
|
2020-04-02 20:44:04 -04:00
|
|
|
|
2026-01-21 20:14:15 -05:00
|
|
|
if (process.env.NODE_ENV === 'development') {
|
2026-03-03 10:46:09 -05:00
|
|
|
const stack = payload instanceof Error ? payload.stack : new Error(String(payload)).stack;
|
|
|
|
|
returnPayload.stack = stack;
|
2022-02-01 21:43:09 -05:00
|
|
|
process.stdout.write(`[${chalk.yellow('api')}] Exception caught, error with stack trace follows:\n`);
|
2026-03-03 10:46:09 -05:00
|
|
|
process.stdout.write(stack);
|
2020-04-02 20:44:04 -04:00
|
|
|
}
|
2020-03-31 17:06:13 -04:00
|
|
|
res.status(statusCode).json(returnPayload);
|
2023-08-19 16:40:43 -04:00
|
|
|
} else {
|
2020-10-01 10:52:05 -04:00
|
|
|
// Non-2xx statusCode, generate predefined error
|
2023-08-19 16:40:43 -04:00
|
|
|
const message = payload ? String(payload) : null;
|
|
|
|
|
const returnPayload = await helpers.generateError(statusCode, message, res);
|
2021-07-09 11:40:05 -04:00
|
|
|
res.status(statusCode).json(returnPayload);
|
2020-03-26 20:25:23 -04:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2020-11-24 13:28:05 -05:00
|
|
|
async function generateBannedResponse(res) {
|
|
|
|
|
const response = {};
|
|
|
|
|
const [reason, expiry] = await Promise.all([
|
|
|
|
|
user.bans.getReason(res.req.uid),
|
|
|
|
|
user.getUserField(res.req.uid, 'banned:expire'),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
response.reason = reason;
|
|
|
|
|
if (expiry) {
|
|
|
|
|
Object.assign(response, {
|
|
|
|
|
expiry,
|
|
|
|
|
expiryISO: new Date(expiry).toISOString(),
|
|
|
|
|
expiryLocaleString: new Date(expiry).toLocaleString(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-15 21:23:23 -04:00
|
|
|
helpers.generateError = async (statusCode, message, res) => {
|
|
|
|
|
async function translateMessage(message) {
|
|
|
|
|
const { req } = res;
|
|
|
|
|
const settings = req.query.lang ? null : await user.getSettings(req.uid);
|
|
|
|
|
const language = String(req.query.lang || settings.userLang || meta.config.defaultLang);
|
|
|
|
|
return await translator.translate(message, language);
|
|
|
|
|
}
|
2021-07-09 11:44:49 -04:00
|
|
|
if (message && message.startsWith('[[')) {
|
2022-05-15 21:23:23 -04:00
|
|
|
message = await translateMessage(message);
|
2021-07-09 11:44:49 -04:00
|
|
|
}
|
|
|
|
|
|
2021-02-04 00:06:15 -07:00
|
|
|
const payload = {
|
2020-03-26 20:25:23 -04:00
|
|
|
status: {
|
|
|
|
|
code: 'internal-server-error',
|
2022-05-15 21:23:23 -04:00
|
|
|
message: message || await translateMessage(`[[error:api.${statusCode}]]`),
|
2020-03-26 20:25:23 -04:00
|
|
|
},
|
|
|
|
|
response: {},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
switch (statusCode) {
|
2020-10-01 10:52:05 -04:00
|
|
|
case 400:
|
|
|
|
|
payload.status.code = 'bad-request';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 401:
|
|
|
|
|
payload.status.code = 'not-authorised';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 403:
|
|
|
|
|
payload.status.code = 'forbidden';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 404:
|
|
|
|
|
payload.status.code = 'not-found';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 426:
|
|
|
|
|
payload.status.code = 'upgrade-required';
|
|
|
|
|
break;
|
|
|
|
|
|
2021-01-07 14:05:23 -05:00
|
|
|
case 429:
|
|
|
|
|
payload.status.code = 'too-many-requests';
|
|
|
|
|
break;
|
|
|
|
|
|
2020-10-01 10:52:05 -04:00
|
|
|
case 500:
|
|
|
|
|
payload.status.code = 'internal-server-error';
|
2020-11-27 15:12:55 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 501:
|
|
|
|
|
payload.status.code = 'not-implemented';
|
|
|
|
|
break;
|
2020-12-04 16:42:39 -05:00
|
|
|
|
|
|
|
|
case 503:
|
|
|
|
|
payload.status.code = 'service-unavailable';
|
|
|
|
|
break;
|
2020-03-26 20:25:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return payload;
|
|
|
|
|
};
|
|
|
|
|
|
2019-08-19 23:17:43 -04:00
|
|
|
require('../promisify')(helpers);
|