1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-06 03:50:26 +02:00

Add notification plugin hook

This commit is contained in:
Chocobozzz 2022-08-03 11:33:43 +02:00
parent 0260dc8aca
commit 785f1897a4
No known key found for this signature in database
GPG key ID: 583A612D890159BE
23 changed files with 61 additions and 43 deletions

View file

@ -7,12 +7,12 @@ import { MAbuseFull, MAbuseMessage, MActorFollowFull, MApplication, MPlugin } fr
import { MCommentOwnerVideo, MVideoAccountLight, MVideoFullLight } from '../../types/models/video'
import { JobQueue } from '../job-queue'
import { PeerTubeSocket } from '../peertube-socket'
import { Hooks } from '../plugins/hooks'
import {
AbstractNotification,
AbuseStateChangeForReporter,
AutoFollowForInstance,
CommentMention,
StudioEditionFinishedForOwner,
FollowForInstance,
FollowForUser,
ImportFinishedForOwner,
@ -31,6 +31,7 @@ import {
OwnedPublicationAfterScheduleUpdate,
OwnedPublicationAfterTranscoding,
RegistrationForModerators,
StudioEditionFinishedForOwner,
UnblacklistForOwner
} from './shared'
@ -222,15 +223,21 @@ class Notifier {
for (const user of users) {
const setting = object.getSetting(user)
if (this.isWebNotificationEnabled(setting)) {
const notification = await object.createNotification(user)
const webNotificationEnabled = this.isWebNotificationEnabled(setting)
const emailNotificationEnabled = this.isEmailEnabled(user, setting)
const notification = object.createNotification(user)
if (webNotificationEnabled) {
await notification.save()
PeerTubeSocket.Instance.sendNotification(user.id, notification)
}
if (this.isEmailEnabled(user, setting)) {
if (emailNotificationEnabled) {
toEmails.push(user.email)
}
Hooks.runAction('action:notifier.notification.created', { webNotificationEnabled, emailNotificationEnabled, user, notification })
}
for (const to of toEmails) {