Merge branch 'develop' of https://github.com/NodeBB/NodeBB into develop

isekai-main
Barış Soner Uşaklı 3 years ago
commit b663c620ce

@ -21,13 +21,13 @@ jobs:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
@ -43,7 +43,7 @@ jobs:
type=raw,value=latest
- name: Build and push Docker images
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile

@ -69,7 +69,7 @@ jobs:
- 6379:6379
mongo:
image: 'mongo:3.6'
image: 'mongo:3.7'
ports:
# Maps port 27017 on service container to the host
- 27017:27017

@ -1,3 +1,20 @@
#### v2.4.1 (2022-08-14)
##### Chores
* **deps:**
* update docker/build-push-action action to v3 (bfd6318c)
* update docker/login-action action to v2 (3d68accf)
* update docker/setup-buildx-action action to v2 (371ac032)
* incrementing version number - v2.4.0 (4834cde3)
* update changelog for v2.4.0 (c4714ff7)
* incrementing version number - v2.3.1 (d2425942)
* incrementing version number - v2.3.0 (046ea120)
##### Bug Fixes
* return at least one in sizeCalculation (#10832) (15ca460c)
#### v2.4.0 (2022-08-10)
##### Chores

@ -2,7 +2,7 @@
"name": "nodebb",
"license": "GPL-3.0",
"description": "NodeBB Forum",
"version": "2.4.0",
"version": "2.4.1",
"homepage": "http://www.nodebb.org",
"repository": {
"type": "git",
@ -29,8 +29,8 @@
},
"dependencies": {
"@adactive/bootstrap-tagsinput": "0.8.2",
"@isaacs/ttlcache": "^1.2.0",
"ace-builds": "1.8.1",
"@isaacs/ttlcache": "1.2.0",
"ace-builds": "1.9.5",
"archiver": "5.3.1",
"async": "3.2.4",
"autoprefixer": "10.4.8",
@ -78,7 +78,7 @@
"less": "4.1.3",
"lodash": "4.17.21",
"logrotate-stream": "0.2.8",
"lru-cache": "7.13.1",
"lru-cache": "7.13.2",
"material-design-lite": "1.3.0",
"mime": "3.0.0",
"mkdirp": "1.0.4",
@ -102,9 +102,9 @@
"nodebb-theme-slick": "2.0.2",
"nodebb-theme-vanilla": "12.1.18",
"nodebb-widget-essentials": "6.0.0",
"nodemailer": "6.7.7",
"nodemailer": "6.7.8",
"nprogress": "0.2.0",
"passport": "0.5.2",
"passport": "0.6.0",
"passport-http-bearer": "1.0.1",
"passport-local": "1.0.0",
"pg": "8.7.3",
@ -150,7 +150,7 @@
"@commitlint/cli": "17.0.3",
"@commitlint/config-angular": "17.0.3",
"coveralls": "3.1.1",
"eslint": "8.21.0",
"eslint": "8.22.0",
"eslint-config-nodebb": "0.1.1",
"eslint-plugin-import": "2.26.0",
"grunt": "1.5.3",

@ -1,5 +1,8 @@
{
"post-cache": "التخزين المؤقت للمشاركات",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "1% كاملة",
"post-cache-size": "حجم التخزين المؤقت للمشاركات",
"items-in-cache": "العناصر في التخزين المؤقت"

@ -1,5 +1,8 @@
{
"post-cache": "Кеш за публикации",
"group-cache": "Кеш за групи",
"local-cache": "Локален кеш",
"object-cache": "Кеш за обекти",
"percent-full": "Запълненост: %1%",
"post-cache-size": "Размер на кеша за публикации",
"items-in-cache": "Елементи в кеша"

@ -1,5 +1,8 @@
{
"post-cache": "Post Cache",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Full",
"post-cache-size": "Post Cache Size",
"items-in-cache": "Items in Cache"

@ -1,5 +1,8 @@
{
"post-cache": "Mezipaměť příspěvku",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% plný",
"post-cache-size": "Velikost mezipaměti příspěvku",
"items-in-cache": "Položek v mezipaměti"

@ -1,5 +1,8 @@
{
"post-cache": "Indlægs Cache",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Fuld",
"post-cache-size": "Indlægs Cache Størrelse",
"items-in-cache": "Ting i Cache"

@ -1,5 +1,8 @@
{
"post-cache": "Post-Cache",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Voll",
"post-cache-size": "Post-Cache-Größe",
"items-in-cache": "Elemente im Cache"

@ -1,5 +1,8 @@
{
"post-cache": "Προσωρινή μνήμη ανάρτησης",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Πλήρες",
"post-cache-size": "Μέγεθος προσωρινής μνήμης ανάρτησης",
"items-in-cache": "Αντικείμενα στην προσωρινή μνήμη"

@ -1,5 +1,8 @@
{
"post-cache": "Post Cache",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Full",
"post-cache-size": "Post Cache Size",
"items-in-cache": "Items in Cache"

@ -1,5 +1,8 @@
{
"post-cache": "Post Cache",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Full",
"post-cache-size": "Post Cache Size",
"items-in-cache": "Items in Cache"

@ -1,5 +1,8 @@
{
"post-cache": "Post Cache",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Full",
"post-cache-size": "Post Cache Size",
"items-in-cache": "Items in Cache"

@ -1,5 +1,8 @@
{
"post-cache": "Publicar Cache",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Completo",
"post-cache-size": "Tamaño de cache del post",
"items-in-cache": "Artículos en cache"

@ -1,5 +1,8 @@
{
"post-cache": "Postituste vahemälu",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Täis",
"post-cache-size": "Postituse vahemälu suurus",
"items-in-cache": "Esemed vahemälus"

@ -1,5 +1,8 @@
{
"post-cache": "کش دیدگاه ",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% تمام شده",
"post-cache-size": "سایز کش دیدگاه",
"items-in-cache": "موارد موجود در کش"

@ -1,5 +1,8 @@
{
"post-cache": "Viestivälimuisti",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Täynnä",
"post-cache-size": "Viestivälimuistin koko",
"items-in-cache": "Asioita välimuistissa"

@ -1,5 +1,8 @@
{
"post-cache": "Cache des messages",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "Plein à %1%",
"post-cache-size": "Taille du cache des messages",
"items-in-cache": "Objets en cache"

@ -1,5 +1,8 @@
{
"post-cache": "Post Cache",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Full",
"post-cache-size": "Post Cache Size",
"items-in-cache": "Items in Cache"

@ -1,5 +1,8 @@
{
"post-cache": "מטמון פוסטים",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Full",
"post-cache-size": "גודל מטמון פוסטים",
"items-in-cache": "פריטים במטמון"

@ -1,5 +1,5 @@
{
"name": "אנגלית (בריטניה/קנדה)",
"name": "עברית (ישראל)",
"code": "he",
"dir": "rtl"
}

@ -1,5 +1,8 @@
{
"post-cache": "Objava predmemorija",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Puno",
"post-cache-size": "Veličina predmemorije objave",
"items-in-cache": "Artikli u predmemoriji"

@ -1,5 +1,8 @@
{
"post-cache": "Hozzászólás gyorsítótár",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Tele",
"post-cache-size": "Hozzászólás gyorsítótáras mérete",
"items-in-cache": "Elemek a gyorsítótárban"

@ -1,5 +1,8 @@
{
"post-cache": "Cache Kiriman",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Penuh",
"post-cache-size": "Ukuran Cache Kiriman",
"items-in-cache": "Item di Cache"

@ -1,5 +1,8 @@
{
"post-cache": "Cache Post",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Pieno",
"post-cache-size": "Dimensione Cache dei Post",
"items-in-cache": "Elementi nella Cache"

@ -1,5 +1,8 @@
{
"post-cache": "投稿キャッシュ",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% がフル",
"post-cache-size": "投稿キャッシュのサイズ",
"items-in-cache": "キャッシュ内のアイテム"

@ -1,5 +1,8 @@
{
"post-cache": "포스트 캐시",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1%꽉참",
"post-cache-size": "포스트 캐시 크기",
"items-in-cache": "캐시된 항목들"

@ -1,5 +1,8 @@
{
"post-cache": "Post Cache",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Full",
"post-cache-size": "Post Cache Size",
"items-in-cache": "Items in Cache"

@ -1,5 +1,8 @@
{
"post-cache": "Rakstu kešatmiņa",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Aizņemts",
"post-cache-size": "Rakstu kešatmiņas lielums",
"items-in-cache": "Rakstu skaits kešatmiņā"

@ -1,5 +1,8 @@
{
"post-cache": "Post Cache",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Full",
"post-cache-size": "Post Cache Size",
"items-in-cache": "Items in Cache"

@ -1,5 +1,8 @@
{
"post-cache": "Post-buffer",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1%full ",
"post-cache-size": "Post-buffer størrelse",
"items-in-cache": "Element i buffer"

@ -1,5 +1,8 @@
{
"post-cache": "Onderwerpcache",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1%vol",
"post-cache-size": "Onderwerpcache grootte",
"items-in-cache": "Items in cache"

@ -1,5 +1,8 @@
{
"post-cache": "Pamięć podręczna postów",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1%",
"post-cache-size": "Rozmiar pamięci podręcznej postów",
"items-in-cache": "Elementów w pamięci podręcznej"

@ -1,5 +1,8 @@
{
"post-cache": "Cache de Posts",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Cheio",
"post-cache-size": "Tamanho do Cache de Posts",
"items-in-cache": "Itens no Cache"

@ -1,5 +1,8 @@
{
"post-cache": "Cache de Publicações",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Cheio",
"post-cache-size": "Tamanho da Cache de Publicações",
"items-in-cache": "Itens em Cache"

@ -1,5 +1,8 @@
{
"post-cache": "Post Cache",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Full",
"post-cache-size": "Post Cache Size",
"items-in-cache": "Items in Cache"

@ -1,5 +1,8 @@
{
"post-cache": "Кэш сообщений",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "Заполнен на%1%",
"post-cache-size": "Размер кэша сообщений",
"items-in-cache": "Закешировано элементов"

@ -1,5 +1,8 @@
{
"post-cache": "Post Cache",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Full",
"post-cache-size": "Post Cache Size",
"items-in-cache": "Items in Cache"

@ -1,5 +1,8 @@
{
"post-cache": "Post Cache",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Full",
"post-cache-size": "Post Cache Size",
"items-in-cache": "Items in Cache"

@ -1,5 +1,8 @@
{
"post-cache": "Vyrovnávacia pamäť príspevku",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% plné",
"post-cache-size": "Veľkosť vyrovnávacej pamäti príspevku",
"items-in-cache": "Položky vo vyrovnávacej pamäti"

@ -1,5 +1,8 @@
{
"post-cache": "Predpomnilnik objav",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1%Zasedeno",
"post-cache-size": "Velikost predpomnilnika objav",
"items-in-cache": "Elementi v predpomnilniku"

@ -1,5 +1,8 @@
{
"post-cache": "Post Cache",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Plot ",
"post-cache-size": "Post Cache Size",
"items-in-cache": "Items in Cache"

@ -1,5 +1,8 @@
{
"post-cache": "Post Cache",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Full",
"post-cache-size": "Post Cache Size",
"items-in-cache": "Items in Cache"

@ -1,5 +1,8 @@
{
"post-cache": "Inläggscache",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Full",
"post-cache-size": "Storlek på inläggscache",
"items-in-cache": "Föremål i cache"

@ -1,5 +1,8 @@
{
"post-cache": "แคชข้อความ",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "เต็ม %1%",
"post-cache-size": "ขนาดแคชของข้อความ",
"items-in-cache": "รายการที่ถูกแคช"

@ -1,5 +1,8 @@
{
"post-cache": "İleti Önbelleği",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Tam",
"post-cache-size": "İleti Önbellek Boyutu",
"items-in-cache": "Önbellekteki Öğeler"

@ -1,5 +1,8 @@
{
"post-cache": "Кеш постів",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "Заповнений на %1%",
"post-cache-size": "Розмір кешу постів",
"items-in-cache": "Елементів у кеші"

@ -1,5 +1,8 @@
{
"post-cache": "Bộ nhớ đệm bài viết",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% Đầy",
"post-cache-size": "Kích thước cache bài viết",
"items-in-cache": "Thành phần trong Cache"

@ -1,5 +1,8 @@
{
"post-cache": "帖子缓存",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% 容量",
"post-cache-size": "帖子缓存大小",
"items-in-cache": "缓存中的条目数量"

@ -1,5 +1,8 @@
{
"post-cache": "貼文快取",
"group-cache": "Group Cache",
"local-cache": "Local Cache",
"object-cache": "Object Cache",
"percent-full": "%1% 容量",
"post-cache-size": "貼文快取大小",
"items-in-cache": "快取中的項目數量"

@ -196,7 +196,7 @@ module.exports = function (utils, Benchpress, relative_path) {
function renderEvents(events) {
return events.reduce((html, event) => {
html += `<li component="topic/event" class="timeline-event" data-topic-event-id="${event.id}">
html += `<li component="topic/event" class="timeline-event" data-topic-event-id="${event.id}" data-topic-event-type="${event.type}">
<div class="timeline-badge">
<i class="fa ${event.icon || 'fa-circle'}"></i>
</div>
@ -216,7 +216,7 @@ module.exports = function (utils, Benchpress, relative_path) {
html += `<span class="timeago timeline-text" title="${event.timestampISO}"></span>`;
if (this.privileges.isAdminOrMod) {
html += `&nbsp;<span component="topic/event/delete" data-topic-event-id="${event.id}" class="timeline-text pointer" title="[[topic:delete-event]]"><i class="fa fa-trash"></i></span>`;
html += `&nbsp;<span component="topic/event/delete" data-topic-event-id="${event.id}" data-topic-event-type="${event.type} class="timeline-text pointer" title="[[topic:delete-event]]"><i class="fa fa-trash"></i></span>`;
}
return html;

5
src/cache/lru.js vendored

@ -37,12 +37,15 @@ module.exports = function (opts) {
cache.enabled = opts.hasOwnProperty('enabled') ? opts.enabled : true;
const cacheSet = lruCache.set;
// backwards compatibility
// expose properties while keeping backwards compatibility
const propertyMap = new Map([
['length', 'calculatedSize'],
['calculatedSize', 'calculatedSize'],
['max', 'max'],
['maxSize', 'maxSize'],
['itemCount', 'size'],
['size', 'size'],
['ttl', 'ttl'],
]);
propertyMap.forEach((lruProp, cacheProp) => {
Object.defineProperty(cache, cacheProp, {

25
src/cache/ttl.js vendored

@ -13,6 +13,23 @@ module.exports = function (opts) {
cache.enabled = opts.hasOwnProperty('enabled') ? opts.enabled : true;
const cacheSet = ttlCache.set;
// expose properties
const propertyMap = new Map([
['max', 'max'],
['itemCount', 'size'],
['size', 'size'],
['ttl', 'ttl'],
]);
propertyMap.forEach((ttlProp, cacheProp) => {
Object.defineProperty(cache, cacheProp, {
get: function () {
return ttlCache[ttlProp];
},
configurable: true,
enumerable: true,
});
});
cache.set = function (key, value, ttl) {
if (!cache.enabled) {
return;
@ -90,5 +107,13 @@ module.exports = function (opts) {
return unCachedKeys;
};
cache.dump = function () {
return Array.from(ttlCache.entries());
};
cache.peek = function (key) {
return ttlCache.get(key, { updateAgeOnGet: false });
};
return cache;
};

@ -3,8 +3,9 @@
const cacheController = module.exports;
const utils = require('../../utils');
const plugins = require('../../plugins');
cacheController.get = function (req, res) {
cacheController.get = async function (req, res) {
const postCache = require('../../posts/cache');
const groupCache = require('../../groups').cache;
const { objectCache } = require('../../database');
@ -23,29 +24,33 @@ cacheController.get = function (req, res) {
misses: utils.addCommas(String(cache.misses)),
hitRatio: ((cache.hits / (cache.hits + cache.misses) || 0)).toFixed(4),
enabled: cache.enabled,
ttl: cache.ttl,
};
}
const data = {
postCache: getInfo(postCache),
groupCache: getInfo(groupCache),
localCache: getInfo(localCache),
let caches = {
post: postCache,
group: groupCache,
local: localCache,
};
if (objectCache) {
data.objectCache = getInfo(objectCache);
caches.object = objectCache;
}
caches = await plugins.hooks.fire('filter:admin.cache.get', caches);
for (const [key, value] of Object.entries(caches)) {
caches[key] = getInfo(value);
}
res.render('admin/advanced/cache', data);
res.render('admin/advanced/cache', { caches });
};
cacheController.dump = function (req, res, next) {
const caches = {
cacheController.dump = async function (req, res, next) {
let caches = {
post: require('../../posts/cache'),
object: require('../../database').objectCache,
group: require('../../groups').cache,
local: require('../../cache'),
};
caches = await plugins.hooks.fire('filter:admin.cache.get', caches);
if (!caches[req.query.name]) {
return next();
}

@ -351,7 +351,7 @@ authenticationController.doLogin = async function (req, uid) {
}
}
await loginAsync({ uid: uid });
await loginAsync({ uid: uid }, { keepSessionInfo: true });
await authenticationController.onSuccessfulLogin(req, uid);
};
@ -459,6 +459,7 @@ authenticationController.localLogin = async function (req, username, password, n
};
const destroyAsync = util.promisify((req, callback) => req.session.destroy(callback));
const logoutAsync = util.promisify((req, callback) => req.logout(callback));
authenticationController.logout = async function (req, res, next) {
if (!req.loggedIn || !req.sessionID) {
@ -470,7 +471,7 @@ authenticationController.logout = async function (req, res, next) {
try {
await user.auth.revokeSession(sessionID, uid);
req.logout();
await logoutAsync();
await destroyAsync(req);
res.clearCookie(nconf.get('sessionKey'), meta.configs.cookie.get());

@ -41,8 +41,10 @@ middleware.buildHeader = helpers.try(async (req, res, next) => {
]);
if (!canLoginIfBanned && req.loggedIn) {
req.logout();
return res.redirect('/');
req.logout(() => {
res.redirect('/');
});
return;
}
res.locals.config = config;

@ -35,7 +35,7 @@ module.exports = function (middleware) {
async function authenticate(req, res) {
async function finishLogin(req, user) {
const loginAsync = util.promisify(req.login).bind(req);
await loginAsync(user);
await loginAsync(user, { keepSessionInfo: true });
await controllers.authentication.onSuccessfulLogin(req, user.uid);
req.uid = user.uid;
req.loggedIn = req.uid > 0;

@ -6,7 +6,7 @@ const meta = require('../meta');
module.exports = cacheCreate({
name: 'post',
maxSize: meta.config.postCacheSize,
sizeCalculation: function (n) { return n.length; },
sizeCalculation: function (n) { return n.length || 1; },
ttl: 0,
enabled: global.env === 'production',
});

@ -93,7 +93,7 @@ Posts.getPostIndices = async function (posts, uid) {
};
Posts.modifyPostByPrivilege = function (post, privileges) {
if (post.deleted && !(post.selfPost || privileges['posts:view_deleted'])) {
if (post && post.deleted && !(post.selfPost || privileges['posts:view_deleted'])) {
post.content = '[[topic:post_is_deleted]]';
if (post.user) {
post.user.signature = '';

@ -139,7 +139,7 @@ Auth.reloadRoutes = async function (params) {
})(req, res, next);
}, Auth.middleware.validateAuth, (req, res, next) => {
async.waterfall([
async.apply(req.login.bind(req), res.locals.user),
async.apply(req.login.bind(req), res.locals.user, { keepSessionInfo: true }),
async.apply(controllers.authentication.onSuccessfulLogin, req, req.uid),
], (err) => {
if (err) {

@ -3,26 +3,30 @@
const SocketCache = module.exports;
const db = require('../../database');
const plugins = require('../../plugins');
SocketCache.clear = async function (socket, data) {
if (data.name === 'post') {
require('../../posts/cache').reset();
} else if (data.name === 'object' && db.objectCache) {
db.objectCache.reset();
} else if (data.name === 'group') {
require('../../groups').cache.reset();
} else if (data.name === 'local') {
require('../../cache').reset();
let caches = {
post: require('../../posts/cache'),
object: db.objectCache,
group: require('../../groups').cache,
local: require('../../cache'),
};
caches = await plugins.hooks.fire('filter:admin.cache.get', caches);
if (!caches[data.name]) {
return;
}
caches[data.name].reset();
};
SocketCache.toggle = async function (socket, data) {
const caches = {
let caches = {
post: require('../../posts/cache'),
object: db.objectCache,
group: require('../../groups').cache,
local: require('../../cache'),
};
caches = await plugins.hooks.fire('filter:admin.cache.get', caches);
if (!caches[data.name]) {
return;
}

@ -2,118 +2,43 @@
<div class="row post-cache">
<div class="col-lg-12">
<div class="row">
{{{each caches}}}
<div class="col-lg-3">
<div class="panel panel-default">
<div class="panel-heading">[[admin/advanced/cache:post-cache]]</div>
<div class="panel-heading">[[admin/advanced/cache:{@key}-cache]]</div>
<div class="panel-body">
<div class="checkbox" data-name="post">
<div class="checkbox" data-name="{@key}">
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
<input class="mdl-switch__input" type="checkbox" {{{if postCache.enabled}}}checked{{{end}}}>
<input class="mdl-switch__input" type="checkbox" {{{if caches.enabled}}}checked{{{end}}}>
</label>
</div>
<span>{postCache.length} / {postCache.maxSize}</span><br/>
<span>{{{if ../length}}}{../length}{{{else}}}{../itemCount}{{{end}}} / {{{if ../max}}}{../max}{{{else}}}{../maxSize}{{{end}}}</span><br/>
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="{postCache.percentFull}" aria-valuemin="0" aria-valuemax="100" style="width: {postCache.percentFull}%;">
[[admin/advanced/cache:percent-full, {postCache.percentFull}]]
<div class="progress-bar" role="progressbar" aria-valuenow="{../percentFull}" aria-valuemin="0" aria-valuemax="100" style="width: {../percentFull}%;">
[[admin/advanced/cache:percent-full, {../percentFull}]]
</div>
</div>
<label>Hits:</label> <span>{postCache.hits}</span><br/>
<label>Misses:</label> <span>{postCache.misses}</span><br/>
<label>Hit Ratio:</label> <span>{postCache.hitRatio}</span><br/>
<label>Hits:</label> <span>{../hits}</span><br/>
<label>Misses:</label> <span>{../misses}</span><br/>
<label>Hit Ratio:</label> <span>{../hitRatio}</span><br/>
{{{if ../ttl}}}<label>TTL:</label> <span>{../ttl}</span></br>{{{end}}}
{{{if (@key == "post")}}}
<hr/>
<div class="form-group">
<label for="postCacheSize">[[admin/advanced/cache:post-cache-size]]</label>
<input id="postCacheSize" type="text" class="form-control" value="" data-field="postCacheSize">
</div>
<a href="{config.relative_path}/api/admin/advanced/cache/dump?name=post" class="btn btn-sm btn-default"><i class="fa fa-download"></i></a>
<a class="btn btn-sm btn-danger clear" data-name="post"><i class="fa fa-trash"></i></a>
</div>
</div>
</div>
<!-- IF objectCache -->
<div class="col-lg-3">
<div class="panel panel-default">
<div class="panel-heading">Object Cache</div>
<div class="panel-body">
<div class="checkbox" data-name="object">
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
<input class="mdl-switch__input" type="checkbox" {{{if objectCache.enabled}}}checked{{{end}}}>
</label>
</div>
<span>{objectCache.itemCount} / {objectCache.max}</span><br/>
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="{objectCache.percentFull}" aria-valuemin="0" aria-valuemax="100" style="width: {objectCache.percentFull}%;">
[[admin/advanced/cache:percent-full, {objectCache.percentFull}]]
</div>
</div>
<label>Hits:</label> <span>{objectCache.hits}</span><br/>
<label>Misses:</label> <span>{objectCache.misses}</span><br/>
<label>Hit Ratio:</label> <span>{objectCache.hitRatio}</span><br/>
<a href="{config.relative_path}/api/admin/advanced/cache/dump?name=object" class="btn btn-sm btn-default"><i class="fa fa-download"></i></a>
<a class="btn btn-sm btn-danger clear" data-name="object"><i class="fa fa-trash"></i></a>
</div>
</div>
</div>
<!-- ENDIF objectCache -->
<div class="col-lg-3">
<div class="panel panel-default">
<div class="panel-heading">Group Cache</div>
<div class="panel-body">
<div class="checkbox" data-name="group">
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
<input class="mdl-switch__input" type="checkbox" {{{if groupCache.enabled}}}checked{{{end}}}>
</label>
</div>
<span>{groupCache.itemCount} / {groupCache.max}</span><br/>
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="{groupCache.percentFull}" aria-valuemin="0" aria-valuemax="100" style="width: {groupCache.percentFull}%;">
[[admin/advanced/cache:percent-full, {groupCache.percentFull}]]
</div>
</div>
<label>Hits:</label> <span>{groupCache.hits}</span><br/>
<label>Misses:</label> <span>{groupCache.misses}</span><br/>
<label>Hit Ratio:</label> <span>{groupCache.hitRatio}</span><br/>
<a href="{config.relative_path}/api/admin/advanced/cache/dump?name=group" class="btn btn-sm btn-default"><i class="fa fa-download"></i></a>
<a class="btn btn-sm btn-danger clear" data-name="group"><i class="fa fa-trash"></i></a>
</div>
</div>
</div>
<div class="col-lg-3">
<div class="panel panel-default">
<div class="panel-heading">Local Cache</div>
<div class="panel-body">
<div class="checkbox" data-name="local">
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
<input class="mdl-switch__input" type="checkbox" {{{if localCache.enabled}}}checked{{{end}}}>
</label>
</div>
<span>{localCache.itemCount} / {localCache.max}</span><br/>
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="{localCache.percentFull}" aria-valuemin="0" aria-valuemax="100" style="width: {localCache.percentFull}%;">
[[admin/advanced/cache:percent-full, {localCache.percentFull}]]
</div>
</div>
<label>Hits:</label> <span>{localCache.hits}</span><br/>
<label>Misses:</label> <span>{localCache.misses}</span><br/>
<label>Hit Ratio:</label> <span>{localCache.hitRatio}</span><br/>
<a href="{config.relative_path}/api/admin/advanced/cache/dump?name=local" class="btn btn-sm btn-default"><i class="fa fa-download"></i></a>
<a class="btn btn-sm btn-danger clear" data-name="local"><i class="fa fa-trash"></i></a>
{{{end}}}
<a href="{config.relative_path}/api/admin/advanced/cache/dump?name={@key}" class="btn btn-sm btn-default"><i class="fa fa-download"></i></a>
<a class="btn btn-sm btn-danger clear" data-name="{@key}"><i class="fa fa-trash"></i></a>
</div>
</div>
</div>
{{{end}}}
</div>
</div>
</div>

Loading…
Cancel
Save