- return VideoAbuse.findAndCountAll(query).then(({ rows, count }) => {
- return { total: count, data: rows }
- })
+ static listForApi (start: number, count: number, sort: string) {
+ const query = {
+ offset: start,
+ limit: count,
+ order: [ getSort(sort) ],
+ include: [
+ {
+ model: AccountModel,
+ required: true
+ },
+ {
+ model: VideoModel,
+ required: true
+ }
+ ]
+ }
+
+ return VideoAbuseModel.findAndCountAll(query)
+ .then(({ rows, count }) => {
+ return { total: count, data: rows }
+ })
+ }
+
+ 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
+ }
+
+ return {
+ id: this.id,
+ reason: this.reason,
+ reporterUsername: this.Account.name,
+ reporterServerHost,
+ videoId: this.Video.id,
+ videoUUID: this.Video.uuid,
+ videoName: this.Video.name,
+ createdAt: this.createdAt
+ }
+ }
+
+ toActivityPubObject (): VideoAbuseObject {
+ return {
+ type: 'Flag' as 'Flag',
+ content: this.reason,
+ object: this.Video.url
+ }
+ }