aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-04-21 09:52:21 +0200
committerRigel Kent <par@rigelk.eu>2020-05-01 16:41:02 +0200
commitd1261d9a3cef6d3df408c9dce977100ac196f9f8 (patch)
tree093c443b2e4c38ee738da3b420c7e3993da4edb3
parent197876ea87494f9c8f5262fa371b0f70e3c56fb5 (diff)
downloadPeerTube-d1261d9a3cef6d3df408c9dce977100ac196f9f8.tar.gz
PeerTube-d1261d9a3cef6d3df408c9dce977100ac196f9f8.tar.zst
PeerTube-d1261d9a3cef6d3df408c9dce977100ac196f9f8.zip
Add links from user-edit
-rw-r--r--client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts1
-rw-r--r--client/src/app/+admin/users/user-edit/user-edit.component.html4
-rw-r--r--client/src/sass/include/_mixins.scss2
-rw-r--r--server/tests/api/videos/video-abuse.ts64
-rw-r--r--server/typings/models/video/video-abuse.ts4
5 files changed, 60 insertions, 15 deletions
diff --git a/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts
index f04efa9fc..e87163c4f 100644
--- a/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts
+++ b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts
@@ -217,6 +217,7 @@ export class VideoAbuseListComponent extends RestTable implements OnInit, AfterV
217 } 217 }
218 218
219 setTableFilter (filter: string) { 219 setTableFilter (filter: string) {
220 // FIXME: cannot use ViewChild, so create a component for the filter input
220 const filterInput = document.getElementById('table-filter') as HTMLInputElement 221 const filterInput = document.getElementById('table-filter') as HTMLInputElement
221 if (filterInput) filterInput.value = filter 222 if (filterInput) filterInput.value = filter
222 } 223 }
diff --git a/client/src/app/+admin/users/user-edit/user-edit.component.html b/client/src/app/+admin/users/user-edit/user-edit.component.html
index 5303d6096..df9f24749 100644
--- a/client/src/app/+admin/users/user-edit/user-edit.component.html
+++ b/client/src/app/+admin/users/user-edit/user-edit.component.html
@@ -37,13 +37,13 @@
37 </a> 37 </a>
38 </div> 38 </div>
39 <div> 39 <div>
40 <a> 40 <a [routerLink]="[ '/admin/moderation/video-abuses/list' ]" [queryParams]="{ 'search': user?.account.displayName }">
41 <div class="dashboard-num">{{ user.videoAbusesCount }}</div> 41 <div class="dashboard-num">{{ user.videoAbusesCount }}</div>
42 <div class="dashboard-label" i18n>Incriminated in reports</div> 42 <div class="dashboard-label" i18n>Incriminated in reports</div>
43 </a> 43 </a>
44 </div> 44 </div>
45 <div> 45 <div>
46 <a> 46 <a [routerLink]="[ '/admin/moderation/video-abuses/list' ]" [queryParams]="{ 'search': user?.account.displayName }">
47 <div class="dashboard-num">{{ user.videoAbusesAcceptedCount }} / {{ user.videoAbusesCreatedCount }}</div> 47 <div class="dashboard-num">{{ user.videoAbusesAcceptedCount }} / {{ user.videoAbusesCreatedCount }}</div>
48 <div class="dashboard-label" i18n>Authored reports accepted</div> 48 <div class="dashboard-label" i18n>Authored reports accepted</div>
49 </a> 49 </a>
diff --git a/client/src/sass/include/_mixins.scss b/client/src/sass/include/_mixins.scss
index adeee758e..a6d1abd6d 100644
--- a/client/src/sass/include/_mixins.scss
+++ b/client/src/sass/include/_mixins.scss
@@ -692,6 +692,8 @@
692 margin-bottom: 10px; 692 margin-bottom: 10px;
693 693
694 & > a { 694 & > a {
695 @include disable-default-a-behaviour;
696
695 text-decoration: none; 697 text-decoration: none;
696 color: inherit; 698 color: inherit;
697 display: block; 699 display: block;
diff --git a/server/tests/api/videos/video-abuse.ts b/server/tests/api/videos/video-abuse.ts
index 8a8290e14..26bc3783b 100644
--- a/server/tests/api/videos/video-abuse.ts
+++ b/server/tests/api/videos/video-abuse.ts
@@ -14,7 +14,9 @@ import {
14 setAccessTokensToServers, 14 setAccessTokensToServers,
15 updateVideoAbuse, 15 updateVideoAbuse,
16 uploadVideo, 16 uploadVideo,
17 removeVideo 17 removeVideo,
18 createUser,
19 userLogin
18} from '../../../../shared/extra-utils/index' 20} from '../../../../shared/extra-utils/index'
19import { doubleFollow } from '../../../../shared/extra-utils/server/follows' 21import { doubleFollow } from '../../../../shared/extra-utils/server/follows'
20import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 22import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
@@ -236,16 +238,56 @@ describe('Test video abuses', function () {
236 238
237 await waitJobs(servers) 239 await waitJobs(servers)
238 240
239 { 241 const res = await getVideoAbusesList(servers[1].url, servers[1].accessToken)
240 const res = await getVideoAbusesList(servers[1].url, servers[1].accessToken) 242 expect(res.body.total).to.equal(2, "wrong number of videos returned")
241 expect(res.body.total).to.equal(2) 243 expect(res.body.data.length).to.equal(2, "wrong number of videos returned")
242 expect(res.body.data.length).to.equal(2) 244 expect(res.body.data[0].id).to.equal(abuseServer2.id, "wrong origin server id for first video")
243 expect(res.body.data[0].id).to.equal(abuseServer2.id) 245
246 const abuse: VideoAbuse = res.body.data[0]
247 expect(abuse.video.id).to.equal(abuseServer2.video.id, "wrong video id")
248 expect(abuse.video.channel).to.exist
249 expect(abuse.video.deleted).to.be.true
250 })
251
252 it('Should include counts of reports from reporter and reportee', async function () {
253 this.timeout(10000)
244 254
245 const abuse: VideoAbuse = res.body.data[1] 255 // register a second user to have two reporters/reportees
246 expect(abuse.video.deleted).to.be.true 256 const user = { username: 'user2', password: 'password' }
247 expect(abuse.video.id).to.equal(abuseServer2.video.id) 257 await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, ...user })
248 expect(abuse.video.channel).to.exist 258 const userAccessToken = await userLogin(servers[0], user)
259
260 // upload a third video via this user
261 const video3Attributes = {
262 name: 'my second super name for server 1',
263 description: 'my second super description for server 1'
264 }
265 await uploadVideo(servers[0].url, userAccessToken, video3Attributes)
266
267 const res1 = await getVideosList(servers[0].url)
268 const videos = res1.body.data
269 const video3 = videos.find(video => video.name === 'my second super name for server 1')
270
271 // resume with the test
272 const reason3 = 'my super bad reason 3'
273 await reportVideoAbuse(servers[0].url, servers[0].accessToken, video3.id, reason3)
274 const reason4 = 'my super bad reason 4'
275 await reportVideoAbuse(servers[0].url, userAccessToken, servers[0].video.id, reason4)
276
277 const res2 = await getVideoAbusesList(servers[0].url, servers[0].accessToken)
278
279 {
280 for (const abuse of res2.body.data as VideoAbuse[]) {
281 if (abuse.video.id === video3.id) {
282 expect(abuse.count).to.equal(1, "wrong reports count for video 3")
283 expect(abuse.nth).to.equal(1, "wrong report position in report list for video 3")
284 expect(abuse.countReportsForReportee).to.equal(1, "wrong reports count for reporter on video 3 abuse")
285 expect(abuse.countReportsForReporter).to.equal(3, "wrong reports count for reportee on video 3 abuse")
286 }
287 if (abuse.video.id === servers[0].video.id) {
288 expect(abuse.countReportsForReportee).to.equal(3, "wrong reports count for reporter on video 1 abuse")
289 }
290 }
249 } 291 }
250 }) 292 })
251 293
@@ -265,7 +307,7 @@ describe('Test video abuses', function () {
265 307
266 { 308 {
267 const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken) 309 const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken)
268 expect(res.body.total).to.equal(3) 310 expect(res.body.total).to.equal(5)
269 } 311 }
270 }) 312 })
271 313
diff --git a/server/typings/models/video/video-abuse.ts b/server/typings/models/video/video-abuse.ts
index 54acccdf5..d60f05e4c 100644
--- a/server/typings/models/video/video-abuse.ts
+++ b/server/typings/models/video/video-abuse.ts
@@ -1,6 +1,6 @@
1import { VideoAbuseModel } from '../../../models/video/video-abuse' 1import { VideoAbuseModel } from '../../../models/video/video-abuse'
2import { PickWith } from '../../utils' 2import { PickWith } from '../../utils'
3import { MVideoAccountLightBlacklistAllFiles } from './video' 3import { MVideoAccountLightBlacklistAllFiles, MVideo } from './video'
4import { MAccountDefault, MAccountFormattable } from '../account' 4import { MAccountDefault, MAccountFormattable } from '../account'
5 5
6type Use<K extends keyof VideoAbuseModel, M> = PickWith<VideoAbuseModel, K, M> 6type Use<K extends keyof VideoAbuseModel, M> = PickWith<VideoAbuseModel, K, M>
@@ -16,7 +16,7 @@ export type MVideoAbuseId = Pick<VideoAbuseModel, 'id'>
16export type MVideoAbuseVideo = 16export type MVideoAbuseVideo =
17 MVideoAbuse & 17 MVideoAbuse &
18 Pick<VideoAbuseModel, 'toActivityPubObject'> & 18 Pick<VideoAbuseModel, 'toActivityPubObject'> &
19 Use<'Video', MVideoAccountLightBlacklistAllFiles> 19 Use<'Video', MVideo>
20 20
21export type MVideoAbuseAccountVideo = 21export type MVideoAbuseAccountVideo =
22 MVideoAbuse & 22 MVideoAbuse &