From 405187b8e0e1bd9704303d7fd6bb2824e3378137 Mon Sep 17 00:00:00 2001 From: NGPixel Date: Sun, 19 Apr 2020 22:41:19 -0400 Subject: [PATCH] fix: HA event publish --- server/core/db.js | 6 +++--- server/models/pages.js | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/server/core/db.js b/server/core/db.js index e2b4fbe4..15e02eb3 100644 --- a/server/core/db.js +++ b/server/core/db.js @@ -207,8 +207,8 @@ module.exports = { // -> Outbound events handling this.listener.addChannel('wiki', payload => { - if (_.has(payload.event) && payload.source !== WIKI.INSTANCE_ID) { - WIKI.logger.debug(`Received event ${payload.event} from instance ${payload.source}: [ OK ]`) + if (_.has(payload, 'event') && payload.source !== WIKI.INSTANCE_ID) { + WIKI.logger.info(`Received event ${payload.event} from instance ${payload.source}: [ OK ]`) WIKI.events.inbound.emit(payload.event, payload.value) } }) @@ -239,7 +239,7 @@ module.exports = { * @param {object} value Payload of the event */ notifyViaDB (event, value) { - this.listener.publish('wiki', { + WIKI.models.listener.publish('wiki', { source: WIKI.INSTANCE_ID, event, value diff --git a/server/models/pages.js b/server/models/pages.js index e1abbfa5..4f70e7b8 100644 --- a/server/models/pages.js +++ b/server/models/pages.js @@ -350,6 +350,7 @@ module.exports = class Page extends Model { // -> Render page to HTML await WIKI.models.pages.renderPage(page) + WIKI.events.outbound.emit('deletePageFromCache', page.hash) // -> Update Search Index const pageContents = await WIKI.models.pages.query().findById(page.id).select('render') @@ -804,12 +805,11 @@ module.exports = class Page extends Model { /** * Delete an Existing Page from Cache * - * @param {Object} page Page Model Instance - * @param {string} page.hash Hash of the Page + * @param {String} page Page Unique Hash * @returns {Promise} Promise with no value */ - static async deletePageFromCache(page) { - return fs.remove(path.resolve(WIKI.ROOTPATH, WIKI.config.dataPath, `cache/${page.hash}.bin`)) + static async deletePageFromCache(hash) { + return fs.remove(path.resolve(WIKI.ROOTPATH, WIKI.config.dataPath, `cache/${hash}.bin`)) } /**