From eacb25c4366bcc8fba20f98f93f004fabc6d5578 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 8 Aug 2018 17:36:10 +0200 Subject: Add reason when banning a user --- server/models/account/user.ts | 9 +++++++++ server/models/video/video-abuse.ts | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'server/models') diff --git a/server/models/account/user.ts b/server/models/account/user.ts index ea6d63312..81b0651fd 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts @@ -21,6 +21,7 @@ import { hasUserRight, USER_ROLE_LABELS, UserRight } from '../../../shared' import { User, UserRole } from '../../../shared/models/users' import { isUserAutoPlayVideoValid, + isUserBlockedReasonValid, isUserBlockedValid, isUserNSFWPolicyValid, isUserPasswordValid, @@ -107,6 +108,12 @@ export class UserModel extends Model { @Column blocked: boolean + @AllowNull(true) + @Default(null) + @Is('UserBlockedReason', value => throwIfNotValid(value, isUserBlockedReasonValid, 'blocked reason')) + @Column + blockedReason: string + @AllowNull(false) @Is('UserRole', value => throwIfNotValid(value, isUserRoleValid, 'role')) @Column @@ -284,6 +291,8 @@ export class UserModel extends Model { roleLabel: USER_ROLE_LABELS[ this.role ], videoQuota: this.videoQuota, createdAt: this.createdAt, + blocked: this.blocked, + blockedReason: this.blockedReason, account: this.Account.toFormattedJSON(), videoChannels: [] } diff --git a/server/models/video/video-abuse.ts b/server/models/video/video-abuse.ts index a6319bb79..39f0c2cb2 100644 --- a/server/models/video/video-abuse.ts +++ b/server/models/video/video-abuse.ts @@ -57,7 +57,7 @@ export class VideoAbuseModel extends Model { @AfterCreate static sendEmailNotification (instance: VideoAbuseModel) { - return Emailer.Instance.addVideoAbuseReport(instance.videoId) + return Emailer.Instance.addVideoAbuseReportJob(instance.videoId) } static listForApi (start: number, count: number, sort: string) { -- cgit v1.2.3