diff options
Diffstat (limited to 'server/models/activitypub')
-rw-r--r-- | server/models/activitypub/actor.ts | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts index 3b98e8841..09d96b24d 100644 --- a/server/models/activitypub/actor.ts +++ b/server/models/activitypub/actor.ts | |||
@@ -19,7 +19,7 @@ import { | |||
19 | } from 'sequelize-typescript' | 19 | } from 'sequelize-typescript' |
20 | import { ModelCache } from '@server/models/model-cache' | 20 | import { ModelCache } from '@server/models/model-cache' |
21 | import { ActivityIconObject, ActivityPubActorType } from '../../../shared/models/activitypub' | 21 | import { ActivityIconObject, ActivityPubActorType } from '../../../shared/models/activitypub' |
22 | import { Avatar } from '../../../shared/models/avatars/avatar.model' | 22 | import { ActorImage } from '../../../shared/models/actors/actor-image.model' |
23 | import { activityPubContextify } from '../../helpers/activitypub' | 23 | import { activityPubContextify } from '../../helpers/activitypub' |
24 | import { | 24 | import { |
25 | isActorFollowersCountValid, | 25 | isActorFollowersCountValid, |
@@ -43,7 +43,7 @@ import { | |||
43 | MActorWithInboxes | 43 | MActorWithInboxes |
44 | } from '../../types/models' | 44 | } from '../../types/models' |
45 | import { AccountModel } from '../account/account' | 45 | import { AccountModel } from '../account/account' |
46 | import { AvatarModel } from '../avatar/avatar' | 46 | import { ActorImageModel } from '../account/actor-image' |
47 | import { ServerModel } from '../server/server' | 47 | import { ServerModel } from '../server/server' |
48 | import { isOutdated, throwIfNotValid } from '../utils' | 48 | import { isOutdated, throwIfNotValid } from '../utils' |
49 | import { VideoModel } from '../video/video' | 49 | import { VideoModel } from '../video/video' |
@@ -73,7 +73,8 @@ export const unusedActorAttributesForAPI = [ | |||
73 | required: false | 73 | required: false |
74 | }, | 74 | }, |
75 | { | 75 | { |
76 | model: AvatarModel, | 76 | model: ActorImageModel, |
77 | as: 'Avatar', | ||
77 | required: false | 78 | required: false |
78 | } | 79 | } |
79 | ] | 80 | ] |
@@ -100,7 +101,8 @@ export const unusedActorAttributesForAPI = [ | |||
100 | required: false | 101 | required: false |
101 | }, | 102 | }, |
102 | { | 103 | { |
103 | model: AvatarModel, | 104 | model: ActorImageModel, |
105 | as: 'Avatar', | ||
104 | required: false | 106 | required: false |
105 | } | 107 | } |
106 | ] | 108 | ] |
@@ -213,18 +215,35 @@ export class ActorModel extends Model { | |||
213 | @UpdatedAt | 215 | @UpdatedAt |
214 | updatedAt: Date | 216 | updatedAt: Date |
215 | 217 | ||
216 | @ForeignKey(() => AvatarModel) | 218 | @ForeignKey(() => ActorImageModel) |
217 | @Column | 219 | @Column |
218 | avatarId: number | 220 | avatarId: number |
219 | 221 | ||
220 | @BelongsTo(() => AvatarModel, { | 222 | @ForeignKey(() => ActorImageModel) |
223 | @Column | ||
224 | bannerId: number | ||
225 | |||
226 | @BelongsTo(() => ActorImageModel, { | ||
227 | foreignKey: { | ||
228 | name: 'avatarId', | ||
229 | allowNull: true | ||
230 | }, | ||
231 | as: 'Avatar', | ||
232 | onDelete: 'set null', | ||
233 | hooks: true | ||
234 | }) | ||
235 | Avatar: ActorImageModel | ||
236 | |||
237 | @BelongsTo(() => ActorImageModel, { | ||
221 | foreignKey: { | 238 | foreignKey: { |
239 | name: 'bannerId', | ||
222 | allowNull: true | 240 | allowNull: true |
223 | }, | 241 | }, |
242 | as: 'Banner', | ||
224 | onDelete: 'set null', | 243 | onDelete: 'set null', |
225 | hooks: true | 244 | hooks: true |
226 | }) | 245 | }) |
227 | Avatar: AvatarModel | 246 | Banner: ActorImageModel |
228 | 247 | ||
229 | @HasMany(() => ActorFollowModel, { | 248 | @HasMany(() => ActorFollowModel, { |
230 | foreignKey: { | 249 | foreignKey: { |
@@ -496,7 +515,7 @@ export class ActorModel extends Model { | |||
496 | } | 515 | } |
497 | 516 | ||
498 | toFormattedSummaryJSON (this: MActorSummaryFormattable) { | 517 | toFormattedSummaryJSON (this: MActorSummaryFormattable) { |
499 | let avatar: Avatar = null | 518 | let avatar: ActorImage = null |
500 | if (this.Avatar) { | 519 | if (this.Avatar) { |
501 | avatar = this.Avatar.toFormattedJSON() | 520 | avatar = this.Avatar.toFormattedJSON() |
502 | } | 521 | } |