diff options
Diffstat (limited to 'server/tests/api/notifications/moderation-notifications.ts')
-rw-r--r-- | server/tests/api/notifications/moderation-notifications.ts | 85 |
1 files changed, 78 insertions, 7 deletions
diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index b90732a7a..a8517600a 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts | |||
@@ -3,15 +3,21 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { v4 as uuidv4 } from 'uuid' | 4 | import { v4 as uuidv4 } from 'uuid' |
5 | import { | 5 | import { |
6 | addVideoCommentThread, | ||
6 | addVideoToBlacklist, | 7 | addVideoToBlacklist, |
7 | cleanupTests, | 8 | cleanupTests, |
9 | createUser, | ||
8 | follow, | 10 | follow, |
11 | generateUserAccessToken, | ||
12 | getAccount, | ||
9 | getCustomConfig, | 13 | getCustomConfig, |
14 | getVideoCommentThreads, | ||
15 | getVideoIdFromUUID, | ||
10 | immutableAssign, | 16 | immutableAssign, |
11 | MockInstancesIndex, | 17 | MockInstancesIndex, |
12 | registerUser, | 18 | registerUser, |
13 | removeVideoFromBlacklist, | 19 | removeVideoFromBlacklist, |
14 | reportVideoAbuse, | 20 | reportAbuse, |
15 | unfollow, | 21 | unfollow, |
16 | updateCustomConfig, | 22 | updateCustomConfig, |
17 | updateCustomSubConfig, | 23 | updateCustomSubConfig, |
@@ -23,7 +29,9 @@ import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | |||
23 | import { | 29 | import { |
24 | checkAutoInstanceFollowing, | 30 | checkAutoInstanceFollowing, |
25 | CheckerBaseParams, | 31 | CheckerBaseParams, |
32 | checkNewAccountAbuseForModerators, | ||
26 | checkNewBlacklistOnMyVideo, | 33 | checkNewBlacklistOnMyVideo, |
34 | checkNewCommentAbuseForModerators, | ||
27 | checkNewInstanceFollower, | 35 | checkNewInstanceFollower, |
28 | checkNewVideoAbuseForModerators, | 36 | checkNewVideoAbuseForModerators, |
29 | checkNewVideoFromSubscription, | 37 | checkNewVideoFromSubscription, |
@@ -74,12 +82,12 @@ describe('Test moderation notifications', function () { | |||
74 | 82 | ||
75 | const name = 'video for abuse ' + uuidv4() | 83 | const name = 'video for abuse ' + uuidv4() |
76 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) | 84 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) |
77 | const uuid = resVideo.body.video.uuid | 85 | const video = resVideo.body.video |
78 | 86 | ||
79 | await reportVideoAbuse(servers[0].url, servers[0].accessToken, uuid, 'super reason') | 87 | await reportAbuse({ url: servers[0].url, token: servers[0].accessToken, videoId: video.id, reason: 'super reason' }) |
80 | 88 | ||
81 | await waitJobs(servers) | 89 | await waitJobs(servers) |
82 | await checkNewVideoAbuseForModerators(baseParams, uuid, name, 'presence') | 90 | await checkNewVideoAbuseForModerators(baseParams, video.uuid, name, 'presence') |
83 | }) | 91 | }) |
84 | 92 | ||
85 | it('Should send a notification to moderators on remote video abuse', async function () { | 93 | it('Should send a notification to moderators on remote video abuse', async function () { |
@@ -87,14 +95,77 @@ describe('Test moderation notifications', function () { | |||
87 | 95 | ||
88 | const name = 'video for abuse ' + uuidv4() | 96 | const name = 'video for abuse ' + uuidv4() |
89 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) | 97 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) |
90 | const uuid = resVideo.body.video.uuid | 98 | const video = resVideo.body.video |
99 | |||
100 | await waitJobs(servers) | ||
101 | |||
102 | const videoId = await getVideoIdFromUUID(servers[1].url, video.uuid) | ||
103 | await reportAbuse({ url: servers[1].url, token: servers[1].accessToken, videoId, reason: 'super reason' }) | ||
104 | |||
105 | await waitJobs(servers) | ||
106 | await checkNewVideoAbuseForModerators(baseParams, video.uuid, name, 'presence') | ||
107 | }) | ||
108 | |||
109 | it('Should send a notification to moderators on local comment abuse', async function () { | ||
110 | this.timeout(10000) | ||
111 | |||
112 | const name = 'video for abuse ' + uuidv4() | ||
113 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) | ||
114 | const video = resVideo.body.video | ||
115 | const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, video.id, 'comment abuse ' + uuidv4()) | ||
116 | const comment = resComment.body.comment | ||
117 | |||
118 | await reportAbuse({ url: servers[0].url, token: servers[0].accessToken, commentId: comment.id, reason: 'super reason' }) | ||
119 | |||
120 | await waitJobs(servers) | ||
121 | await checkNewCommentAbuseForModerators(baseParams, video.uuid, name, 'presence') | ||
122 | }) | ||
123 | |||
124 | it('Should send a notification to moderators on remote comment abuse', async function () { | ||
125 | this.timeout(10000) | ||
126 | |||
127 | const name = 'video for abuse ' + uuidv4() | ||
128 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) | ||
129 | const video = resVideo.body.video | ||
130 | await addVideoCommentThread(servers[0].url, userAccessToken, video.id, 'comment abuse ' + uuidv4()) | ||
131 | |||
132 | await waitJobs(servers) | ||
133 | |||
134 | const resComments = await getVideoCommentThreads(servers[1].url, video.uuid, 0, 5) | ||
135 | const commentId = resComments.body.data[0].id | ||
136 | await reportAbuse({ url: servers[1].url, token: servers[1].accessToken, commentId, reason: 'super reason' }) | ||
137 | |||
138 | await waitJobs(servers) | ||
139 | await checkNewCommentAbuseForModerators(baseParams, video.uuid, name, 'presence') | ||
140 | }) | ||
141 | |||
142 | it('Should send a notification to moderators on local account abuse', async function () { | ||
143 | this.timeout(10000) | ||
144 | |||
145 | const username = 'user' + new Date().getTime() | ||
146 | const resUser = await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username, password: 'donald' }) | ||
147 | const accountId = resUser.body.user.account.id | ||
148 | |||
149 | await reportAbuse({ url: servers[0].url, token: servers[0].accessToken, accountId, reason: 'super reason' }) | ||
150 | |||
151 | await waitJobs(servers) | ||
152 | await checkNewAccountAbuseForModerators(baseParams, username, 'presence') | ||
153 | }) | ||
154 | |||
155 | it('Should send a notification to moderators on remote account abuse', async function () { | ||
156 | this.timeout(10000) | ||
157 | |||
158 | const username = 'user' + new Date().getTime() | ||
159 | const tmpToken = await generateUserAccessToken(servers[0], username) | ||
160 | await uploadVideo(servers[0].url, tmpToken, { name: 'super video' }) | ||
91 | 161 | ||
92 | await waitJobs(servers) | 162 | await waitJobs(servers) |
93 | 163 | ||
94 | await reportVideoAbuse(servers[1].url, servers[1].accessToken, uuid, 'super reason') | 164 | const resAccount = await getAccount(servers[1].url, username + '@' + servers[0].host) |
165 | await reportAbuse({ url: servers[1].url, token: servers[1].accessToken, accountId: resAccount.body.id, reason: 'super reason' }) | ||
95 | 166 | ||
96 | await waitJobs(servers) | 167 | await waitJobs(servers) |
97 | await checkNewVideoAbuseForModerators(baseParams, uuid, name, 'presence') | 168 | await checkNewAccountAbuseForModerators(baseParams, username, 'presence') |
98 | }) | 169 | }) |
99 | }) | 170 | }) |
100 | 171 | ||