Change video abuse API response
This commit is contained in:
parent
f2c3f7cd8a
commit
19a3b914f1
25
CHANGELOG.md
25
CHANGELOG.md
|
@ -1,5 +1,30 @@
|
|||
# Changelog
|
||||
|
||||
## v1.0.0-alpha.7
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* Update videos list/search API response:
|
||||
* Removed `accountName` field
|
||||
* Removed `serverHost` field
|
||||
* Added `account.name` field
|
||||
* Added `account.displayName` field
|
||||
* Added `account.host` field
|
||||
* Added `account.url` field
|
||||
* Added `account.avatar` field
|
||||
* Update video abuses API response:
|
||||
* Removed `reporterUsername` field
|
||||
* Removed `reporterServerHost` field
|
||||
* Removed `videoId` field
|
||||
* Removed `videoUUID` field
|
||||
* Removed `videoName` field
|
||||
* Added `reporterAccount` field
|
||||
* Added `video.id` field
|
||||
* Added `video.name` field
|
||||
* Added `video.uuid` field
|
||||
* Added `video.url` field
|
||||
|
||||
|
||||
## v1.0.0-alpha.4
|
||||
|
||||
### Features
|
||||
|
|
|
@ -18,10 +18,16 @@
|
|||
<ng-template pTemplate="body" let-videoAbuse>
|
||||
<tr>
|
||||
<td>{{ videoAbuse.reason }}</td>
|
||||
<td>{{ videoAbuse.reporterUsername + '@' + videoAbuse.reporterServerHost }}</td>
|
||||
<td>
|
||||
<a [href]="videoAbuse.reporterAccount.url" title="Go to the account" target="_blank">
|
||||
{{ createByString(videoAbuse.reporterAccount) }}
|
||||
</a>
|
||||
</td>
|
||||
<td>{{ videoAbuse.createdAt }}</td>
|
||||
<td>
|
||||
<a [routerLink]="getRouterVideoLink(videoAbuse.videoUUID)" title="Go to the video">{{ videoAbuse.videoName }}</a>
|
||||
<a [href]="videoAbuse.video.url" title="Go to the video" target="_blank">
|
||||
{{ videoAbuse.video.name }}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</ng-template>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { Component, OnInit } from '@angular/core'
|
||||
|
||||
import { Account } from '@app/shared/account/account.model'
|
||||
import { NotificationsService } from 'angular2-notifications'
|
||||
import { SortMeta } from 'primeng/components/common/sortmeta'
|
||||
|
||||
import { RestTable, RestPagination, VideoAbuseService } from '../../../shared'
|
||||
import { VideoAbuse } from '../../../../../../shared'
|
||||
|
||||
import { RestPagination, RestTable, VideoAbuseService } from '../../../shared'
|
||||
|
||||
@Component({
|
||||
selector: 'my-video-abuse-list',
|
||||
templateUrl: './video-abuse-list.component.html',
|
||||
|
@ -29,8 +29,8 @@ export class VideoAbuseListComponent extends RestTable implements OnInit {
|
|||
this.loadSort()
|
||||
}
|
||||
|
||||
getRouterVideoLink (videoUUID: string) {
|
||||
return [ '/videos', videoUUID ]
|
||||
createByString (account: Account) {
|
||||
return Account.CREATE_BY_STRING(account.name, account.host)
|
||||
}
|
||||
|
||||
protected loadData () {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { AfterCreate, AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
|
||||
import { VideoAbuseObject } from '../../../shared/models/activitypub/objects'
|
||||
import { VideoAbuse } from '../../../shared/models/videos'
|
||||
import { isVideoAbuseReasonValid } from '../../helpers/custom-validators/videos'
|
||||
import { CONFIG } from '../../initializers'
|
||||
import { Emailer } from '../../lib/emailer'
|
||||
import { AccountModel } from '../account/account'
|
||||
import { getSort, throwIfNotValid } from '../utils'
|
||||
|
@ -83,24 +83,17 @@ export class VideoAbuseModel extends Model<VideoAbuseModel> {
|
|||
})
|
||||
}
|
||||
|
||||
toFormattedJSON () {
|
||||
let reporterServerHost
|
||||
|
||||
if (this.Account.Actor.Server) {
|
||||
reporterServerHost = this.Account.Actor.Server.host
|
||||
} else {
|
||||
// It means it's our video
|
||||
reporterServerHost = CONFIG.WEBSERVER.HOST
|
||||
}
|
||||
|
||||
toFormattedJSON (): VideoAbuse {
|
||||
return {
|
||||
id: this.id,
|
||||
reason: this.reason,
|
||||
reporterUsername: this.Account.name,
|
||||
reporterServerHost,
|
||||
videoId: this.Video.id,
|
||||
videoUUID: this.Video.uuid,
|
||||
videoName: this.Video.name,
|
||||
reporterAccount: this.Account.toFormattedJSON(),
|
||||
video: {
|
||||
id: this.Video.id,
|
||||
uuid: this.Video.uuid,
|
||||
url: this.Video.url,
|
||||
name: this.Video.name
|
||||
},
|
||||
createdAt: this.createdAt
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import * as chai from 'chai'
|
||||
import 'mocha'
|
||||
import { VideoAbuse } from '../../../../shared/models/videos'
|
||||
import {
|
||||
flushAndRunMultipleServers,
|
||||
flushTests,
|
||||
|
@ -83,11 +84,11 @@ describe('Test video abuses', function () {
|
|||
expect(res1.body.data).to.be.an('array')
|
||||
expect(res1.body.data.length).to.equal(1)
|
||||
|
||||
const abuse = res1.body.data[0]
|
||||
const abuse: VideoAbuse = res1.body.data[0]
|
||||
expect(abuse.reason).to.equal('my super bad reason')
|
||||
expect(abuse.reporterUsername).to.equal('root')
|
||||
expect(abuse.reporterServerHost).to.equal('localhost:9001')
|
||||
expect(abuse.videoId).to.equal(servers[0].video.id)
|
||||
expect(abuse.reporterAccount.name).to.equal('root')
|
||||
expect(abuse.reporterAccount.host).to.equal('localhost:9001')
|
||||
expect(abuse.video.id).to.equal(servers[0].video.id)
|
||||
|
||||
const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken)
|
||||
expect(res2.body.total).to.equal(0)
|
||||
|
@ -111,27 +112,27 @@ describe('Test video abuses', function () {
|
|||
expect(res1.body.data).to.be.an('array')
|
||||
expect(res1.body.data.length).to.equal(2)
|
||||
|
||||
const abuse1 = res1.body.data[0]
|
||||
const abuse1: VideoAbuse = res1.body.data[0]
|
||||
expect(abuse1.reason).to.equal('my super bad reason')
|
||||
expect(abuse1.reporterUsername).to.equal('root')
|
||||
expect(abuse1.reporterServerHost).to.equal('localhost:9001')
|
||||
expect(abuse1.videoId).to.equal(servers[0].video.id)
|
||||
expect(abuse1.reporterAccount.name).to.equal('root')
|
||||
expect(abuse1.reporterAccount.host).to.equal('localhost:9001')
|
||||
expect(abuse1.video.id).to.equal(servers[0].video.id)
|
||||
|
||||
const abuse2 = res1.body.data[1]
|
||||
const abuse2: VideoAbuse = res1.body.data[1]
|
||||
expect(abuse2.reason).to.equal('my super bad reason 2')
|
||||
expect(abuse2.reporterUsername).to.equal('root')
|
||||
expect(abuse2.reporterServerHost).to.equal('localhost:9001')
|
||||
expect(abuse2.videoId).to.equal(servers[1].video.id)
|
||||
expect(abuse2.reporterAccount.name).to.equal('root')
|
||||
expect(abuse2.reporterAccount.host).to.equal('localhost:9001')
|
||||
expect(abuse2.video.id).to.equal(servers[1].video.id)
|
||||
|
||||
const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken)
|
||||
expect(res2.body.total).to.equal(1)
|
||||
expect(res2.body.data).to.be.an('array')
|
||||
expect(res2.body.data.length).to.equal(1)
|
||||
|
||||
const abuse3 = res2.body.data[0]
|
||||
const abuse3: VideoAbuse = res2.body.data[0]
|
||||
expect(abuse3.reason).to.equal('my super bad reason 2')
|
||||
expect(abuse3.reporterUsername).to.equal('root')
|
||||
expect(abuse3.reporterServerHost).to.equal('localhost:9001')
|
||||
expect(abuse3.reporterAccount.name).to.equal('root')
|
||||
expect(abuse3.reporterAccount.host).to.equal('localhost:9001')
|
||||
})
|
||||
|
||||
after(async function () {
|
||||
|
|
|
@ -420,7 +420,8 @@ async function completeVideoCheck (
|
|||
expect(videoDetails.tags).to.deep.equal(attributes.tags)
|
||||
expect(videoDetails.privacy).to.deep.equal(attributes.privacy)
|
||||
expect(videoDetails.privacyLabel).to.deep.equal(VIDEO_PRIVACIES[attributes.privacy])
|
||||
expect(videoDetails.account.name).to.equal(attributes.account)
|
||||
expect(videoDetails.account.name).to.equal(attributes.account.name)
|
||||
expect(videoDetails.account.host).to.equal(attributes.account.host)
|
||||
expect(videoDetails.commentsEnabled).to.equal(attributes.commentsEnabled)
|
||||
|
||||
expect(videoDetails.channel.displayName).to.equal(attributes.channel.name)
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
import { Account } from '../actors'
|
||||
|
||||
export interface VideoAbuse {
|
||||
id: number
|
||||
reason: string
|
||||
reporterUsername: string
|
||||
reporterServerHost: string
|
||||
videoId: number
|
||||
videoUUID: string
|
||||
videoName: string
|
||||
reporterAccount: Account
|
||||
video: {
|
||||
id: number
|
||||
name: string
|
||||
uuid: string
|
||||
url: string
|
||||
}
|
||||
createdAt: Date
|
||||
}
|
||||
|
|
|
@ -1094,16 +1094,13 @@ definitions:
|
|||
type: number
|
||||
reason:
|
||||
type: string
|
||||
reporterUsername:
|
||||
type: string
|
||||
reporterServerHost:
|
||||
type: string
|
||||
videoId:
|
||||
type: number
|
||||
videoUUID:
|
||||
type: string
|
||||
videoName:
|
||||
type: string
|
||||
reporterAccount:
|
||||
$ref: "#/definitions/Account"
|
||||
video:
|
||||
id: number
|
||||
name: string
|
||||
uuid: string
|
||||
url: string
|
||||
createdAt:
|
||||
type: string
|
||||
VideoBlacklist:
|
||||
|
|
Loading…
Reference in New Issue