aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/account')
-rw-r--r--server/models/account/account-blocklist.ts4
-rw-r--r--server/models/account/account-video-rate.ts9
-rw-r--r--server/models/account/account.ts8
-rw-r--r--server/models/account/user-notification-setting.ts3
-rw-r--r--server/models/account/user.ts12
5 files changed, 25 insertions, 11 deletions
diff --git a/server/models/account/account-blocklist.ts b/server/models/account/account-blocklist.ts
index bb5371395..8bcaca828 100644
--- a/server/models/account/account-blocklist.ts
+++ b/server/models/account/account-blocklist.ts
@@ -4,7 +4,7 @@ import { getSort } from '../utils'
4import { AccountBlock } from '../../../shared/models/blocklist' 4import { AccountBlock } from '../../../shared/models/blocklist'
5import { Op } from 'sequelize' 5import { Op } from 'sequelize'
6import * as Bluebird from 'bluebird' 6import * as Bluebird from 'bluebird'
7import { MAccountBlocklist, MAccountBlocklistAccounts } from '@server/typings/models' 7import { MAccountBlocklist, MAccountBlocklistAccounts, MAccountBlocklistFormattable } from '@server/typings/models'
8 8
9enum ScopeNames { 9enum ScopeNames {
10 WITH_ACCOUNTS = 'WITH_ACCOUNTS' 10 WITH_ACCOUNTS = 'WITH_ACCOUNTS'
@@ -134,7 +134,7 @@ export class AccountBlocklistModel extends Model<AccountBlocklistModel> {
134 }) 134 })
135 } 135 }
136 136
137 toFormattedJSON (): AccountBlock { 137 toFormattedJSON (this: MAccountBlocklistFormattable): AccountBlock {
138 return { 138 return {
139 byAccount: this.ByAccount.toFormattedJSON(), 139 byAccount: this.ByAccount.toFormattedJSON(),
140 blockedAccount: this.BlockedAccount.toFormattedJSON(), 140 blockedAccount: this.BlockedAccount.toFormattedJSON(),
diff --git a/server/models/account/account-video-rate.ts b/server/models/account/account-video-rate.ts
index 8b62dd05f..a6edbeee8 100644
--- a/server/models/account/account-video-rate.ts
+++ b/server/models/account/account-video-rate.ts
@@ -11,7 +11,12 @@ import { isActivityPubUrlValid } from '../../helpers/custom-validators/activityp
11import { AccountVideoRate } from '../../../shared' 11import { AccountVideoRate } from '../../../shared'
12import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from '../video/video-channel' 12import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from '../video/video-channel'
13import * as Bluebird from 'bluebird' 13import * as Bluebird from 'bluebird'
14import { MAccountVideoRate, MAccountVideoRateAccountUrl, MAccountVideoRateAccountVideo } from '@server/typings/models/video/video-rate' 14import {
15 MAccountVideoRate,
16 MAccountVideoRateAccountUrl,
17 MAccountVideoRateAccountVideo,
18 MAccountVideoRateFormattable
19} from '@server/typings/models/video/video-rate'
15 20
16/* 21/*
17 Account rates per video. 22 Account rates per video.
@@ -248,7 +253,7 @@ export class AccountVideoRateModel extends Model<AccountVideoRateModel> {
248 }) 253 })
249 } 254 }
250 255
251 toFormattedJSON (): AccountVideoRate { 256 toFormattedJSON (this: MAccountVideoRateFormattable): AccountVideoRate {
252 return { 257 return {
253 video: this.Video.toFormattedJSON(), 258 video: this.Video.toFormattedJSON(),
254 rating: this.type 259 rating: this.type
diff --git a/server/models/account/account.ts b/server/models/account/account.ts
index 4cc731075..8369738b9 100644
--- a/server/models/account/account.ts
+++ b/server/models/account/account.ts
@@ -32,7 +32,7 @@ import { FindOptions, IncludeOptions, Op, Transaction, WhereOptions } from 'sequ
32import { AccountBlocklistModel } from './account-blocklist' 32import { AccountBlocklistModel } from './account-blocklist'
33import { ServerBlocklistModel } from '../server/server-blocklist' 33import { ServerBlocklistModel } from '../server/server-blocklist'
34import { ActorFollowModel } from '../activitypub/actor-follow' 34import { ActorFollowModel } from '../activitypub/actor-follow'
35import { MAccountActor, MAccountDefault } from '../../typings/models' 35import { MAccountActor, MAccountDefault, MAccountSummaryFormattable, MAccountFormattable } from '../../typings/models'
36import * as Bluebird from 'bluebird' 36import * as Bluebird from 'bluebird'
37 37
38export enum ScopeNames { 38export enum ScopeNames {
@@ -353,7 +353,7 @@ export class AccountModel extends Model<AccountModel> {
353 .findAll(query) 353 .findAll(query)
354 } 354 }
355 355
356 toFormattedJSON (): Account { 356 toFormattedJSON (this: MAccountFormattable): Account {
357 const actor = this.Actor.toFormattedJSON() 357 const actor = this.Actor.toFormattedJSON()
358 const account = { 358 const account = {
359 id: this.id, 359 id: this.id,
@@ -367,8 +367,8 @@ export class AccountModel extends Model<AccountModel> {
367 return Object.assign(actor, account) 367 return Object.assign(actor, account)
368 } 368 }
369 369
370 toFormattedSummaryJSON (): AccountSummary { 370 toFormattedSummaryJSON (this: MAccountSummaryFormattable): AccountSummary {
371 const actor = this.Actor.toFormattedJSON() 371 const actor = this.Actor.toFormattedSummaryJSON()
372 372
373 return { 373 return {
374 id: this.id, 374 id: this.id,
diff --git a/server/models/account/user-notification-setting.ts b/server/models/account/user-notification-setting.ts
index c2fbc6d23..1506295cf 100644
--- a/server/models/account/user-notification-setting.ts
+++ b/server/models/account/user-notification-setting.ts
@@ -17,6 +17,7 @@ import { UserModel } from './user'
17import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications' 17import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications'
18import { UserNotificationSetting, UserNotificationSettingValue } from '../../../shared/models/users/user-notification-setting.model' 18import { UserNotificationSetting, UserNotificationSettingValue } from '../../../shared/models/users/user-notification-setting.model'
19import { clearCacheByUserId } from '../../lib/oauth-model' 19import { clearCacheByUserId } from '../../lib/oauth-model'
20import { MNotificationSettingFormattable } from '@server/typings/models'
20 21
21@Table({ 22@Table({
22 tableName: 'userNotificationSetting', 23 tableName: 'userNotificationSetting',
@@ -152,7 +153,7 @@ export class UserNotificationSettingModel extends Model<UserNotificationSettingM
152 return clearCacheByUserId(instance.userId) 153 return clearCacheByUserId(instance.userId)
153 } 154 }
154 155
155 toFormattedJSON (): UserNotificationSetting { 156 toFormattedJSON (this: MNotificationSettingFormattable): UserNotificationSetting {
156 return { 157 return {
157 newCommentOnMyVideo: this.newCommentOnMyVideo, 158 newCommentOnMyVideo: this.newCommentOnMyVideo,
158 newVideoFromSubscription: this.newVideoFromSubscription, 159 newVideoFromSubscription: this.newVideoFromSubscription,
diff --git a/server/models/account/user.ts b/server/models/account/user.ts
index cb54d79af..616dd603c 100644
--- a/server/models/account/user.ts
+++ b/server/models/account/user.ts
@@ -55,7 +55,13 @@ import { UserAdminFlag } from '../../../shared/models/users/user-flag.model'
55import { isThemeNameValid } from '../../helpers/custom-validators/plugins' 55import { isThemeNameValid } from '../../helpers/custom-validators/plugins'
56import { getThemeOrDefault } from '../../lib/plugins/theme-utils' 56import { getThemeOrDefault } from '../../lib/plugins/theme-utils'
57import * as Bluebird from 'bluebird' 57import * as Bluebird from 'bluebird'
58import { MUserNotifSettingChannelDefault, MUserDefault, MUserId, MUserWithNotificationSetting } from '@server/typings/models' 58import {
59 MUserDefault,
60 MUserFormattable,
61 MUserId,
62 MUserNotifSettingChannelDefault,
63 MUserWithNotificationSetting
64} from '@server/typings/models'
59 65
60enum ScopeNames { 66enum ScopeNames {
61 WITH_VIDEO_CHANNEL = 'WITH_VIDEO_CHANNEL' 67 WITH_VIDEO_CHANNEL = 'WITH_VIDEO_CHANNEL'
@@ -554,7 +560,9 @@ export class UserModel extends Model<UserModel> {
554 return comparePassword(password, this.password) 560 return comparePassword(password, this.password)
555 } 561 }
556 562
557 toFormattedJSON (parameters: { withAdminFlags?: boolean } = {}): User { 563 toSummaryJSON
564
565 toFormattedJSON (this: MUserFormattable, parameters: { withAdminFlags?: boolean } = {}): User {
558 const videoQuotaUsed = this.get('videoQuotaUsed') 566 const videoQuotaUsed = this.get('videoQuotaUsed')
559 const videoQuotaUsedDaily = this.get('videoQuotaUsedDaily') 567 const videoQuotaUsedDaily = this.get('videoQuotaUsedDaily')
560 568