}
function checkVideo (video: any, videoName?: string, videoUUID?: string) {
- expect(video.name).to.be.a('string')
- expect(video.name).to.not.be.empty
- if (videoName) expect(video.name).to.equal(videoName)
+ if (videoName) {
+ expect(video.name).to.be.a('string')
+ expect(video.name).to.not.be.empty
+ expect(video.name).to.equal(videoName)
+ }
- expect(video.uuid).to.be.a('string')
- expect(video.uuid).to.not.be.empty
- if (videoUUID) expect(video.uuid).to.equal(videoUUID)
+ if (videoUUID) {
+ expect(video.uuid).to.be.a('string')
+ expect(video.uuid).to.not.be.empty
+ expect(video.uuid).to.equal(videoUUID)
+ }
expect(video.id).to.be.a('number')
}
}
async function checkNewVideoAbuseForModerators (base: CheckerBaseParams, videoUUID: string, videoName: string, type: CheckerType) {
- const notificationType = UserNotificationType.NEW_VIDEO_ABUSE_FOR_MODERATORS
+ const notificationType = UserNotificationType.NEW_ABUSE_FOR_MODERATORS
+
+ function notificationChecker (notification: UserNotification, type: CheckerType) {
+ if (type === 'presence') {
+ expect(notification).to.not.be.undefined
+ expect(notification.type).to.equal(notificationType)
+
+ expect(notification.abuse.id).to.be.a('number')
+ checkVideo(notification.abuse.video, videoName, videoUUID)
+ } else {
+ expect(notification).to.satisfy((n: UserNotification) => {
+ return n === undefined || n.abuse === undefined || n.abuse.video.uuid !== videoUUID
+ })
+ }
+ }
+
+ function emailNotificationFinder (email: object) {
+ const text = email['text']
+ return text.indexOf(videoUUID) !== -1 && text.indexOf('abuse') !== -1
+ }
+
+ await checkNotification(base, notificationChecker, emailNotificationFinder, type)
+}
+
+async function checkNewCommentAbuseForModerators (base: CheckerBaseParams, videoUUID: string, videoName: string, type: CheckerType) {
+ const notificationType = UserNotificationType.NEW_ABUSE_FOR_MODERATORS
function notificationChecker (notification: UserNotification, type: CheckerType) {
if (type === 'presence') {
expect(notification).to.not.be.undefined
expect(notification.type).to.equal(notificationType)
- expect(notification.videoAbuse.id).to.be.a('number')
- checkVideo(notification.videoAbuse.video, videoName, videoUUID)
+ expect(notification.abuse.id).to.be.a('number')
+ checkVideo(notification.abuse.comment.video, videoName, videoUUID)
} else {
expect(notification).to.satisfy((n: UserNotification) => {
- return n === undefined || n.videoAbuse === undefined || n.videoAbuse.video.uuid !== videoUUID
+ return n === undefined || n.abuse === undefined || n.abuse.comment.video.uuid !== videoUUID
})
}
}
await checkNotification(base, notificationChecker, emailNotificationFinder, type)
}
+async function checkNewAccountAbuseForModerators (base: CheckerBaseParams, displayName: string, type: CheckerType) {
+ const notificationType = UserNotificationType.NEW_ABUSE_FOR_MODERATORS
+
+ function notificationChecker (notification: UserNotification, type: CheckerType) {
+ if (type === 'presence') {
+ expect(notification).to.not.be.undefined
+ expect(notification.type).to.equal(notificationType)
+
+ expect(notification.abuse.id).to.be.a('number')
+ expect(notification.abuse.account.displayName).to.equal(displayName)
+ } else {
+ expect(notification).to.satisfy((n: UserNotification) => {
+ return n === undefined || n.abuse === undefined || n.abuse.account.displayName !== displayName
+ })
+ }
+ }
+
+ function emailNotificationFinder (email: object) {
+ const text = email['text']
+ return text.indexOf(displayName) !== -1 && text.indexOf('abuse') !== -1
+ }
+
+ await checkNotification(base, notificationChecker, emailNotificationFinder, type)
+}
+
async function checkVideoAutoBlacklistForModerators (base: CheckerBaseParams, videoUUID: string, videoName: string, type: CheckerType) {
const notificationType = UserNotificationType.VIDEO_AUTO_BLACKLIST_FOR_MODERATORS
return {
newVideoFromSubscription: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
newCommentOnMyVideo: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
- videoAbuseAsModerator: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
+ abuseAsModerator: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
videoAutoBlacklistAsModerator: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
blacklistOnMyVideo: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
myVideoImportFinished: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
smtp: {
hostname: 'localhost',
port
+ },
+ signup: {
+ limit: 20
}
}
const servers = await flushAndRunMultipleServers(serversCount, overrideConfig)
markAsReadNotifications,
getLastNotification,
checkNewInstanceFollower,
- prepareNotificationsTest
+ prepareNotificationsTest,
+ checkNewCommentAbuseForModerators,
+ checkNewAccountAbuseForModerators
}