import 'mocha'
import { buildUUID } from '@server/helpers/uuid'
import {
- addUserSubscription,
- addVideoCommentThread,
- addVideoToBlacklist,
checkAbuseStateChange,
checkAutoInstanceFollowing,
CheckerBaseParams,
checkVideoIsPublished,
cleanupTests,
createUser,
- follow,
generateUserAccessToken,
- getAccount,
- getCustomConfig,
- getVideoCommentThreads,
getVideoIdFromUUID,
- immutableAssign,
MockInstancesIndex,
MockSmtpServer,
prepareNotificationsTest,
registerUser,
- removeUserSubscription,
- removeVideoFromBlacklist,
ServerInfo,
- unfollow,
- updateCustomConfig,
- updateCustomSubConfig,
uploadVideo,
wait,
waitJobs
const name = 'video for abuse ' + buildUUID()
const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name })
const video = resVideo.body.video
- const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, video.id, 'comment abuse ' + buildUUID())
- const comment = resComment.body.comment
+ const comment = await servers[0].commentsCommand.createThread({
+ token: userAccessToken,
+ videoId: video.id,
+ text: 'comment abuse ' + buildUUID()
+ })
await waitJobs(servers)
const name = 'video for abuse ' + buildUUID()
const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name })
const video = resVideo.body.video
- await addVideoCommentThread(servers[0].url, userAccessToken, video.id, 'comment abuse ' + buildUUID())
+
+ await servers[0].commentsCommand.createThread({
+ token: userAccessToken,
+ videoId: video.id,
+ text: 'comment abuse ' + buildUUID()
+ })
await waitJobs(servers)
- const resComments = await getVideoCommentThreads(servers[1].url, video.uuid, 0, 5)
- const commentId = resComments.body.data[0].id
+ const { data } = await servers[1].commentsCommand.listThreads({ videoId: video.uuid })
+ const commentId = data[0].id
await servers[1].abusesCommand.report({ commentId, reason: 'super reason' })
await waitJobs(servers)
await waitJobs(servers)
- const resAccount = await getAccount(servers[1].url, username + '@' + servers[0].host)
- await servers[1].abusesCommand.report({ accountId: resAccount.body.id, reason: 'super reason' })
+ const account = await servers[1].accountsCommand.get({ accountName: username + '@' + servers[0].host })
+ await servers[1].abusesCommand.report({ accountId: account.id, reason: 'super reason' })
await waitJobs(servers)
await checkNewAccountAbuseForModerators(baseParams, username, 'presence')
const video = resVideo.body.video
{
- const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' })
+ const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' })
abuseId = body.abuse.id
}
const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name })
const uuid = resVideo.body.video.uuid
- await addVideoToBlacklist(servers[0].url, servers[0].accessToken, uuid)
+ await servers[0].blacklistCommand.add({ videoId: uuid })
await waitJobs(servers)
await checkNewBlacklistOnMyVideo(baseParams, uuid, name, 'blacklist')
const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name })
const uuid = resVideo.body.video.uuid
- await addVideoToBlacklist(servers[0].url, servers[0].accessToken, uuid)
+ await servers[0].blacklistCommand.add({ videoId: uuid })
await waitJobs(servers)
- await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, uuid)
+ await servers[0].blacklistCommand.remove({ videoId: uuid })
await waitJobs(servers)
await wait(500)
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')
+ await checkUserRegistered({ ...baseParams, ...userOverride }, 'user_45', 'absence')
})
})
it('Should send a notification only to admin when there is a new instance follower', async function () {
this.timeout(20000)
- await follow(servers[2].url, [ servers[0].url ], servers[2].accessToken)
+ await servers[2].followsCommand.follow({ targets: [ servers[0].url ] })
await waitJobs(servers)
await checkNewInstanceFollower(baseParams, 'localhost:' + servers[2].port, 'presence')
const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }
- await checkNewInstanceFollower(immutableAssign(baseParams, userOverride), 'localhost:' + servers[2].port, 'absence')
+ await checkNewInstanceFollower({ ...baseParams, ...userOverride }, 'localhost:' + servers[2].port, 'absence')
})
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 servers[2].followsCommand.unfollow({ target: servers[0] })
await waitJobs(servers)
const config = {
}
}
}
- await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
+ await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
- await follow(servers[2].url, [ servers[0].url ], servers[2].accessToken)
+ await servers[2].followsCommand.follow({ targets: [ servers[0].url ] })
await waitJobs(servers)
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')
+ await checkAutoInstanceFollowing({ ...baseParams, ...userOverride }, followerHost, followingHost, 'absence')
config.followings.instance.autoFollowBack.enabled = false
- await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
- await unfollow(servers[0].url, servers[0].accessToken, servers[2])
- await unfollow(servers[2].url, servers[2].accessToken, servers[0])
+ await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
+ await servers[0].followsCommand.unfollow({ target: servers[2] })
+ await servers[2].followsCommand.unfollow({ target: 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 servers[0].followsCommand.unfollow({ target: servers[1] })
- await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
+ await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
await wait(5000)
await waitJobs(servers)
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])
+ await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
+ await servers[0].followsCommand.unfollow({ target: servers[1] })
})
})
token: userAccessToken
}
- const resCustomConfig = await getCustomConfig(servers[0].url, servers[0].accessToken)
- currentCustomConfig = resCustomConfig.body
- const autoBlacklistTestsCustomConfig = immutableAssign(currentCustomConfig, {
+ currentCustomConfig = await servers[0].configCommand.getCustomConfig()
+
+ const autoBlacklistTestsCustomConfig = {
+ ...currentCustomConfig,
+
autoBlacklist: {
videos: {
ofUsers: {
}
}
}
- })
+ }
+
// enable transcoding otherwise own publish notification after transcoding not expected
autoBlacklistTestsCustomConfig.transcoding.enabled = true
- await updateCustomConfig(servers[0].url, servers[0].accessToken, autoBlacklistTestsCustomConfig)
+ await servers[0].configCommand.updateCustomConfig({ newCustomConfig: 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)
+ await servers[0].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
+ await servers[1].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
})
it('Should send video published and unblacklist after video unblacklisted', async function () {
this.timeout(40000)
- await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, videoUUID)
+ await servers[0].blacklistCommand.remove({ videoId: videoUUID })
await waitJobs(servers)
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 servers[0].blacklistCommand.remove({ videoId: uuid })
await waitJobs(servers)
await checkNewBlacklistOnMyVideo(userBaseParams, uuid, name, 'unblacklist')
})
after(async () => {
- await updateCustomConfig(servers[0].url, servers[0].accessToken, currentCustomConfig)
+ await servers[0].configCommand.updateCustomConfig({ newCustomConfig: 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)
+ await servers[0].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
+ await servers[1].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
})
})