fix: HA event publish

pull/1749/head
NGPixel 4 years ago committed by Nicolas Giard
parent bd4263ecb2
commit 405187b8e0

@ -207,8 +207,8 @@ module.exports = {
// -> Outbound events handling // -> Outbound events handling
this.listener.addChannel('wiki', payload => { this.listener.addChannel('wiki', payload => {
if (_.has(payload.event) && payload.source !== WIKI.INSTANCE_ID) { if (_.has(payload, 'event') && payload.source !== WIKI.INSTANCE_ID) {
WIKI.logger.debug(`Received event ${payload.event} from instance ${payload.source}: [ OK ]`) WIKI.logger.info(`Received event ${payload.event} from instance ${payload.source}: [ OK ]`)
WIKI.events.inbound.emit(payload.event, payload.value) WIKI.events.inbound.emit(payload.event, payload.value)
} }
}) })
@ -239,7 +239,7 @@ module.exports = {
* @param {object} value Payload of the event * @param {object} value Payload of the event
*/ */
notifyViaDB (event, value) { notifyViaDB (event, value) {
this.listener.publish('wiki', { WIKI.models.listener.publish('wiki', {
source: WIKI.INSTANCE_ID, source: WIKI.INSTANCE_ID,
event, event,
value value

@ -350,6 +350,7 @@ module.exports = class Page extends Model {
// -> Render page to HTML // -> Render page to HTML
await WIKI.models.pages.renderPage(page) await WIKI.models.pages.renderPage(page)
WIKI.events.outbound.emit('deletePageFromCache', page.hash)
// -> Update Search Index // -> Update Search Index
const pageContents = await WIKI.models.pages.query().findById(page.id).select('render') 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 * Delete an Existing Page from Cache
* *
* @param {Object} page Page Model Instance * @param {String} page Page Unique Hash
* @param {string} page.hash Hash of the Page
* @returns {Promise} Promise with no value * @returns {Promise} Promise with no value
*/ */
static async deletePageFromCache(page) { static async deletePageFromCache(hash) {
return fs.remove(path.resolve(WIKI.ROOTPATH, WIKI.config.dataPath, `cache/${page.hash}.bin`)) return fs.remove(path.resolve(WIKI.ROOTPATH, WIKI.config.dataPath, `cache/${hash}.bin`))
} }
/** /**

Loading…
Cancel
Save