Add Hooks to normalize payload and error validation
Closed this issue · 4 comments
Hi,
Would it be possible to fire a hook (passing in the payload and userData) in the normalizePayload function so we can do some custom normalizing of our app cookie data and custom validation on the payload?
nodebb-plugin-session-sharing/library.js
Line 191 in 1a55469
Also would it be possible to fire hooks after each error condition in the process callback for some custom error handling (passing in req, res, err, uid, plugin settings)?
nodebb-plugin-session-sharing/library.js
Line 417 in 1a55469
nodebb-plugin-session-sharing/library.js
Line 421 in 1a55469
nodebb-plugin-session-sharing/library.js
Line 425 in 1a55469
nodebb-plugin-session-sharing/library.js
Line 429 in 1a55469
Thanks
Look at you @uplift, getting all advanced with plugins firing hooks for other plugins to listen for 😄
I have no objection to this if you want to open a PR for filter:sessionSharing.normalizePayload
, though for the errors, you can add this after if (err) {
:
if (plugins.hasListeners('filter:sessionSharing.error')) {
return plugins.fireHook('filter:sessionSharing.error', whatever, arguments, you, needed);
}
Haha, Trust me its better than the current approach I inherited :)
I'll try get something across in next couple of weeks as this is a background task for me currently.