From 4f32032fed8587ea97d45e235b167e8958efd81f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 7 Jul 2020 14:34:16 +0200 Subject: Add migrations --- server/models/account/account.ts | 5 +-- server/models/account/user-notification-setting.ts | 8 ++--- server/models/account/user.ts | 36 ++++++++++------------ 3 files changed, 24 insertions(+), 25 deletions(-) (limited to 'server/models/account') diff --git a/server/models/account/account.ts b/server/models/account/account.ts index 466d6258e..f97519b14 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts @@ -42,6 +42,7 @@ export enum ScopeNames { } export type SummaryOptions = { + actorRequired?: boolean // Default: true whereActor?: WhereOptions withAccountBlockerIds?: number[] } @@ -65,12 +66,12 @@ export type SummaryOptions = { } const query: FindOptions = { - attributes: [ 'id', 'name' ], + attributes: [ 'id', 'name', 'actorId' ], include: [ { attributes: [ 'id', 'preferredUsername', 'url', 'serverId', 'avatarId' ], model: ActorModel.unscoped(), - required: true, + required: options.actorRequired ?? true, where: whereActor, include: [ serverInclude, diff --git a/server/models/account/user-notification-setting.ts b/server/models/account/user-notification-setting.ts index b69b47265..d8f3f13da 100644 --- a/server/models/account/user-notification-setting.ts +++ b/server/models/account/user-notification-setting.ts @@ -51,11 +51,11 @@ export class UserNotificationSettingModel extends Model throwIfNotValid(value, isUserNotificationSettingValid, 'videoAbuseAsModerator') + 'UserNotificationSettingAbuseAsModerator', + value => throwIfNotValid(value, isUserNotificationSettingValid, 'abuseAsModerator') ) @Column - videoAbuseAsModerator: UserNotificationSettingValue + abuseAsModerator: UserNotificationSettingValue @AllowNull(false) @Default(null) @@ -166,7 +166,7 @@ export class UserNotificationSettingModel extends Model { const videoQuotaUsed = this.get('videoQuotaUsed') const videoQuotaUsedDaily = this.get('videoQuotaUsedDaily') const videosCount = this.get('videosCount') - const [ videoAbusesCount, videoAbusesAcceptedCount ] = (this.get('videoAbusesCount') as string || ':').split(':') - const videoAbusesCreatedCount = this.get('videoAbusesCreatedCount') + const [ abusesCount, abusesAcceptedCount ] = (this.get('abusesCount') as string || ':').split(':') + const abusesCreatedCount = this.get('abusesCreatedCount') const videoCommentsCount = this.get('videoCommentsCount') const json: User = { @@ -815,14 +813,14 @@ export class UserModel extends Model { videosCount: videosCount !== undefined ? parseInt(videosCount + '', 10) : undefined, - videoAbusesCount: videoAbusesCount - ? parseInt(videoAbusesCount, 10) + abusesCount: abusesCount + ? parseInt(abusesCount, 10) : undefined, - videoAbusesAcceptedCount: videoAbusesAcceptedCount - ? parseInt(videoAbusesAcceptedCount, 10) + abusesAcceptedCount: abusesAcceptedCount + ? parseInt(abusesAcceptedCount, 10) : undefined, - videoAbusesCreatedCount: videoAbusesCreatedCount !== undefined - ? parseInt(videoAbusesCreatedCount + '', 10) + abusesCreatedCount: abusesCreatedCount !== undefined + ? parseInt(abusesCreatedCount + '', 10) : undefined, videoCommentsCount: videoCommentsCount !== undefined ? parseInt(videoCommentsCount + '', 10) -- cgit v1.2.3