refactor: move plugin hook methods to plugin.hooks.*

This commit is contained in:
Julian Lam
2020-11-20 16:06:26 -05:00
parent 3b1c03ed50
commit 6e2da9966e
136 changed files with 550 additions and 541 deletions

View File

@@ -38,7 +38,7 @@ Notifications.privilegedTypes = [
];
Notifications.getAllNotificationTypes = async function () {
const results = await plugins.fireHook('filter:user.notificationTypes', {
const results = await plugins.hooks.fire('filter:user.notificationTypes', {
types: Notifications.baseTypes.slice(),
privilegedTypes: Notifications.privilegedTypes.slice(),
});
@@ -213,7 +213,7 @@ async function pushToUids(uids, notification) {
// Remove uid from recipients list if they have blocked the user triggering the notification
uids = await User.blocks.filterUids(notification.from, uids);
const data = await plugins.fireHook('filter:notification.push', { notification: notification, uids: uids });
const data = await plugins.hooks.fire('filter:notification.push', { notification: notification, uids: uids });
if (!data || !data.notification || !data.uids || !data.uids.length) {
return;
}
@@ -227,7 +227,7 @@ async function pushToUids(uids, notification) {
sendNotification(results.uidsToNotify),
sendEmail(results.uidsToEmail),
]);
plugins.fireHook('action:notification.pushed', {
plugins.hooks.fire('action:notification.pushed', {
notification: notification,
uids: results.uidsToNotify,
uidsNotified: results.uidsToNotify,
@@ -419,7 +419,7 @@ Notifications.merge = async function (notifications) {
return notifications;
}, notifications);
const data = await plugins.fireHook('filter:notifications.merge', {
const data = await plugins.hooks.fire('filter:notifications.merge', {
notifications: notifications,
});
return data && data.notifications;