diff options
Diffstat (limited to 'server/models/account')
-rw-r--r-- | server/models/account/account.ts | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/server/models/account/account.ts b/server/models/account/account.ts index 20724ae0c..d8f305c37 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts | |||
@@ -1,16 +1,28 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import { | 2 | import { |
3 | AllowNull, BeforeDestroy, BelongsTo, Column, CreatedAt, DefaultScope, ForeignKey, HasMany, Model, Table, | 3 | AllowNull, |
4 | BeforeDestroy, | ||
5 | BelongsTo, | ||
6 | Column, | ||
7 | CreatedAt, | ||
8 | Default, | ||
9 | DefaultScope, | ||
10 | ForeignKey, | ||
11 | HasMany, | ||
12 | Is, | ||
13 | Model, | ||
14 | Table, | ||
4 | UpdatedAt | 15 | UpdatedAt |
5 | } from 'sequelize-typescript' | 16 | } from 'sequelize-typescript' |
6 | import { Account } from '../../../shared/models/actors' | 17 | import { Account } from '../../../shared/models/actors' |
18 | import { isAccountDescriptionValid } from '../../helpers/custom-validators/accounts' | ||
7 | import { logger } from '../../helpers/logger' | 19 | import { logger } from '../../helpers/logger' |
8 | import { sendDeleteActor } from '../../lib/activitypub/send' | 20 | import { sendDeleteActor } from '../../lib/activitypub/send' |
9 | import { ActorModel } from '../activitypub/actor' | 21 | import { ActorModel } from '../activitypub/actor' |
10 | import { ApplicationModel } from '../application/application' | 22 | import { ApplicationModel } from '../application/application' |
11 | import { AvatarModel } from '../avatar/avatar' | 23 | import { AvatarModel } from '../avatar/avatar' |
12 | import { ServerModel } from '../server/server' | 24 | import { ServerModel } from '../server/server' |
13 | import { getSort } from '../utils' | 25 | import { getSort, throwIfNotValid } from '../utils' |
14 | import { VideoChannelModel } from '../video/video-channel' | 26 | import { VideoChannelModel } from '../video/video-channel' |
15 | import { VideoCommentModel } from '../video/video-comment' | 27 | import { VideoCommentModel } from '../video/video-comment' |
16 | import { UserModel } from './user' | 28 | import { UserModel } from './user' |
@@ -42,6 +54,12 @@ export class AccountModel extends Model<AccountModel> { | |||
42 | @Column | 54 | @Column |
43 | name: string | 55 | name: string |
44 | 56 | ||
57 | @AllowNull(true) | ||
58 | @Default(null) | ||
59 | @Is('AccountDescription', value => throwIfNotValid(value, isAccountDescriptionValid, 'description')) | ||
60 | @Column | ||
61 | description: string | ||
62 | |||
45 | @CreatedAt | 63 | @CreatedAt |
46 | createdAt: Date | 64 | createdAt: Date |
47 | 65 | ||
@@ -196,6 +214,7 @@ export class AccountModel extends Model<AccountModel> { | |||
196 | const account = { | 214 | const account = { |
197 | id: this.id, | 215 | id: this.id, |
198 | displayName: this.name, | 216 | displayName: this.name, |
217 | description: this.description, | ||
199 | createdAt: this.createdAt, | 218 | createdAt: this.createdAt, |
200 | updatedAt: this.updatedAt | 219 | updatedAt: this.updatedAt |
201 | } | 220 | } |
@@ -204,7 +223,11 @@ export class AccountModel extends Model<AccountModel> { | |||
204 | } | 223 | } |
205 | 224 | ||
206 | toActivityPubObject () { | 225 | toActivityPubObject () { |
207 | return this.Actor.toActivityPubObject(this.name, 'Account') | 226 | const obj = this.Actor.toActivityPubObject(this.name, 'Account') |
227 | |||
228 | return Object.assign(obj, { | ||
229 | summary: this.description | ||
230 | }) | ||
208 | } | 231 | } |
209 | 232 | ||
210 | isOwned () { | 233 | isOwned () { |