mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-04 15:37:50 +02:00
refactor: move plugin hook methods to plugin.hooks.*
This commit is contained in:
@@ -12,8 +12,8 @@ exports.handle404 = function handle404(req, res) {
|
||||
const relativePath = nconf.get('relative_path');
|
||||
const isClientScript = new RegExp('^' + relativePath + '\\/assets\\/src\\/.+\\.js(\\?v=\\w+)?$');
|
||||
|
||||
if (plugins.hasListeners('action:meta.override404')) {
|
||||
return plugins.fireHook('action:meta.override404', {
|
||||
if (plugins.hooks.hasListeners('action:meta.override404')) {
|
||||
return plugins.hooks.fire('action:meta.override404', {
|
||||
req: req,
|
||||
res: res,
|
||||
error: {},
|
||||
|
||||
@@ -19,7 +19,7 @@ blocksController.getBlocks = async function (req, res, next) {
|
||||
return next();
|
||||
}
|
||||
const uids = await user.blocks.list(userData.uid);
|
||||
const data = await plugins.fireHook('filter:user.getBlocks', {
|
||||
const data = await plugins.hooks.fire('filter:user.getBlocks', {
|
||||
uids: uids,
|
||||
uid: userData.uid,
|
||||
start: start,
|
||||
|
||||
@@ -112,7 +112,7 @@ helpers.getUserDataByUserSlug = async function (userslug, callerUID) {
|
||||
userData['cover:position'] = validator.escape(String(userData['cover:position'] || '50% 50%'));
|
||||
userData['username:disableEdit'] = !userData.isAdmin && meta.config['username:disableEdit'];
|
||||
userData['email:disableEdit'] = !userData.isAdmin && meta.config['email:disableEdit'];
|
||||
const hookData = await plugins.fireHook('filter:helpers.getUserDataByUserSlug', { userData: userData, callerUID: callerUID });
|
||||
const hookData = await plugins.hooks.fire('filter:helpers.getUserDataByUserSlug', { userData: userData, callerUID: callerUID });
|
||||
return hookData.userData;
|
||||
};
|
||||
|
||||
@@ -128,7 +128,7 @@ async function getAllData(uid, callerUID) {
|
||||
ips: user.getIPs(uid, 4),
|
||||
profile_menu: getProfileMenu(uid, callerUID),
|
||||
groups: groups.getUserGroups([uid]),
|
||||
sso: plugins.fireHook('filter:auth.list', { uid: uid, associations: [] }),
|
||||
sso: plugins.hooks.fire('filter:auth.list', { uid: uid, associations: [] }),
|
||||
canEdit: privileges.users.canEdit(callerUID, uid),
|
||||
canBanUser: privileges.users.canBanUser(callerUID, uid),
|
||||
isBlocked: user.blocks.is(uid, callerUID),
|
||||
@@ -183,7 +183,7 @@ async function getProfileMenu(uid, callerUID) {
|
||||
});
|
||||
}
|
||||
|
||||
return await plugins.fireHook('filter:user.profileMenu', {
|
||||
return await plugins.hooks.fire('filter:user.profileMenu', {
|
||||
uid: uid,
|
||||
callerUID: callerUID,
|
||||
links: links,
|
||||
@@ -197,7 +197,7 @@ async function parseAboutMe(userData) {
|
||||
return;
|
||||
}
|
||||
userData.aboutme = validator.escape(String(userData.aboutme || ''));
|
||||
const parsed = await plugins.fireHook('filter:parse.aboutme', userData.aboutme);
|
||||
const parsed = await plugins.hooks.fire('filter:parse.aboutme', userData.aboutme);
|
||||
userData.aboutmeParsed = translator.escape(parsed);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ notificationsController.get = async function (req, res, next) {
|
||||
const stop = start + itemsPerPage - 1;
|
||||
|
||||
const [filters, isPrivileged] = await Promise.all([
|
||||
plugins.fireHook('filter:notifications.addFilters', {
|
||||
plugins.hooks.fire('filter:notifications.addFilters', {
|
||||
regularFilters: regularFilters,
|
||||
moderatorFilters: moderatorFilters,
|
||||
uid: req.uid,
|
||||
|
||||
@@ -33,7 +33,7 @@ settingsController.get = async function (req, res, next) {
|
||||
userData.acpLanguages = _.cloneDeep(languagesData);
|
||||
}
|
||||
|
||||
const data = await plugins.fireHook('filter:user.customSettings', {
|
||||
const data = await plugins.hooks.fire('filter:user.customSettings', {
|
||||
settings: settings,
|
||||
customSettings: [],
|
||||
uid: req.uid,
|
||||
@@ -110,7 +110,7 @@ settingsController.get = async function (req, res, next) {
|
||||
userData.hideFullname = meta.config.hideFullname || 0;
|
||||
userData.hideEmail = meta.config.hideEmail || 0;
|
||||
|
||||
userData.inTopicSearchAvailable = plugins.hasListeners('filter:topic.search');
|
||||
userData.inTopicSearchAvailable = plugins.hooks.hasListeners('filter:topic.search');
|
||||
|
||||
userData.maxTopicsPerPage = meta.config.maxTopicsPerPage;
|
||||
userData.maxPostsPerPage = meta.config.maxPostsPerPage;
|
||||
@@ -191,7 +191,7 @@ async function getNotificationSettings(userData) {
|
||||
if (privileges.isAdmin || privileges.isGlobalMod) {
|
||||
privilegedTypes.push('notificationType_new-user-flag');
|
||||
}
|
||||
const results = await plugins.fireHook('filter:user.notificationTypes', {
|
||||
const results = await plugins.hooks.fire('filter:user.notificationTypes', {
|
||||
types: notifications.baseTypes.slice(),
|
||||
privilegedTypes: privilegedTypes,
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ categoriesController.get = async function (req, res, next) {
|
||||
});
|
||||
const selectedCategory = allCategories.find(c => c.selected);
|
||||
|
||||
const data = await plugins.fireHook('filter:admin.category.get', {
|
||||
const data = await plugins.hooks.fire('filter:admin.category.get', {
|
||||
req: req,
|
||||
res: res,
|
||||
category: category,
|
||||
@@ -53,7 +53,7 @@ categoriesController.getAll = async function (req, res) {
|
||||
'color', 'bgColor', 'backgroundImage', 'imageClass',
|
||||
];
|
||||
const categoriesData = await categories.getCategoriesFields(cids, fields);
|
||||
const result = await plugins.fireHook('filter:admin.categories.get', { categories: categoriesData, fields: fields });
|
||||
const result = await plugins.hooks.fire('filter:admin.categories.get', { categories: categoriesData, fields: fields });
|
||||
const tree = categories.getTree(result.categories, 0);
|
||||
res.render('admin/manage/categories', {
|
||||
categories: tree,
|
||||
|
||||
@@ -47,7 +47,7 @@ async function getNotices() {
|
||||
notDoneText: '[[admin/dashboard:restart-required]]',
|
||||
},
|
||||
{
|
||||
done: plugins.hasListeners('filter:search.query'),
|
||||
done: plugins.hooks.hasListeners('filter:search.query'),
|
||||
doneText: '[[admin/dashboard:search-plugin-installed]]',
|
||||
notDoneText: '[[admin/dashboard:search-plugin-not-installed]]',
|
||||
tooltip: '[[admin/dashboard:search-plugin-tooltip]]',
|
||||
@@ -62,7 +62,7 @@ async function getNotices() {
|
||||
});
|
||||
}
|
||||
|
||||
return await plugins.fireHook('filter:admin.notices', notices);
|
||||
return await plugins.hooks.fire('filter:admin.notices', notices);
|
||||
}
|
||||
|
||||
async function getLatestVersion() {
|
||||
|
||||
@@ -237,8 +237,8 @@ function validateUpload(res, uploadedFile, allowedTypes) {
|
||||
async function uploadImage(filename, folder, uploadedFile, req, res, next) {
|
||||
let imageData;
|
||||
try {
|
||||
if (plugins.hasListeners('filter:uploadImage')) {
|
||||
imageData = await plugins.fireHook('filter:uploadImage', { image: uploadedFile, uid: req.uid, folder: folder });
|
||||
if (plugins.hooks.hasListeners('filter:uploadImage')) {
|
||||
imageData = await plugins.hooks.fire('filter:uploadImage', { image: uploadedFile, uid: req.uid, folder: folder });
|
||||
} else {
|
||||
imageData = await file.saveFileToLocal(filename, folder, uploadedFile.path);
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ usersController.registrationQueue = async function (req, res) {
|
||||
const data = await utils.promiseParallel({
|
||||
registrationQueueCount: db.sortedSetCard('registration:queue'),
|
||||
users: user.getRegistrationQueue(start, stop),
|
||||
customHeaders: plugins.fireHook('filter:admin.registrationQueue.customHeaders', { headers: [] }),
|
||||
customHeaders: plugins.hooks.fire('filter:admin.registrationQueue.customHeaders', { headers: [] }),
|
||||
invites: getInvites(),
|
||||
});
|
||||
var pageCount = Math.max(1, Math.ceil(data.registrationQueueCount / itemsPerPage));
|
||||
|
||||
@@ -65,7 +65,7 @@ apiController.loadConfig = async function (req) {
|
||||
topicPostSort: meta.config.topicPostSort || 'oldest_to_newest',
|
||||
categoryTopicSort: meta.config.categoryTopicSort || 'newest_to_oldest',
|
||||
csrf_token: req.uid >= 0 && req.csrfToken && req.csrfToken(),
|
||||
searchEnabled: plugins.hasListeners('filter:search.query'),
|
||||
searchEnabled: plugins.hooks.hasListeners('filter:search.query'),
|
||||
bootswatchSkin: meta.config.bootswatchSkin || '',
|
||||
enablePostHistory: meta.config.enablePostHistory === 1,
|
||||
timeagoCutoff: meta.config.timeagoCutoff !== '' ? Math.max(0, parseInt(meta.config.timeagoCutoff, 10)) : meta.config.timeagoCutoff,
|
||||
@@ -98,7 +98,7 @@ apiController.loadConfig = async function (req) {
|
||||
config.categoryTopicSort = settings.categoryTopicSort || config.categoryTopicSort;
|
||||
config.topicSearchEnabled = settings.topicSearchEnabled || false;
|
||||
config.bootswatchSkin = (meta.config.disableCustomUserSkins !== 1 && settings.bootswatchSkin && settings.bootswatchSkin !== '') ? settings.bootswatchSkin : '';
|
||||
config = await plugins.fireHook('filter:config.get', config);
|
||||
config = await plugins.hooks.fire('filter:config.get', config);
|
||||
return config;
|
||||
};
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ const sockets = require('../socket.io');
|
||||
const authenticationController = module.exports;
|
||||
|
||||
async function registerAndLoginUser(req, res, userData) {
|
||||
const data = await plugins.fireHook('filter:register.interstitial', {
|
||||
const data = await plugins.hooks.fire('filter:register.interstitial', {
|
||||
userData: userData,
|
||||
interstitials: [],
|
||||
});
|
||||
@@ -45,7 +45,7 @@ async function registerAndLoginUser(req, res, userData) {
|
||||
return;
|
||||
}
|
||||
const queue = await user.shouldQueueUser(req.ip);
|
||||
const result = await plugins.fireHook('filter:register.shouldQueue', { req: req, res: res, userData: userData, queue: queue });
|
||||
const result = await plugins.hooks.fire('filter:register.shouldQueue', { req: req, res: res, userData: userData, queue: queue });
|
||||
if (result.queue) {
|
||||
return await addToApprovalQueue(req, userData);
|
||||
}
|
||||
@@ -61,7 +61,7 @@ async function registerAndLoginUser(req, res, userData) {
|
||||
}
|
||||
await user.deleteInvitationKey(userData.email);
|
||||
const referrer = req.body.referrer || req.session.referrer || nconf.get('relative_path') + '/';
|
||||
const complete = await plugins.fireHook('filter:register.complete', { uid: uid, referrer: referrer });
|
||||
const complete = await plugins.hooks.fire('filter:register.complete', { uid: uid, referrer: referrer });
|
||||
req.session.returnTo = complete.referrer;
|
||||
return complete;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ authenticationController.register = async function (req, res) {
|
||||
user.isPasswordValid(userData.password);
|
||||
|
||||
res.locals.processLogin = true; // set it to false in plugin if you wish to just register only
|
||||
await plugins.fireHook('filter:register.check', { req: req, res: res, userData: userData });
|
||||
await plugins.hooks.fire('filter:register.check', { req: req, res: res, userData: userData });
|
||||
|
||||
const data = await registerAndLoginUser(req, res, userData);
|
||||
if (data) {
|
||||
@@ -137,7 +137,7 @@ async function addToApprovalQueue(req, userData) {
|
||||
|
||||
authenticationController.registerComplete = function (req, res, next) {
|
||||
// For the interstitials that respond, execute the callback with the form body
|
||||
plugins.fireHook('filter:register.interstitial', {
|
||||
plugins.hooks.fire('filter:register.interstitial', {
|
||||
userData: req.session.registration,
|
||||
interstitials: [],
|
||||
}, function (err, data) {
|
||||
@@ -217,14 +217,14 @@ authenticationController.registerAbort = function (req, res) {
|
||||
};
|
||||
|
||||
authenticationController.login = function (req, res, next) {
|
||||
if (plugins.hasListeners('action:auth.overrideLogin')) {
|
||||
if (plugins.hooks.hasListeners('action:auth.overrideLogin')) {
|
||||
return continueLogin(req, res, next);
|
||||
}
|
||||
|
||||
var loginWith = meta.config.allowLoginWith || 'username-email';
|
||||
req.body.username = req.body.username.trim();
|
||||
|
||||
plugins.fireHook('filter:login.check', { req: req, res: res, userData: req.body }, (err) => {
|
||||
plugins.hooks.fire('filter:login.check', { req: req, res: res, userData: req.body }, (err) => {
|
||||
if (err) {
|
||||
return helpers.noScriptErrors(req, res, err.message, 403);
|
||||
}
|
||||
@@ -355,7 +355,7 @@ authenticationController.onSuccessfulLogin = async function (req, uid) {
|
||||
// Force session check for all connected socket.io clients with the same session id
|
||||
sockets.in('sess_' + req.sessionID).emit('checkSession', uid);
|
||||
|
||||
plugins.fireHook('action:user.loggedIn', { uid: uid, req: req });
|
||||
plugins.hooks.fire('action:user.loggedIn', { uid: uid, req: req });
|
||||
} catch (err) {
|
||||
req.session.destroy();
|
||||
throw err;
|
||||
@@ -428,14 +428,14 @@ authenticationController.logout = async function (req, res, next) {
|
||||
|
||||
await user.setUserField(uid, 'lastonline', Date.now() - (meta.config.onlineCutoff * 60000));
|
||||
await db.sortedSetAdd('users:online', Date.now() - (meta.config.onlineCutoff * 60000), uid);
|
||||
await plugins.fireHook('static:user.loggedOut', { req: req, res: res, uid: uid, sessionID: sessionID });
|
||||
await plugins.hooks.fire('static:user.loggedOut', { req: req, res: res, uid: uid, sessionID: sessionID });
|
||||
|
||||
// Force session check for all connected socket.io clients with the same session id
|
||||
sockets.in('sess_' + sessionID).emit('checkSession', 0);
|
||||
const payload = {
|
||||
next: nconf.get('relative_path') + '/',
|
||||
};
|
||||
plugins.fireHook('filter:user.logout', payload);
|
||||
plugins.hooks.fire('filter:user.logout', payload);
|
||||
|
||||
if (req.body.noscript === 'true') {
|
||||
return res.redirect(payload.next);
|
||||
|
||||
@@ -15,7 +15,7 @@ exports.get = async function (req, res, callback) {
|
||||
content: 'noindex',
|
||||
};
|
||||
|
||||
const data = await plugins.fireHook('filter:composer.build', {
|
||||
const data = await plugins.hooks.fire('filter:composer.build', {
|
||||
req: req,
|
||||
res: res,
|
||||
next: callback,
|
||||
|
||||
@@ -65,7 +65,7 @@ exports.handleErrors = function handleErrors(err, req, res, next) { // eslint-di
|
||||
}
|
||||
};
|
||||
|
||||
plugins.fireHook('filter:error.handle', {
|
||||
plugins.hooks.fire('filter:error.handle', {
|
||||
cases: cases,
|
||||
}, function (_err, data) {
|
||||
if (_err) {
|
||||
|
||||
@@ -116,7 +116,7 @@ helpers.buildTerms = function (url, term, query) {
|
||||
};
|
||||
|
||||
helpers.notAllowed = async function (req, res, error) {
|
||||
const data = await plugins.fireHook('filter:helpers.notAllowed', {
|
||||
const data = await plugins.hooks.fire('filter:helpers.notAllowed', {
|
||||
req: req,
|
||||
res: res,
|
||||
error: error,
|
||||
@@ -336,7 +336,7 @@ helpers.getHomePageRoutes = async function (uid) {
|
||||
name: 'Custom',
|
||||
},
|
||||
]);
|
||||
const data = await plugins.fireHook('filter:homepage.get', { routes: routes });
|
||||
const data = await plugins.hooks.fire('filter:homepage.get', { routes: routes });
|
||||
return data.routes;
|
||||
};
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ async function rewrite(req, res, next) {
|
||||
|
||||
const pathname = parsedUrl.pathname;
|
||||
const hook = 'action:homepage.get:' + pathname;
|
||||
if (!plugins.hasListeners(hook)) {
|
||||
if (!plugins.hooks.hasListeners(hook)) {
|
||||
req.url = req.path + (!req.path.endsWith('/') ? '/' : '') + pathname;
|
||||
} else {
|
||||
res.locals.homePageRoute = pathname;
|
||||
@@ -54,7 +54,7 @@ exports.rewrite = rewrite;
|
||||
function pluginHook(req, res, next) {
|
||||
var hook = 'action:homepage.get:' + res.locals.homePageRoute;
|
||||
|
||||
plugins.fireHook(hook, {
|
||||
plugins.hooks.fire(hook, {
|
||||
req: req,
|
||||
res: res,
|
||||
next: next,
|
||||
|
||||
@@ -184,7 +184,7 @@ Controllers.registerInterstitial = async function (req, res, next) {
|
||||
return res.redirect(nconf.get('relative_path') + '/register');
|
||||
}
|
||||
try {
|
||||
const data = await plugins.fireHook('filter:register.interstitial', {
|
||||
const data = await plugins.hooks.fire('filter:register.interstitial', {
|
||||
userData: req.session.registration,
|
||||
interstitials: [],
|
||||
});
|
||||
@@ -298,7 +298,7 @@ Controllers.manifest = async function (req, res) {
|
||||
});
|
||||
}
|
||||
|
||||
const data = await plugins.fireHook('filter:manifest.build', {
|
||||
const data = await plugins.hooks.fire('filter:manifest.build', {
|
||||
req: req,
|
||||
res: res,
|
||||
manifest: manifest,
|
||||
@@ -331,7 +331,7 @@ Controllers.termsOfUse = async function (req, res, next) {
|
||||
if (!meta.config.termsOfUse) {
|
||||
return next();
|
||||
}
|
||||
const termsOfUse = await plugins.fireHook('filter:parse.post', {
|
||||
const termsOfUse = await plugins.hooks.fire('filter:parse.post', {
|
||||
postData: {
|
||||
content: meta.config.termsOfUse || '',
|
||||
},
|
||||
|
||||
@@ -30,8 +30,8 @@ modsController.flags.list = async function (req, res, next) {
|
||||
const results = await Promise.all([
|
||||
user.isAdminOrGlobalMod(req.uid),
|
||||
user.getModeratedCids(req.uid),
|
||||
plugins.fireHook('filter:flags.validateFilters', { filters: validFilters }),
|
||||
plugins.fireHook('filter:flags.validateSort', { sorts: validSorts }),
|
||||
plugins.hooks.fire('filter:flags.validateFilters', { filters: validFilters }),
|
||||
plugins.hooks.fire('filter:flags.validateSort', { sorts: validSorts }),
|
||||
]);
|
||||
const [isAdminOrGlobalMod, moderatedCids,, { sorts }] = results;
|
||||
let [,, { filters }] = results;
|
||||
@@ -226,7 +226,7 @@ modsController.postQueue = async function (req, res, next) {
|
||||
(!categoriesData.selectedCids.length || categoriesData.selectedCids.includes(p.category.cid)) &&
|
||||
(isAdminOrGlobalMod || moderatedCids.includes(String(p.category.cid))));
|
||||
|
||||
({ posts: postData } = await plugins.fireHook('filter:post-queue.get', {
|
||||
({ posts: postData } = await plugins.hooks.fire('filter:post-queue.get', {
|
||||
posts: postData,
|
||||
req: req,
|
||||
}));
|
||||
@@ -281,6 +281,6 @@ async function addMetaData(postData) {
|
||||
postData.topic = await topics.getTopicFields(postData.data.tid, ['title', 'cid']);
|
||||
}
|
||||
postData.category = await categories.getCategoryData(postData.topic.cid);
|
||||
const result = await plugins.fireHook('filter:parse.post', { postData: postData.data });
|
||||
const result = await plugins.hooks.fire('filter:parse.post', { postData: postData.data });
|
||||
postData.data.content = result.postData.content;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ const plugins = require('../plugins');
|
||||
const meta = require('../meta');
|
||||
|
||||
module.exports.handle = function (req, res, next) {
|
||||
if (plugins.hasListeners('filter:search.query')) {
|
||||
if (plugins.hooks.hasListeners('filter:search.query')) {
|
||||
res.type('application/opensearchdescription+xml').send(generateXML());
|
||||
} else {
|
||||
next();
|
||||
|
||||
@@ -15,7 +15,7 @@ const helpers = require('./helpers');
|
||||
const searchController = module.exports;
|
||||
|
||||
searchController.search = async function (req, res, next) {
|
||||
if (!plugins.hasListeners('filter:search.query')) {
|
||||
if (!plugins.hooks.hasListeners('filter:search.query')) {
|
||||
return next();
|
||||
}
|
||||
const page = Math.max(1, parseInt(req.query.page, 10)) || 1;
|
||||
|
||||
@@ -64,8 +64,8 @@ unreadController.get = async function (req, res) {
|
||||
};
|
||||
|
||||
async function getWatchedCategories(uid, cid, filter) {
|
||||
if (plugins.hasListeners('filter:unread.categories')) {
|
||||
return await plugins.fireHook('filter:unread.categories', { uid: uid, cid: cid });
|
||||
if (plugins.hooks.hasListeners('filter:unread.categories')) {
|
||||
return await plugins.hooks.fire('filter:unread.categories', { uid: uid, cid: cid });
|
||||
}
|
||||
const states = [categories.watchStates.watching];
|
||||
if (filter === 'watched') {
|
||||
|
||||
@@ -56,8 +56,8 @@ async function uploadAsImage(req, uploadedFile) {
|
||||
await image.checkDimensions(uploadedFile.path);
|
||||
await image.stripEXIF(uploadedFile.path);
|
||||
|
||||
if (plugins.hasListeners('filter:uploadImage')) {
|
||||
return await plugins.fireHook('filter:uploadImage', {
|
||||
if (plugins.hooks.hasListeners('filter:uploadImage')) {
|
||||
return await plugins.hooks.fire('filter:uploadImage', {
|
||||
image: uploadedFile,
|
||||
uid: req.uid,
|
||||
folder: 'files',
|
||||
@@ -122,8 +122,8 @@ uploadsController.uploadThumb = async function (req, res, next) {
|
||||
width: meta.config.topicThumbSize,
|
||||
height: meta.config.topicThumbSize,
|
||||
});
|
||||
if (plugins.hasListeners('filter:uploadImage')) {
|
||||
return await plugins.fireHook('filter:uploadImage', {
|
||||
if (plugins.hooks.hasListeners('filter:uploadImage')) {
|
||||
return await plugins.hooks.fire('filter:uploadImage', {
|
||||
image: uploadedFile,
|
||||
uid: req.uid,
|
||||
folder: 'files',
|
||||
@@ -135,8 +135,8 @@ uploadsController.uploadThumb = async function (req, res, next) {
|
||||
};
|
||||
|
||||
uploadsController.uploadFile = async function (uid, uploadedFile) {
|
||||
if (plugins.hasListeners('filter:uploadFile')) {
|
||||
return await plugins.fireHook('filter:uploadFile', {
|
||||
if (plugins.hooks.hasListeners('filter:uploadFile')) {
|
||||
return await plugins.hooks.fire('filter:uploadFile', {
|
||||
file: uploadedFile,
|
||||
uid: uid,
|
||||
folder: 'files',
|
||||
@@ -175,7 +175,7 @@ async function saveFileToLocal(uid, folder, uploadedFile) {
|
||||
};
|
||||
const fileKey = upload.url.replace(nconf.get('upload_url'), '');
|
||||
await db.sortedSetAdd('uid:' + uid + ':uploads', Date.now(), fileKey);
|
||||
const data = await plugins.fireHook('filter:uploadStored', { uid: uid, uploadedFile: uploadedFile, storedFile: storedFile });
|
||||
const data = await plugins.hooks.fire('filter:uploadStored', { uid: uid, uploadedFile: uploadedFile, storedFile: storedFile });
|
||||
return data.storedFile;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user