2020-01-31 09:56:52 -06:00
|
|
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
import * as chai from 'chai'
|
|
|
|
import 'mocha'
|
|
|
|
import {
|
|
|
|
addVideoToBlacklist,
|
2019-04-25 07:23:15 -05:00
|
|
|
cleanupTests,
|
2018-12-26 03:36:24 -06:00
|
|
|
createUser,
|
|
|
|
doubleFollow,
|
|
|
|
flushAndRunMultipleServers,
|
2019-04-25 07:23:15 -05:00
|
|
|
follow,
|
|
|
|
getCustomConfig,
|
2018-12-26 03:36:24 -06:00
|
|
|
getMyUserInformation,
|
2019-04-25 07:23:15 -05:00
|
|
|
getVideoCommentThreads,
|
|
|
|
getVideoThreadComments,
|
2018-12-26 03:36:24 -06:00
|
|
|
immutableAssign,
|
2019-09-04 04:39:25 -05:00
|
|
|
MockInstancesIndex,
|
2019-01-04 01:56:20 -06:00
|
|
|
registerUser,
|
2018-12-26 03:36:24 -06:00
|
|
|
removeVideoFromBlacklist,
|
2019-09-04 04:39:25 -05:00
|
|
|
reportVideoAbuse,
|
|
|
|
unfollow,
|
|
|
|
updateCustomConfig,
|
|
|
|
updateCustomSubConfig,
|
2019-01-04 01:56:20 -06:00
|
|
|
updateMyUser,
|
2018-12-26 03:36:24 -06:00
|
|
|
updateVideo,
|
2019-01-04 01:56:20 -06:00
|
|
|
updateVideoChannel,
|
2018-12-26 03:36:24 -06:00
|
|
|
userLogin,
|
2019-04-25 07:23:15 -05:00
|
|
|
wait
|
2019-04-15 08:26:15 -05:00
|
|
|
} from '../../../../shared/extra-utils'
|
2019-04-25 07:23:15 -05:00
|
|
|
import { ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index'
|
2019-04-15 08:26:15 -05:00
|
|
|
import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
|
|
|
|
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
|
|
|
|
import { getUserNotificationSocket } from '../../../../shared/extra-utils/socket/socket-io'
|
2018-12-26 03:36:24 -06:00
|
|
|
import {
|
2019-09-04 04:39:25 -05:00
|
|
|
checkAutoInstanceFollowing,
|
2019-01-04 01:56:20 -06:00
|
|
|
checkCommentMention,
|
2018-12-26 03:36:24 -06:00
|
|
|
CheckerBaseParams,
|
2019-01-04 01:56:20 -06:00
|
|
|
checkMyVideoImportIsFinished,
|
|
|
|
checkNewActorFollow,
|
2018-12-26 03:36:24 -06:00
|
|
|
checkNewBlacklistOnMyVideo,
|
|
|
|
checkNewCommentOnMyVideo,
|
2019-04-25 07:23:15 -05:00
|
|
|
checkNewInstanceFollower,
|
2018-12-26 03:36:24 -06:00
|
|
|
checkNewVideoAbuseForModerators,
|
|
|
|
checkNewVideoFromSubscription,
|
2019-01-04 01:56:20 -06:00
|
|
|
checkUserRegistered,
|
2019-04-25 07:23:15 -05:00
|
|
|
checkVideoAutoBlacklistForModerators,
|
2019-01-04 01:56:20 -06:00
|
|
|
checkVideoIsPublished,
|
2018-12-26 03:36:24 -06:00
|
|
|
getLastNotification,
|
|
|
|
getUserNotifications,
|
2019-04-25 07:23:15 -05:00
|
|
|
markAsReadAllNotifications,
|
2018-12-26 03:36:24 -06:00
|
|
|
markAsReadNotifications,
|
2019-09-04 04:39:25 -05:00
|
|
|
updateMyNotificationSettings
|
2019-04-15 08:26:15 -05:00
|
|
|
} from '../../../../shared/extra-utils/users/user-notifications'
|
2019-01-02 09:37:43 -06:00
|
|
|
import {
|
|
|
|
User,
|
|
|
|
UserNotification,
|
|
|
|
UserNotificationSetting,
|
|
|
|
UserNotificationSettingValue,
|
|
|
|
UserNotificationType
|
|
|
|
} from '../../../../shared/models/users'
|
2019-04-15 08:26:15 -05:00
|
|
|
import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'
|
|
|
|
import { addUserSubscription, removeUserSubscription } from '../../../../shared/extra-utils/users/user-subscriptions'
|
2018-12-26 03:36:24 -06:00
|
|
|
import { VideoPrivacy } from '../../../../shared/models/videos'
|
2019-04-15 08:26:15 -05:00
|
|
|
import { getBadVideoUrl, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports'
|
|
|
|
import { addVideoCommentReply, addVideoCommentThread } from '../../../../shared/extra-utils/videos/video-comments'
|
2019-01-02 09:37:43 -06:00
|
|
|
import * as uuidv4 from 'uuid/v4'
|
2019-04-15 08:26:15 -05:00
|
|
|
import { addAccountToAccountBlocklist, removeAccountFromAccountBlocklist } from '../../../../shared/extra-utils/users/blocklist'
|
2019-04-02 04:26:47 -05:00
|
|
|
import { CustomConfig } from '../../../../shared/models/server'
|
2019-04-03 03:26:03 -05:00
|
|
|
import { VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
const expect = chai.expect
|
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
async function uploadVideoByRemoteAccount (servers: ServerInfo[], additionalParams: any = {}) {
|
|
|
|
const name = 'remote video ' + uuidv4()
|
|
|
|
|
|
|
|
const data = Object.assign({ name }, additionalParams)
|
2020-01-31 09:56:52 -06:00
|
|
|
const res = await uploadVideo(servers[1].url, servers[1].accessToken, data)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
return { uuid: res.body.video.uuid, name }
|
2018-12-26 03:36:24 -06:00
|
|
|
}
|
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
async function uploadVideoByLocalAccount (servers: ServerInfo[], additionalParams: any = {}) {
|
|
|
|
const name = 'local video ' + uuidv4()
|
|
|
|
|
|
|
|
const data = Object.assign({ name }, additionalParams)
|
2020-01-31 09:56:52 -06:00
|
|
|
const res = await uploadVideo(servers[0].url, servers[0].accessToken, data)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
return { uuid: res.body.video.uuid, name }
|
2018-12-26 03:36:24 -06:00
|
|
|
}
|
|
|
|
|
2019-02-07 04:48:17 -06:00
|
|
|
describe('Test users notifications', function () {
|
2018-12-26 03:36:24 -06:00
|
|
|
let servers: ServerInfo[] = []
|
|
|
|
let userAccessToken: string
|
2020-01-31 09:56:52 -06:00
|
|
|
const userNotifications: UserNotification[] = []
|
|
|
|
const adminNotifications: UserNotification[] = []
|
|
|
|
const adminNotificationsServer2: UserNotification[] = []
|
2018-12-26 03:36:24 -06:00
|
|
|
const emails: object[] = []
|
2019-01-02 09:37:43 -06:00
|
|
|
let channelId: number
|
|
|
|
|
|
|
|
const allNotificationSettings: UserNotificationSetting = {
|
2019-01-08 04:26:41 -06:00
|
|
|
newVideoFromSubscription: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
|
|
|
|
newCommentOnMyVideo: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
|
|
|
|
videoAbuseAsModerator: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
|
2019-04-02 04:26:47 -05:00
|
|
|
videoAutoBlacklistAsModerator: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
|
2019-01-08 04:26:41 -06:00
|
|
|
blacklistOnMyVideo: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
|
|
|
|
myVideoImportFinished: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
|
|
|
|
myVideoPublished: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
|
|
|
|
commentMention: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
|
|
|
|
newFollow: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
|
2019-04-08 10:26:01 -05:00
|
|
|
newUserRegistration: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
|
2019-08-30 09:50:12 -05:00
|
|
|
newInstanceFollower: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
|
|
|
|
autoInstanceFollowing: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL
|
2019-01-02 09:37:43 -06:00
|
|
|
}
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
before(async function () {
|
|
|
|
this.timeout(120000)
|
|
|
|
|
2019-04-25 10:14:49 -05:00
|
|
|
const port = await MockSmtpServer.Instance.collectEmails(emails)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
const overrideConfig = {
|
|
|
|
smtp: {
|
2019-04-25 10:14:49 -05:00
|
|
|
hostname: 'localhost',
|
|
|
|
port
|
2018-12-26 03:36:24 -06:00
|
|
|
}
|
|
|
|
}
|
2019-04-08 10:26:01 -05:00
|
|
|
servers = await flushAndRunMultipleServers(3, overrideConfig)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
// Get the access tokens
|
|
|
|
await setAccessTokensToServers(servers)
|
|
|
|
|
|
|
|
// Server 1 and server 2 follow each other
|
|
|
|
await doubleFollow(servers[0], servers[1])
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
|
|
|
const user = {
|
|
|
|
username: 'user_1',
|
|
|
|
password: 'super password'
|
|
|
|
}
|
2019-04-15 03:49:46 -05:00
|
|
|
await createUser({
|
2020-01-31 09:56:52 -06:00
|
|
|
url: servers[0].url,
|
|
|
|
accessToken: servers[0].accessToken,
|
2019-04-15 03:49:46 -05:00
|
|
|
username: user.username,
|
|
|
|
password: user.password,
|
|
|
|
videoQuota: 10 * 1000 * 1000
|
|
|
|
})
|
2018-12-26 03:36:24 -06:00
|
|
|
userAccessToken = await userLogin(servers[0], user)
|
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
await updateMyNotificationSettings(servers[0].url, userAccessToken, allNotificationSettings)
|
|
|
|
await updateMyNotificationSettings(servers[0].url, servers[0].accessToken, allNotificationSettings)
|
|
|
|
await updateMyNotificationSettings(servers[1].url, servers[1].accessToken, allNotificationSettings)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
{
|
2020-01-31 09:56:52 -06:00
|
|
|
const socket = getUserNotificationSocket(servers[0].url, userAccessToken)
|
2018-12-26 03:36:24 -06:00
|
|
|
socket.on('new-notification', n => userNotifications.push(n))
|
|
|
|
}
|
|
|
|
{
|
2020-01-31 09:56:52 -06:00
|
|
|
const socket = getUserNotificationSocket(servers[0].url, servers[0].accessToken)
|
2018-12-26 03:36:24 -06:00
|
|
|
socket.on('new-notification', n => adminNotifications.push(n))
|
|
|
|
}
|
2019-01-02 09:37:43 -06:00
|
|
|
{
|
2020-01-31 09:56:52 -06:00
|
|
|
const socket = getUserNotificationSocket(servers[1].url, servers[1].accessToken)
|
2019-01-02 09:37:43 -06:00
|
|
|
socket.on('new-notification', n => adminNotificationsServer2.push(n))
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const resChannel = await getMyUserInformation(servers[0].url, servers[0].accessToken)
|
|
|
|
channelId = resChannel.body.videoChannels[0].id
|
|
|
|
}
|
2018-12-26 03:36:24 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
describe('New video from my subscription notification', function () {
|
|
|
|
let baseParams: CheckerBaseParams
|
|
|
|
|
|
|
|
before(() => {
|
|
|
|
baseParams = {
|
|
|
|
server: servers[0],
|
|
|
|
emails,
|
|
|
|
socketNotifications: userNotifications,
|
|
|
|
token: userAccessToken
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should not send notifications if the user does not follow the video publisher', async function () {
|
2019-02-06 05:14:45 -06:00
|
|
|
this.timeout(10000)
|
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
await uploadVideoByLocalAccount(servers)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
const notification = await getLastNotification(servers[0].url, userAccessToken)
|
2018-12-26 03:36:24 -06:00
|
|
|
expect(notification).to.be.undefined
|
|
|
|
|
|
|
|
expect(emails).to.have.lengthOf(0)
|
|
|
|
expect(userNotifications).to.have.lengthOf(0)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a new video notification if the user follows the local video publisher', async function () {
|
2019-01-08 08:51:52 -06:00
|
|
|
this.timeout(15000)
|
2019-01-08 04:26:41 -06:00
|
|
|
|
2019-04-25 10:14:49 -05:00
|
|
|
await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:' + servers[0].port)
|
2019-01-08 04:26:41 -06:00
|
|
|
await waitJobs(servers)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
const { name, uuid } = await uploadVideoByLocalAccount(servers)
|
|
|
|
await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
|
2018-12-26 03:36:24 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a new video notification from a remote account', async function () {
|
|
|
|
this.timeout(50000) // Server 2 has transcoding enabled
|
|
|
|
|
2019-04-25 10:14:49 -05:00
|
|
|
await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:' + servers[1].port)
|
2019-01-08 04:26:41 -06:00
|
|
|
await waitJobs(servers)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
const { name, uuid } = await uploadVideoByRemoteAccount(servers)
|
|
|
|
await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
|
2018-12-26 03:36:24 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a new video notification on a scheduled publication', async function () {
|
|
|
|
this.timeout(20000)
|
|
|
|
|
|
|
|
// In 2 seconds
|
2020-01-31 09:56:52 -06:00
|
|
|
const updateAt = new Date(new Date().getTime() + 2000)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
const data = {
|
|
|
|
privacy: VideoPrivacy.PRIVATE,
|
|
|
|
scheduleUpdate: {
|
|
|
|
updateAt: updateAt.toISOString(),
|
|
|
|
privacy: VideoPrivacy.PUBLIC
|
|
|
|
}
|
|
|
|
}
|
2019-01-02 09:37:43 -06:00
|
|
|
const { name, uuid } = await uploadVideoByLocalAccount(servers, data)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
await wait(6000)
|
2019-01-02 09:37:43 -06:00
|
|
|
await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
|
2018-12-26 03:36:24 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a new video notification on a remote scheduled publication', async function () {
|
2019-03-18 04:26:53 -05:00
|
|
|
this.timeout(50000)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
// In 2 seconds
|
2020-01-31 09:56:52 -06:00
|
|
|
const updateAt = new Date(new Date().getTime() + 2000)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
const data = {
|
|
|
|
privacy: VideoPrivacy.PRIVATE,
|
|
|
|
scheduleUpdate: {
|
|
|
|
updateAt: updateAt.toISOString(),
|
|
|
|
privacy: VideoPrivacy.PUBLIC
|
|
|
|
}
|
|
|
|
}
|
2019-01-02 09:37:43 -06:00
|
|
|
const { name, uuid } = await uploadVideoByRemoteAccount(servers, data)
|
2018-12-28 06:47:17 -06:00
|
|
|
await waitJobs(servers)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
await wait(6000)
|
2019-01-02 09:37:43 -06:00
|
|
|
await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
|
2018-12-26 03:36:24 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should not send a notification before the video is published', async function () {
|
|
|
|
this.timeout(20000)
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
const updateAt = new Date(new Date().getTime() + 1000000)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
const data = {
|
|
|
|
privacy: VideoPrivacy.PRIVATE,
|
|
|
|
scheduleUpdate: {
|
|
|
|
updateAt: updateAt.toISOString(),
|
|
|
|
privacy: VideoPrivacy.PUBLIC
|
|
|
|
}
|
|
|
|
}
|
2019-01-02 09:37:43 -06:00
|
|
|
const { name, uuid } = await uploadVideoByLocalAccount(servers, data)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
await wait(6000)
|
2019-01-02 09:37:43 -06:00
|
|
|
await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
|
2018-12-26 03:36:24 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a new video notification when a video becomes public', async function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
|
|
|
const data = { privacy: VideoPrivacy.PRIVATE }
|
2019-01-02 09:37:43 -06:00
|
|
|
const { name, uuid } = await uploadVideoByLocalAccount(servers, data)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
await updateVideo(servers[0].url, servers[0].accessToken, uuid, { privacy: VideoPrivacy.PUBLIC })
|
|
|
|
|
|
|
|
await wait(500)
|
2019-01-02 09:37:43 -06:00
|
|
|
await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
|
2018-12-26 03:36:24 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a new video notification when a remote video becomes public', async function () {
|
|
|
|
this.timeout(20000)
|
|
|
|
|
|
|
|
const data = { privacy: VideoPrivacy.PRIVATE }
|
2019-01-02 09:37:43 -06:00
|
|
|
const { name, uuid } = await uploadVideoByRemoteAccount(servers, data)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
await updateVideo(servers[1].url, servers[1].accessToken, uuid, { privacy: VideoPrivacy.PUBLIC })
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
2019-01-02 09:37:43 -06:00
|
|
|
await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
|
2018-12-26 03:36:24 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should not send a new video notification when a video becomes unlisted', async function () {
|
|
|
|
this.timeout(20000)
|
|
|
|
|
|
|
|
const data = { privacy: VideoPrivacy.PRIVATE }
|
2019-01-02 09:37:43 -06:00
|
|
|
const { name, uuid } = await uploadVideoByLocalAccount(servers, data)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
await updateVideo(servers[0].url, servers[0].accessToken, uuid, { privacy: VideoPrivacy.UNLISTED })
|
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
|
2018-12-26 03:36:24 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should not send a new video notification when a remote video becomes unlisted', async function () {
|
|
|
|
this.timeout(20000)
|
|
|
|
|
|
|
|
const data = { privacy: VideoPrivacy.PRIVATE }
|
2019-01-02 09:37:43 -06:00
|
|
|
const { name, uuid } = await uploadVideoByRemoteAccount(servers, data)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
await updateVideo(servers[1].url, servers[1].accessToken, uuid, { privacy: VideoPrivacy.UNLISTED })
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
2019-01-02 09:37:43 -06:00
|
|
|
await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
|
2018-12-26 03:36:24 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a new video notification after a video import', async function () {
|
2019-04-02 04:26:47 -05:00
|
|
|
this.timeout(100000)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
const name = 'video import ' + uuidv4()
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
const attributes = {
|
2019-01-02 09:37:43 -06:00
|
|
|
name,
|
2018-12-26 03:36:24 -06:00
|
|
|
channelId,
|
|
|
|
privacy: VideoPrivacy.PUBLIC,
|
|
|
|
targetUrl: getYoutubeVideoUrl()
|
|
|
|
}
|
|
|
|
const res = await importVideo(servers[0].url, servers[0].accessToken, attributes)
|
|
|
|
const uuid = res.body.video.uuid
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
|
2018-12-26 03:36:24 -06:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('Comment on my video notifications', function () {
|
|
|
|
let baseParams: CheckerBaseParams
|
|
|
|
|
|
|
|
before(() => {
|
|
|
|
baseParams = {
|
|
|
|
server: servers[0],
|
|
|
|
emails,
|
|
|
|
socketNotifications: userNotifications,
|
|
|
|
token: userAccessToken
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should not send a new comment notification after a comment on another video', async function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
|
|
|
const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' })
|
|
|
|
const uuid = resVideo.body.video.uuid
|
|
|
|
|
|
|
|
const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment')
|
|
|
|
const commentId = resComment.body.comment.id
|
|
|
|
|
|
|
|
await wait(500)
|
|
|
|
await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should not send a new comment notification if I comment my own video', async function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
|
|
|
const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' })
|
|
|
|
const uuid = resVideo.body.video.uuid
|
|
|
|
|
|
|
|
const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, uuid, 'comment')
|
|
|
|
const commentId = resComment.body.comment.id
|
|
|
|
|
|
|
|
await wait(500)
|
|
|
|
await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence')
|
|
|
|
})
|
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
it('Should not send a new comment notification if the account is muted', async function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
await addAccountToAccountBlocklist(servers[0].url, userAccessToken, 'root')
|
2019-01-02 09:37:43 -06:00
|
|
|
|
|
|
|
const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' })
|
|
|
|
const uuid = resVideo.body.video.uuid
|
|
|
|
|
|
|
|
const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment')
|
|
|
|
const commentId = resComment.body.comment.id
|
|
|
|
|
|
|
|
await wait(500)
|
|
|
|
await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence')
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
await removeAccountFromAccountBlocklist(servers[0].url, userAccessToken, 'root')
|
2019-01-02 09:37:43 -06:00
|
|
|
})
|
|
|
|
|
2018-12-26 03:36:24 -06:00
|
|
|
it('Should send a new comment notification after a local comment on my video', async function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
|
|
|
const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' })
|
|
|
|
const uuid = resVideo.body.video.uuid
|
|
|
|
|
|
|
|
const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment')
|
|
|
|
const commentId = resComment.body.comment.id
|
|
|
|
|
|
|
|
await wait(500)
|
|
|
|
await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'presence')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a new comment notification after a remote comment on my video', async function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
|
|
|
const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' })
|
|
|
|
const uuid = resVideo.body.video.uuid
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
2019-04-03 03:26:03 -05:00
|
|
|
await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, 'comment')
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
await waitJobs(servers)
|
2019-04-03 03:26:03 -05:00
|
|
|
|
|
|
|
const resComment = await getVideoCommentThreads(servers[0].url, uuid, 0, 5)
|
|
|
|
expect(resComment.body.data).to.have.lengthOf(1)
|
|
|
|
const commentId = resComment.body.data[0].id
|
|
|
|
|
2018-12-26 03:36:24 -06:00
|
|
|
await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'presence')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a new comment notification after a local reply on my video', async function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
|
|
|
const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' })
|
|
|
|
const uuid = resVideo.body.video.uuid
|
|
|
|
|
|
|
|
const resThread = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment')
|
|
|
|
const threadId = resThread.body.comment.id
|
|
|
|
|
|
|
|
const resComment = await addVideoCommentReply(servers[0].url, servers[0].accessToken, uuid, threadId, 'reply')
|
|
|
|
const commentId = resComment.body.comment.id
|
|
|
|
|
|
|
|
await wait(500)
|
|
|
|
await checkNewCommentOnMyVideo(baseParams, uuid, commentId, threadId, 'presence')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a new comment notification after a remote reply on my video', async function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
|
|
|
const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' })
|
|
|
|
const uuid = resVideo.body.video.uuid
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
2019-04-03 03:26:03 -05:00
|
|
|
{
|
2020-01-31 09:56:52 -06:00
|
|
|
const resThread = await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, 'comment')
|
2019-04-03 03:26:03 -05:00
|
|
|
const threadId = resThread.body.comment.id
|
2020-01-31 09:56:52 -06:00
|
|
|
await addVideoCommentReply(servers[1].url, servers[1].accessToken, uuid, threadId, 'reply')
|
2019-04-03 03:26:03 -05:00
|
|
|
}
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
await waitJobs(servers)
|
2019-04-03 03:26:03 -05:00
|
|
|
|
|
|
|
const resThread = await getVideoCommentThreads(servers[0].url, uuid, 0, 5)
|
|
|
|
expect(resThread.body.data).to.have.lengthOf(1)
|
|
|
|
const threadId = resThread.body.data[0].id
|
|
|
|
|
|
|
|
const resComments = await getVideoThreadComments(servers[0].url, uuid, threadId)
|
|
|
|
const tree = resComments.body as VideoCommentThreadTree
|
|
|
|
|
|
|
|
expect(tree.children).to.have.lengthOf(1)
|
|
|
|
const commentId = tree.children[0].comment.id
|
|
|
|
|
2018-12-26 03:36:24 -06:00
|
|
|
await checkNewCommentOnMyVideo(baseParams, uuid, commentId, threadId, 'presence')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2019-01-04 01:56:20 -06:00
|
|
|
describe('Mention notifications', function () {
|
|
|
|
let baseParams: CheckerBaseParams
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
baseParams = {
|
|
|
|
server: servers[0],
|
|
|
|
emails,
|
|
|
|
socketNotifications: userNotifications,
|
|
|
|
token: userAccessToken
|
|
|
|
}
|
|
|
|
|
|
|
|
await updateMyUser({
|
|
|
|
url: servers[0].url,
|
|
|
|
accessToken: servers[0].accessToken,
|
|
|
|
displayName: 'super root name'
|
|
|
|
})
|
|
|
|
|
|
|
|
await updateMyUser({
|
|
|
|
url: servers[1].url,
|
|
|
|
accessToken: servers[1].accessToken,
|
|
|
|
displayName: 'super root 2 name'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should not send a new mention comment notification if I mention the video owner', async function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
|
|
|
const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' })
|
|
|
|
const uuid = resVideo.body.video.uuid
|
|
|
|
|
|
|
|
const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello')
|
|
|
|
const commentId = resComment.body.comment.id
|
|
|
|
|
|
|
|
await wait(500)
|
|
|
|
await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should not send a new mention comment notification if I mention myself', async function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
|
|
|
const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' })
|
|
|
|
const uuid = resVideo.body.video.uuid
|
|
|
|
|
|
|
|
const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, uuid, '@user_1 hello')
|
|
|
|
const commentId = resComment.body.comment.id
|
|
|
|
|
|
|
|
await wait(500)
|
|
|
|
await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should not send a new mention notification if the account is muted', async function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
await addAccountToAccountBlocklist(servers[0].url, userAccessToken, 'root')
|
2019-01-04 01:56:20 -06:00
|
|
|
|
|
|
|
const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' })
|
|
|
|
const uuid = resVideo.body.video.uuid
|
|
|
|
|
|
|
|
const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello')
|
|
|
|
const commentId = resComment.body.comment.id
|
|
|
|
|
|
|
|
await wait(500)
|
|
|
|
await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
await removeAccountFromAccountBlocklist(servers[0].url, userAccessToken, 'root')
|
2019-01-04 01:56:20 -06:00
|
|
|
})
|
|
|
|
|
2019-02-14 04:04:50 -06:00
|
|
|
it('Should not send a new mention notification if the remote account mention a local account', async function () {
|
|
|
|
this.timeout(20000)
|
|
|
|
|
|
|
|
const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' })
|
|
|
|
const uuid = resVideo.body.video.uuid
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
|
|
|
const resThread = await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, '@user_1 hello')
|
|
|
|
const threadId = resThread.body.comment.id
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
|
|
|
await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root 2 name', 'absence')
|
|
|
|
})
|
|
|
|
|
2019-01-04 01:56:20 -06:00
|
|
|
it('Should send a new mention notification after local comments', async function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
|
|
|
const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' })
|
|
|
|
const uuid = resVideo.body.video.uuid
|
|
|
|
|
|
|
|
const resThread = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello 1')
|
|
|
|
const threadId = resThread.body.comment.id
|
|
|
|
|
|
|
|
await wait(500)
|
|
|
|
await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root name', 'presence')
|
|
|
|
|
|
|
|
const resComment = await addVideoCommentReply(servers[0].url, servers[0].accessToken, uuid, threadId, 'hello 2 @user_1')
|
|
|
|
const commentId = resComment.body.comment.id
|
|
|
|
|
|
|
|
await wait(500)
|
|
|
|
await checkCommentMention(baseParams, uuid, commentId, threadId, 'super root name', 'presence')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a new mention notification after remote comments', async function () {
|
|
|
|
this.timeout(20000)
|
|
|
|
|
|
|
|
const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' })
|
|
|
|
const uuid = resVideo.body.video.uuid
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
2019-04-25 10:14:49 -05:00
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
const text1 = `hello @user_1@localhost:${servers[0].port} 1`
|
2019-04-25 10:14:49 -05:00
|
|
|
const resThread = await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, text1)
|
2019-04-03 03:26:03 -05:00
|
|
|
const server2ThreadId = resThread.body.comment.id
|
2019-01-04 01:56:20 -06:00
|
|
|
|
|
|
|
await waitJobs(servers)
|
2019-04-03 03:26:03 -05:00
|
|
|
|
|
|
|
const resThread2 = await getVideoCommentThreads(servers[0].url, uuid, 0, 5)
|
|
|
|
expect(resThread2.body.data).to.have.lengthOf(1)
|
|
|
|
const server1ThreadId = resThread2.body.data[0].id
|
|
|
|
await checkCommentMention(baseParams, uuid, server1ThreadId, server1ThreadId, 'super root 2 name', 'presence')
|
2019-01-04 01:56:20 -06:00
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
const text2 = `@user_1@localhost:${servers[0].port} hello 2 @root@localhost:${servers[0].port}`
|
2019-04-25 10:14:49 -05:00
|
|
|
await addVideoCommentReply(servers[1].url, servers[1].accessToken, uuid, server2ThreadId, text2)
|
2019-01-04 01:56:20 -06:00
|
|
|
|
|
|
|
await waitJobs(servers)
|
2019-04-03 03:26:03 -05:00
|
|
|
|
|
|
|
const resComments = await getVideoThreadComments(servers[0].url, uuid, server1ThreadId)
|
|
|
|
const tree = resComments.body as VideoCommentThreadTree
|
|
|
|
|
|
|
|
expect(tree.children).to.have.lengthOf(1)
|
|
|
|
const commentId = tree.children[0].comment.id
|
|
|
|
|
|
|
|
await checkCommentMention(baseParams, uuid, commentId, server1ThreadId, 'super root 2 name', 'presence')
|
2019-01-04 01:56:20 -06:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
describe('Video abuse for moderators notification', function () {
|
2018-12-26 03:36:24 -06:00
|
|
|
let baseParams: CheckerBaseParams
|
|
|
|
|
|
|
|
before(() => {
|
|
|
|
baseParams = {
|
|
|
|
server: servers[0],
|
|
|
|
emails,
|
|
|
|
socketNotifications: adminNotifications,
|
|
|
|
token: servers[0].accessToken
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a notification to moderators on local video abuse', async function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
const name = 'video for abuse ' + uuidv4()
|
|
|
|
const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name })
|
2018-12-26 03:36:24 -06:00
|
|
|
const uuid = resVideo.body.video.uuid
|
|
|
|
|
|
|
|
await reportVideoAbuse(servers[0].url, servers[0].accessToken, uuid, 'super reason')
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
2019-01-02 09:37:43 -06:00
|
|
|
await checkNewVideoAbuseForModerators(baseParams, uuid, name, 'presence')
|
2018-12-26 03:36:24 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a notification to moderators on remote video abuse', async function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
const name = 'video for abuse ' + uuidv4()
|
|
|
|
const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name })
|
2018-12-26 03:36:24 -06:00
|
|
|
const uuid = resVideo.body.video.uuid
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
|
|
|
await reportVideoAbuse(servers[1].url, servers[1].accessToken, uuid, 'super reason')
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
2019-01-02 09:37:43 -06:00
|
|
|
await checkNewVideoAbuseForModerators(baseParams, uuid, name, 'presence')
|
2018-12-26 03:36:24 -06:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('Video blacklist on my video', function () {
|
|
|
|
let baseParams: CheckerBaseParams
|
|
|
|
|
|
|
|
before(() => {
|
|
|
|
baseParams = {
|
|
|
|
server: servers[0],
|
|
|
|
emails,
|
|
|
|
socketNotifications: userNotifications,
|
|
|
|
token: userAccessToken
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a notification to video owner on blacklist', async function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
const name = 'video for abuse ' + uuidv4()
|
|
|
|
const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name })
|
2018-12-26 03:36:24 -06:00
|
|
|
const uuid = resVideo.body.video.uuid
|
|
|
|
|
|
|
|
await addVideoToBlacklist(servers[0].url, servers[0].accessToken, uuid)
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
2019-01-02 09:37:43 -06:00
|
|
|
await checkNewBlacklistOnMyVideo(baseParams, uuid, name, 'blacklist')
|
2018-12-26 03:36:24 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a notification to video owner on unblacklist', async function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
const name = 'video for abuse ' + uuidv4()
|
|
|
|
const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name })
|
2018-12-26 03:36:24 -06:00
|
|
|
const uuid = resVideo.body.video.uuid
|
|
|
|
|
|
|
|
await addVideoToBlacklist(servers[0].url, servers[0].accessToken, uuid)
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
|
|
|
await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, uuid)
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
|
|
|
await wait(500)
|
2019-01-02 09:37:43 -06:00
|
|
|
await checkNewBlacklistOnMyVideo(baseParams, uuid, name, 'unblacklist')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('My video is published', function () {
|
|
|
|
let baseParams: CheckerBaseParams
|
|
|
|
|
|
|
|
before(() => {
|
|
|
|
baseParams = {
|
|
|
|
server: servers[1],
|
|
|
|
emails,
|
|
|
|
socketNotifications: adminNotificationsServer2,
|
|
|
|
token: servers[1].accessToken
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should not send a notification if transcoding is not enabled', async function () {
|
2019-02-06 05:14:45 -06:00
|
|
|
this.timeout(10000)
|
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
const { name, uuid } = await uploadVideoByLocalAccount(servers)
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
|
|
|
await checkVideoIsPublished(baseParams, name, uuid, 'absence')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should not send a notification if the wait transcoding is false', async function () {
|
|
|
|
this.timeout(50000)
|
|
|
|
|
|
|
|
await uploadVideoByRemoteAccount(servers, { waitTranscoding: false })
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
const notification = await getLastNotification(servers[0].url, userAccessToken)
|
2019-01-02 09:37:43 -06:00
|
|
|
if (notification) {
|
|
|
|
expect(notification.type).to.not.equal(UserNotificationType.MY_VIDEO_PUBLISHED)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a notification even if the video is not transcoded in other resolutions', async function () {
|
|
|
|
this.timeout(50000)
|
|
|
|
|
|
|
|
const { name, uuid } = await uploadVideoByRemoteAccount(servers, { waitTranscoding: true, fixture: 'video_short_240p.mp4' })
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
|
|
|
await checkVideoIsPublished(baseParams, name, uuid, 'presence')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a notification with a transcoded video', async function () {
|
|
|
|
this.timeout(50000)
|
|
|
|
|
|
|
|
const { name, uuid } = await uploadVideoByRemoteAccount(servers, { waitTranscoding: true })
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
|
|
|
await checkVideoIsPublished(baseParams, name, uuid, 'presence')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a notification when an imported video is transcoded', async function () {
|
|
|
|
this.timeout(50000)
|
|
|
|
|
|
|
|
const name = 'video import ' + uuidv4()
|
|
|
|
|
|
|
|
const attributes = {
|
|
|
|
name,
|
|
|
|
channelId,
|
|
|
|
privacy: VideoPrivacy.PUBLIC,
|
|
|
|
targetUrl: getYoutubeVideoUrl(),
|
|
|
|
waitTranscoding: true
|
|
|
|
}
|
|
|
|
const res = await importVideo(servers[1].url, servers[1].accessToken, attributes)
|
|
|
|
const uuid = res.body.video.uuid
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
|
|
|
await checkVideoIsPublished(baseParams, name, uuid, 'presence')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a notification when the scheduled update has been proceeded', async function () {
|
|
|
|
this.timeout(70000)
|
|
|
|
|
|
|
|
// In 2 seconds
|
2020-01-31 09:56:52 -06:00
|
|
|
const updateAt = new Date(new Date().getTime() + 2000)
|
2019-01-02 09:37:43 -06:00
|
|
|
|
|
|
|
const data = {
|
|
|
|
privacy: VideoPrivacy.PRIVATE,
|
|
|
|
scheduleUpdate: {
|
|
|
|
updateAt: updateAt.toISOString(),
|
|
|
|
privacy: VideoPrivacy.PUBLIC
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const { name, uuid } = await uploadVideoByRemoteAccount(servers, data)
|
|
|
|
|
|
|
|
await wait(6000)
|
|
|
|
await checkVideoIsPublished(baseParams, name, uuid, 'presence')
|
|
|
|
})
|
2019-02-06 05:14:45 -06:00
|
|
|
|
|
|
|
it('Should not send a notification before the video is published', async function () {
|
|
|
|
this.timeout(20000)
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
const updateAt = new Date(new Date().getTime() + 1000000)
|
2019-02-06 05:14:45 -06:00
|
|
|
|
|
|
|
const data = {
|
|
|
|
privacy: VideoPrivacy.PRIVATE,
|
|
|
|
scheduleUpdate: {
|
|
|
|
updateAt: updateAt.toISOString(),
|
|
|
|
privacy: VideoPrivacy.PUBLIC
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const { name, uuid } = await uploadVideoByRemoteAccount(servers, data)
|
|
|
|
|
|
|
|
await wait(6000)
|
|
|
|
await checkVideoIsPublished(baseParams, name, uuid, 'absence')
|
|
|
|
})
|
2019-01-02 09:37:43 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
describe('My video is imported', function () {
|
|
|
|
let baseParams: CheckerBaseParams
|
|
|
|
|
|
|
|
before(() => {
|
|
|
|
baseParams = {
|
|
|
|
server: servers[0],
|
|
|
|
emails,
|
|
|
|
socketNotifications: adminNotifications,
|
|
|
|
token: servers[0].accessToken
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a notification when the video import failed', async function () {
|
|
|
|
this.timeout(70000)
|
|
|
|
|
|
|
|
const name = 'video import ' + uuidv4()
|
|
|
|
|
|
|
|
const attributes = {
|
|
|
|
name,
|
|
|
|
channelId,
|
|
|
|
privacy: VideoPrivacy.PRIVATE,
|
|
|
|
targetUrl: getBadVideoUrl()
|
|
|
|
}
|
|
|
|
const res = await importVideo(servers[0].url, servers[0].accessToken, attributes)
|
|
|
|
const uuid = res.body.video.uuid
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
|
|
|
await checkMyVideoImportIsFinished(baseParams, name, uuid, getBadVideoUrl(), false, 'presence')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a notification when the video import succeeded', async function () {
|
|
|
|
this.timeout(70000)
|
|
|
|
|
|
|
|
const name = 'video import ' + uuidv4()
|
|
|
|
|
|
|
|
const attributes = {
|
|
|
|
name,
|
|
|
|
channelId,
|
|
|
|
privacy: VideoPrivacy.PRIVATE,
|
|
|
|
targetUrl: getYoutubeVideoUrl()
|
|
|
|
}
|
|
|
|
const res = await importVideo(servers[0].url, servers[0].accessToken, attributes)
|
|
|
|
const uuid = res.body.video.uuid
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
|
|
|
await checkMyVideoImportIsFinished(baseParams, name, uuid, getYoutubeVideoUrl(), true, 'presence')
|
2018-12-26 03:36:24 -06:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2019-01-04 01:56:20 -06:00
|
|
|
describe('New registration', function () {
|
|
|
|
let baseParams: CheckerBaseParams
|
|
|
|
|
|
|
|
before(() => {
|
|
|
|
baseParams = {
|
|
|
|
server: servers[0],
|
|
|
|
emails,
|
|
|
|
socketNotifications: adminNotifications,
|
|
|
|
token: servers[0].accessToken
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a notification only to moderators when a user registers on the instance', async function () {
|
2019-02-06 05:14:45 -06:00
|
|
|
this.timeout(10000)
|
|
|
|
|
2019-01-04 01:56:20 -06:00
|
|
|
await registerUser(servers[0].url, 'user_45', 'password')
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
|
|
|
await checkUserRegistered(baseParams, 'user_45', 'presence')
|
|
|
|
|
|
|
|
const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }
|
|
|
|
await checkUserRegistered(immutableAssign(baseParams, userOverride), 'user_45', 'absence')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2019-09-04 04:39:25 -05:00
|
|
|
describe('New instance follows', function () {
|
|
|
|
const instanceIndexServer = new MockInstancesIndex()
|
|
|
|
const config = {
|
|
|
|
followings: {
|
|
|
|
instance: {
|
|
|
|
autoFollowIndex: {
|
|
|
|
indexUrl: 'http://localhost:42100',
|
|
|
|
enabled: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-08 10:26:01 -05:00
|
|
|
let baseParams: CheckerBaseParams
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
baseParams = {
|
|
|
|
server: servers[0],
|
|
|
|
emails,
|
|
|
|
socketNotifications: adminNotifications,
|
|
|
|
token: servers[0].accessToken
|
|
|
|
}
|
2019-09-04 04:39:25 -05:00
|
|
|
|
|
|
|
await instanceIndexServer.initialize()
|
|
|
|
instanceIndexServer.addInstance(servers[1].host)
|
2019-04-08 10:26:01 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a notification only to admin when there is a new instance follower', async function () {
|
2019-04-25 07:23:15 -05:00
|
|
|
this.timeout(20000)
|
2019-04-08 10:26:01 -05:00
|
|
|
|
|
|
|
await follow(servers[2].url, [ servers[0].url ], servers[2].accessToken)
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
2019-04-25 10:14:49 -05:00
|
|
|
await checkNewInstanceFollower(baseParams, 'localhost:' + servers[2].port, 'presence')
|
2019-04-08 10:26:01 -05:00
|
|
|
|
|
|
|
const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }
|
2019-04-25 10:14:49 -05:00
|
|
|
await checkNewInstanceFollower(immutableAssign(baseParams, userOverride), 'localhost:' + servers[2].port, 'absence')
|
2019-04-08 10:26:01 -05:00
|
|
|
})
|
2019-08-30 09:50:12 -05:00
|
|
|
|
|
|
|
it('Should send a notification on auto follow back', async function () {
|
|
|
|
this.timeout(40000)
|
|
|
|
|
|
|
|
await unfollow(servers[2].url, servers[2].accessToken, servers[0])
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
|
|
|
const config = {
|
|
|
|
followings: {
|
|
|
|
instance: {
|
|
|
|
autoFollowBack: { enabled: true }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
|
|
|
|
|
|
|
|
await follow(servers[2].url, [ servers[0].url ], servers[2].accessToken)
|
|
|
|
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
|
|
|
const followerHost = servers[0].host
|
|
|
|
const followingHost = servers[2].host
|
|
|
|
await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence')
|
|
|
|
|
|
|
|
const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }
|
|
|
|
await checkAutoInstanceFollowing(immutableAssign(baseParams, userOverride), followerHost, followingHost, 'absence')
|
|
|
|
|
|
|
|
config.followings.instance.autoFollowBack.enabled = false
|
|
|
|
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
|
2019-09-04 04:39:25 -05:00
|
|
|
await unfollow(servers[0].url, servers[0].accessToken, servers[2])
|
|
|
|
await unfollow(servers[2].url, servers[2].accessToken, servers[0])
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should send a notification on auto instances index follow', async function () {
|
|
|
|
this.timeout(30000)
|
|
|
|
await unfollow(servers[0].url, servers[0].accessToken, servers[1])
|
|
|
|
|
|
|
|
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
|
|
|
|
|
|
|
|
await wait(5000)
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
|
|
|
const followerHost = servers[0].host
|
|
|
|
const followingHost = servers[1].host
|
|
|
|
await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence')
|
|
|
|
|
|
|
|
config.followings.instance.autoFollowIndex.enabled = false
|
|
|
|
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
|
|
|
|
await unfollow(servers[0].url, servers[0].accessToken, servers[1])
|
2019-08-30 09:50:12 -05:00
|
|
|
})
|
2019-04-08 10:26:01 -05:00
|
|
|
})
|
|
|
|
|
2019-01-04 01:56:20 -06:00
|
|
|
describe('New actor follow', function () {
|
|
|
|
let baseParams: CheckerBaseParams
|
2020-01-31 09:56:52 -06:00
|
|
|
const myChannelName = 'super channel name'
|
|
|
|
const myUserName = 'super user name'
|
2019-01-04 01:56:20 -06:00
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
baseParams = {
|
|
|
|
server: servers[0],
|
|
|
|
emails,
|
|
|
|
socketNotifications: userNotifications,
|
|
|
|
token: userAccessToken
|
|
|
|
}
|
|
|
|
|
|
|
|
await updateMyUser({
|
|
|
|
url: servers[0].url,
|
|
|
|
accessToken: servers[0].accessToken,
|
|
|
|
displayName: 'super root name'
|
|
|
|
})
|
|
|
|
|
|
|
|
await updateMyUser({
|
|
|
|
url: servers[0].url,
|
|
|
|
accessToken: userAccessToken,
|
|
|
|
displayName: myUserName
|
|
|
|
})
|
|
|
|
|
|
|
|
await updateMyUser({
|
|
|
|
url: servers[1].url,
|
|
|
|
accessToken: servers[1].accessToken,
|
|
|
|
displayName: 'super root 2 name'
|
|
|
|
})
|
|
|
|
|
|
|
|
await updateVideoChannel(servers[0].url, userAccessToken, 'user_1_channel', { displayName: myChannelName })
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should notify when a local channel is following one of our channel', async function () {
|
2019-01-08 04:26:41 -06:00
|
|
|
this.timeout(10000)
|
2019-01-04 01:56:20 -06:00
|
|
|
|
2019-04-25 10:14:49 -05:00
|
|
|
await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port)
|
2019-01-04 01:56:20 -06:00
|
|
|
await waitJobs(servers)
|
|
|
|
|
|
|
|
await checkNewActorFollow(baseParams, 'channel', 'root', 'super root name', myChannelName, 'presence')
|
|
|
|
|
2019-04-25 10:14:49 -05:00
|
|
|
await removeUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port)
|
2019-01-04 01:56:20 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should notify when a remote channel is following one of our channel', async function () {
|
2019-01-08 04:26:41 -06:00
|
|
|
this.timeout(10000)
|
2019-01-04 01:56:20 -06:00
|
|
|
|
2019-04-25 10:14:49 -05:00
|
|
|
await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port)
|
2019-01-04 01:56:20 -06:00
|
|
|
await waitJobs(servers)
|
|
|
|
|
|
|
|
await checkNewActorFollow(baseParams, 'channel', 'root', 'super root 2 name', myChannelName, 'presence')
|
|
|
|
|
2019-04-25 10:14:49 -05:00
|
|
|
await removeUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port)
|
2019-01-04 01:56:20 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should notify when a local account is following one of our channel', async function () {
|
2019-02-06 05:14:45 -06:00
|
|
|
this.timeout(10000)
|
|
|
|
|
2019-04-25 10:14:49 -05:00
|
|
|
await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1@localhost:' + servers[0].port)
|
2019-01-04 01:56:20 -06:00
|
|
|
|
|
|
|
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 () {
|
2019-02-06 05:14:45 -06:00
|
|
|
this.timeout(10000)
|
|
|
|
|
2019-04-25 10:14:49 -05:00
|
|
|
await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1@localhost:' + servers[0].port)
|
2019-01-04 01:56:20 -06:00
|
|
|
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
|
|
|
await checkNewActorFollow(baseParams, 'account', 'root', 'super root 2 name', myUserName, 'presence')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2019-04-02 04:26:47 -05:00
|
|
|
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)
|
|
|
|
|
2019-04-25 10:14:49 -05:00
|
|
|
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)
|
2019-04-02 04:26:47 -05:00
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
const updateAt = new Date(new Date().getTime() + 1000000)
|
2019-04-02 04:26:47 -05:00
|
|
|
|
|
|
|
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
|
2020-01-31 09:56:52 -06:00
|
|
|
const updateAt = new Date(new Date().getTime() + 2000)
|
2019-04-02 04:26:47 -05:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2019-04-25 10:14:49 -05:00
|
|
|
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)
|
2019-04-02 04:26:47 -05:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2018-12-26 03:36:24 -06:00
|
|
|
describe('Mark as read', function () {
|
|
|
|
it('Should mark as read some notifications', async function () {
|
2020-01-31 09:56:52 -06:00
|
|
|
const res = await getUserNotifications(servers[0].url, userAccessToken, 2, 3)
|
2018-12-26 03:36:24 -06:00
|
|
|
const ids = res.body.data.map(n => n.id)
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
await markAsReadNotifications(servers[0].url, userAccessToken, ids)
|
2018-12-26 03:36:24 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should have the notifications marked as read', async function () {
|
2020-01-31 09:56:52 -06:00
|
|
|
const res = await getUserNotifications(servers[0].url, userAccessToken, 0, 10)
|
2019-01-02 09:37:43 -06:00
|
|
|
|
|
|
|
const notifications = res.body.data as UserNotification[]
|
2020-01-31 09:56:52 -06:00
|
|
|
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
|
2019-01-02 09:37:43 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should only list read notifications', async function () {
|
2020-01-31 09:56:52 -06:00
|
|
|
const res = await getUserNotifications(servers[0].url, userAccessToken, 0, 10, false)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
const notifications = res.body.data as UserNotification[]
|
2019-01-02 09:37:43 -06:00
|
|
|
for (const notification of notifications) {
|
|
|
|
expect(notification.read).to.be.true
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should only list unread notifications', async function () {
|
2020-01-31 09:56:52 -06:00
|
|
|
const res = await getUserNotifications(servers[0].url, userAccessToken, 0, 10, true)
|
2019-01-02 09:37:43 -06:00
|
|
|
|
|
|
|
const notifications = res.body.data as UserNotification[]
|
|
|
|
for (const notification of notifications) {
|
|
|
|
expect(notification.read).to.be.false
|
|
|
|
}
|
2018-12-26 03:36:24 -06:00
|
|
|
})
|
2019-01-08 04:26:41 -06:00
|
|
|
|
|
|
|
it('Should mark as read all notifications', async function () {
|
2020-01-31 09:56:52 -06:00
|
|
|
await markAsReadAllNotifications(servers[0].url, userAccessToken)
|
2019-01-08 04:26:41 -06:00
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
const res = await getUserNotifications(servers[0].url, userAccessToken, 0, 10, true)
|
2019-01-08 04:26:41 -06:00
|
|
|
|
|
|
|
expect(res.body.total).to.equal(0)
|
|
|
|
expect(res.body.data).to.have.lengthOf(0)
|
|
|
|
})
|
2018-12-26 03:36:24 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
describe('Notification settings', function () {
|
|
|
|
let baseParams: CheckerBaseParams
|
|
|
|
|
|
|
|
before(() => {
|
|
|
|
baseParams = {
|
|
|
|
server: servers[0],
|
|
|
|
emails,
|
|
|
|
socketNotifications: userNotifications,
|
|
|
|
token: userAccessToken
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should not have notifications', async function () {
|
2019-04-02 04:26:47 -05:00
|
|
|
this.timeout(20000)
|
2019-02-06 05:14:45 -06:00
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, {
|
2018-12-26 03:36:24 -06:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
const { name, uuid } = await uploadVideoByLocalAccount(servers)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
const check = { web: true, mail: true }
|
2019-01-02 09:37:43 -06:00
|
|
|
await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'absence')
|
2018-12-26 03:36:24 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Should only have web notifications', async function () {
|
2019-04-02 04:26:47 -05:00
|
|
|
this.timeout(20000)
|
2019-02-06 05:14:45 -06:00
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, {
|
2019-01-08 04:26:41 -06:00
|
|
|
newVideoFromSubscription: UserNotificationSettingValue.WEB
|
2018-12-26 03:36:24 -06:00
|
|
|
}))
|
|
|
|
|
|
|
|
{
|
|
|
|
const res = await getMyUserInformation(servers[0].url, userAccessToken)
|
|
|
|
const info = res.body as User
|
2019-01-08 04:26:41 -06:00
|
|
|
expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB)
|
2018-12-26 03:36:24 -06:00
|
|
|
}
|
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
const { name, uuid } = await uploadVideoByLocalAccount(servers)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
{
|
|
|
|
const check = { mail: true, web: false }
|
2019-01-02 09:37:43 -06:00
|
|
|
await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'absence')
|
2018-12-26 03:36:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const check = { mail: false, web: true }
|
2019-01-02 09:37:43 -06:00
|
|
|
await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'presence')
|
2018-12-26 03:36:24 -06:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should only have mail notifications', async function () {
|
2019-04-02 04:26:47 -05:00
|
|
|
this.timeout(20000)
|
2019-02-06 05:14:45 -06:00
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, {
|
2018-12-26 03:36:24 -06:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
const { name, uuid } = await uploadVideoByLocalAccount(servers)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
|
|
|
{
|
|
|
|
const check = { mail: false, web: true }
|
2019-01-02 09:37:43 -06:00
|
|
|
await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'absence')
|
2018-12-26 03:36:24 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const check = { mail: true, web: false }
|
2019-01-02 09:37:43 -06:00
|
|
|
await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'presence')
|
2018-12-26 03:36:24 -06:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should have email and web notifications', async function () {
|
2019-04-02 04:26:47 -05:00
|
|
|
this.timeout(20000)
|
2019-02-06 05:14:45 -06:00
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, {
|
2019-01-08 04:26:41 -06:00
|
|
|
newVideoFromSubscription: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL
|
2018-12-26 03:36:24 -06:00
|
|
|
}))
|
|
|
|
|
|
|
|
{
|
|
|
|
const res = await getMyUserInformation(servers[0].url, userAccessToken)
|
|
|
|
const info = res.body as User
|
2019-01-08 04:26:41 -06:00
|
|
|
expect(info.notificationSettings.newVideoFromSubscription).to.equal(
|
|
|
|
UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL
|
|
|
|
)
|
2018-12-26 03:36:24 -06:00
|
|
|
}
|
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
const { name, uuid } = await uploadVideoByLocalAccount(servers)
|
2018-12-26 03:36:24 -06:00
|
|
|
|
2019-01-02 09:37:43 -06:00
|
|
|
await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
|
2018-12-26 03:36:24 -06:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2019-04-24 08:10:37 -05:00
|
|
|
after(async function () {
|
2019-01-08 08:51:52 -06:00
|
|
|
MockSmtpServer.Instance.kill()
|
|
|
|
|
2019-04-24 08:10:37 -05:00
|
|
|
await cleanupTests(servers)
|
2018-12-26 03:36:24 -06:00
|
|
|
})
|
|
|
|
})
|