- await removeUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port)
- })
-
- it('Should notify when a local account is following one of our channel', async function () {
- this.timeout(10000)
-
- await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1@localhost:' + servers[0].port)
-
- await waitJobs(servers)
-
- await checkNewActorFollow(baseParams, 'account', 'root', 'super root name', myUserName, 'presence')
- })
-
- it('Should notify when a remote account is following one of our channel', async function () {
- this.timeout(10000)
-
- await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1@localhost:' + servers[0].port)
-
- await waitJobs(servers)
-
- await checkNewActorFollow(baseParams, 'account', 'root', 'super root 2 name', myUserName, 'presence')
- })
- })
-
- describe('Video-related notifications when video auto-blacklist is enabled', function () {
- let userBaseParams: CheckerBaseParams
- let adminBaseParamsServer1: CheckerBaseParams
- let adminBaseParamsServer2: CheckerBaseParams
- let videoUUID: string
- let videoName: string
- let currentCustomConfig: CustomConfig
-
- before(async () => {
-
- adminBaseParamsServer1 = {
- server: servers[0],
- emails,
- socketNotifications: adminNotifications,
- token: servers[0].accessToken
- }
-
- adminBaseParamsServer2 = {
- server: servers[1],
- emails,
- socketNotifications: adminNotificationsServer2,
- token: servers[1].accessToken
- }
-
- userBaseParams = {
- server: servers[0],
- emails,
- socketNotifications: userNotifications,
- token: userAccessToken
- }
-
- const resCustomConfig = await getCustomConfig(servers[0].url, servers[0].accessToken)
- currentCustomConfig = resCustomConfig.body
- const autoBlacklistTestsCustomConfig = immutableAssign(currentCustomConfig, {
- autoBlacklist: {
- videos: {
- ofUsers: {
- enabled: true
- }
- }
- }
- })
- // enable transcoding otherwise own publish notification after transcoding not expected
- autoBlacklistTestsCustomConfig.transcoding.enabled = true
- await updateCustomConfig(servers[0].url, servers[0].accessToken, autoBlacklistTestsCustomConfig)
-
- await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port)
- await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port)
-
- })
-
- it('Should send notification to moderators on new video with auto-blacklist', async function () {
- this.timeout(20000)
-
- videoName = 'video with auto-blacklist ' + uuidv4()
- const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: videoName })
- videoUUID = resVideo.body.video.uuid
-
- await waitJobs(servers)
- await checkVideoAutoBlacklistForModerators(adminBaseParamsServer1, videoUUID, videoName, 'presence')
- })
-
- it('Should not send video publish notification if auto-blacklisted', async function () {
- await checkVideoIsPublished(userBaseParams, videoName, videoUUID, 'absence')
- })
-
- it('Should not send a local user subscription notification if auto-blacklisted', async function () {
- await checkNewVideoFromSubscription(adminBaseParamsServer1, videoName, videoUUID, 'absence')
- })
-
- it('Should not send a remote user subscription notification if auto-blacklisted', async function () {
- await checkNewVideoFromSubscription(adminBaseParamsServer2, videoName, videoUUID, 'absence')
- })
-
- it('Should send video published and unblacklist after video unblacklisted', async function () {
- this.timeout(20000)
-
- await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, videoUUID)
-
- await waitJobs(servers)
-
- // FIXME: Can't test as two notifications sent to same user and util only checks last one
- // One notification might be better anyways
- // await checkNewBlacklistOnMyVideo(userBaseParams, videoUUID, videoName, 'unblacklist')
- // await checkVideoIsPublished(userBaseParams, videoName, videoUUID, 'presence')
- })
-
- it('Should send a local user subscription notification after removed from blacklist', async function () {
- await checkNewVideoFromSubscription(adminBaseParamsServer1, videoName, videoUUID, 'presence')
- })
-
- it('Should send a remote user subscription notification after removed from blacklist', async function () {
- await checkNewVideoFromSubscription(adminBaseParamsServer2, videoName, videoUUID, 'presence')
- })
-
- it('Should send unblacklist but not published/subscription notes after unblacklisted if scheduled update pending', async function () {
- this.timeout(20000)
-
- let updateAt = new Date(new Date().getTime() + 100000)
-
- const name = 'video with auto-blacklist and future schedule ' + uuidv4()
-
- const data = {
- name,
- privacy: VideoPrivacy.PRIVATE,
- scheduleUpdate: {
- updateAt: updateAt.toISOString(),
- privacy: VideoPrivacy.PUBLIC
- }
- }
-
- const resVideo = await uploadVideo(servers[0].url, userAccessToken, data)
- const uuid = resVideo.body.video.uuid
-
- await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, uuid)
-
- await waitJobs(servers)
- await checkNewBlacklistOnMyVideo(userBaseParams, uuid, name, 'unblacklist')
-
- // FIXME: Can't test absence as two notifications sent to same user and util only checks last one
- // One notification might be better anyways
- // await checkVideoIsPublished(userBaseParams, name, uuid, 'absence')
-
- await checkNewVideoFromSubscription(adminBaseParamsServer1, name, uuid, 'absence')
- await checkNewVideoFromSubscription(adminBaseParamsServer2, name, uuid, 'absence')
- })
-
- it('Should not send publish/subscription notifications after scheduled update if video still auto-blacklisted', async function () {
- this.timeout(20000)
-
- // In 2 seconds
- let updateAt = new Date(new Date().getTime() + 2000)
-
- const name = 'video with schedule done and still auto-blacklisted ' + uuidv4()
-
- const data = {
- name,
- privacy: VideoPrivacy.PRIVATE,
- scheduleUpdate: {
- updateAt: updateAt.toISOString(),
- privacy: VideoPrivacy.PUBLIC
- }
- }
-
- const resVideo = await uploadVideo(servers[0].url, userAccessToken, data)
- const uuid = resVideo.body.video.uuid
-
- await wait(6000)
- await checkVideoIsPublished(userBaseParams, name, uuid, 'absence')
- await checkNewVideoFromSubscription(adminBaseParamsServer1, name, uuid, 'absence')
- await checkNewVideoFromSubscription(adminBaseParamsServer2, name, uuid, 'absence')
- })
-
- it('Should not send a notification to moderators on new video without auto-blacklist', async function () {
- this.timeout(20000)
-
- const name = 'video without auto-blacklist ' + uuidv4()
-
- // admin with blacklist right will not be auto-blacklisted
- const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name })
- const uuid = resVideo.body.video.uuid
-
- await waitJobs(servers)
- await checkVideoAutoBlacklistForModerators(adminBaseParamsServer1, uuid, name, 'absence')
- })
-
- after(async () => {
- await updateCustomConfig(servers[0].url, servers[0].accessToken, currentCustomConfig)
-
- await removeUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port)
- await removeUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port)
- })
- })
-
- describe('Mark as read', function () {
- it('Should mark as read some notifications', async function () {
- const res = await getUserNotifications(servers[ 0 ].url, userAccessToken, 2, 3)
- const ids = res.body.data.map(n => n.id)
-
- await markAsReadNotifications(servers[ 0 ].url, userAccessToken, ids)
- })
-
- it('Should have the notifications marked as read', async function () {
- const res = await getUserNotifications(servers[ 0 ].url, userAccessToken, 0, 10)
-
- const notifications = res.body.data as UserNotification[]
- expect(notifications[ 0 ].read).to.be.false
- expect(notifications[ 1 ].read).to.be.false
- expect(notifications[ 2 ].read).to.be.true
- expect(notifications[ 3 ].read).to.be.true
- expect(notifications[ 4 ].read).to.be.true
- expect(notifications[ 5 ].read).to.be.false
- })
-
- it('Should only list read notifications', async function () {
- const res = await getUserNotifications(servers[ 0 ].url, userAccessToken, 0, 10, false)
-
- const notifications = res.body.data as UserNotification[]
- for (const notification of notifications) {
- expect(notification.read).to.be.true
- }
- })
-
- it('Should only list unread notifications', async function () {
- const res = await getUserNotifications(servers[ 0 ].url, userAccessToken, 0, 10, true)
-
- const notifications = res.body.data as UserNotification[]
- for (const notification of notifications) {
- expect(notification.read).to.be.false
- }
- })
-
- it('Should mark as read all notifications', async function () {
- await markAsReadAllNotifications(servers[ 0 ].url, userAccessToken)
-
- const res = await getUserNotifications(servers[ 0 ].url, userAccessToken, 0, 10, true)
-
- expect(res.body.total).to.equal(0)
- expect(res.body.data).to.have.lengthOf(0)
- })
- })
-
- describe('Notification settings', function () {
- let baseParams: CheckerBaseParams
-
- before(() => {
- baseParams = {
- server: servers[0],
- emails,
- socketNotifications: userNotifications,
- token: userAccessToken
- }
- })
-
- it('Should not have notifications', async function () {
- this.timeout(20000)
-
- await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, {
- newVideoFromSubscription: UserNotificationSettingValue.NONE
- }))
-
- {
- const res = await getMyUserInformation(servers[0].url, userAccessToken)
- const info = res.body as User
- expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.NONE)
- }
-
- const { name, uuid } = await uploadVideoByLocalAccount(servers)
-
- const check = { web: true, mail: true }
- await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'absence')
- })
-
- it('Should only have web notifications', async function () {
- this.timeout(20000)
-
- await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, {
- newVideoFromSubscription: UserNotificationSettingValue.WEB
- }))
-
- {
- const res = await getMyUserInformation(servers[0].url, userAccessToken)
- const info = res.body as User
- expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB)
- }
-
- const { name, uuid } = await uploadVideoByLocalAccount(servers)
-
- {
- const check = { mail: true, web: false }
- await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'absence')
- }
-
- {
- const check = { mail: false, web: true }
- await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'presence')
- }
- })
-
- it('Should only have mail notifications', async function () {
- this.timeout(20000)
-
- await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, {
- newVideoFromSubscription: UserNotificationSettingValue.EMAIL
- }))
-
- {
- const res = await getMyUserInformation(servers[0].url, userAccessToken)
- const info = res.body as User
- expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.EMAIL)
- }
-
- const { name, uuid } = await uploadVideoByLocalAccount(servers)
-
- {
- const check = { mail: false, web: true }
- await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'absence')
- }
-
- {
- const check = { mail: true, web: false }
- await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'presence')
- }
- })
-
- it('Should have email and web notifications', async function () {
- this.timeout(20000)
-
- await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, {
- newVideoFromSubscription: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL
- }))
-
- {
- const res = await getMyUserInformation(servers[0].url, userAccessToken)
- const info = res.body as User
- expect(info.notificationSettings.newVideoFromSubscription).to.equal(
- UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL
- )
- }
-
- const { name, uuid } = await uploadVideoByLocalAccount(servers)
-
- await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
- })