- 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 (): VideoAbuse {
+ return {
+ id: this.id,
+ reason: this.reason,
+ reporterAccount: this.Account.toFormattedJSON(),
+ state: {
+ id: this.state,
+ label: VideoAbuseModel.getStateLabel(this.state)
+ },
+ moderationComment: this.moderationComment,
+ video: {
+ id: this.Video.id,
+ uuid: this.Video.uuid,
+ name: this.Video.name
+ },
+ createdAt: this.createdAt
+ }
+ }
+
+ toActivityPubObject (): VideoAbuseObject {
+ return {
+ type: 'Flag' as 'Flag',
+ content: this.reason,
+ object: this.Video.url
+ }
+ }
+
+ private static getStateLabel (id: number) {
+ return VIDEO_ABUSE_STATES[id] || 'Unknown'
+ }