diff options
Diffstat (limited to 'server/models/activitypub')
-rw-r--r-- | server/models/activitypub/actor-follow.ts | 3 | ||||
-rw-r--r-- | server/models/activitypub/actor.ts | 32 |
2 files changed, 26 insertions, 9 deletions
diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts index 8ef770cd4..c8b3aae9f 100644 --- a/server/models/activitypub/actor-follow.ts +++ b/server/models/activitypub/actor-follow.ts | |||
@@ -32,6 +32,7 @@ import { | |||
32 | MActorFollowActorsDefault, | 32 | MActorFollowActorsDefault, |
33 | MActorFollowActorsDefaultSubscription, | 33 | MActorFollowActorsDefaultSubscription, |
34 | MActorFollowFollowingHost, | 34 | MActorFollowFollowingHost, |
35 | MActorFollowFormattable, | ||
35 | MActorFollowSubscriptions | 36 | MActorFollowSubscriptions |
36 | } from '@server/typings/models' | 37 | } from '@server/typings/models' |
37 | 38 | ||
@@ -580,7 +581,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> { | |||
580 | return ActorFollowModel.findAll(query) | 581 | return ActorFollowModel.findAll(query) |
581 | } | 582 | } |
582 | 583 | ||
583 | toFormattedJSON (): ActorFollow { | 584 | toFormattedJSON (this: MActorFollowFormattable): ActorFollow { |
584 | const follower = this.ActorFollower.toFormattedJSON() | 585 | const follower = this.ActorFollower.toFormattedJSON() |
585 | const following = this.ActorFollowing.toFormattedJSON() | 586 | const following = this.ActorFollowing.toFormattedJSON() |
586 | 587 | ||
diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts index 2312127b4..e2213afa1 100644 --- a/server/models/activitypub/actor.ts +++ b/server/models/activitypub/actor.ts | |||
@@ -36,7 +36,16 @@ import { isOutdated, throwIfNotValid } from '../utils' | |||
36 | import { VideoChannelModel } from '../video/video-channel' | 36 | import { VideoChannelModel } from '../video/video-channel' |
37 | import { ActorFollowModel } from './actor-follow' | 37 | import { ActorFollowModel } from './actor-follow' |
38 | import { VideoModel } from '../video/video' | 38 | import { VideoModel } from '../video/video' |
39 | import { MActor, MActorAccountChannelId, MActorFull } from '../../typings/models' | 39 | import { |
40 | MActor, | ||
41 | MActorAccountChannelId, | ||
42 | MActorFormattable, | ||
43 | MActorFull, MActorHost, | ||
44 | MActorServer, | ||
45 | MActorSummaryFormattable, | ||
46 | MServerHost, | ||
47 | MActorRedundancyAllowed | ||
48 | } from '../../typings/models' | ||
40 | import * as Bluebird from 'bluebird' | 49 | import * as Bluebird from 'bluebird' |
41 | 50 | ||
42 | enum ScopeNames { | 51 | enum ScopeNames { |
@@ -393,24 +402,31 @@ export class ActorModel extends Model<ActorModel> { | |||
393 | }) | 402 | }) |
394 | } | 403 | } |
395 | 404 | ||
396 | toFormattedJSON () { | 405 | toFormattedSummaryJSON (this: MActorSummaryFormattable) { |
397 | let avatar: Avatar = null | 406 | let avatar: Avatar = null |
398 | if (this.Avatar) { | 407 | if (this.Avatar) { |
399 | avatar = this.Avatar.toFormattedJSON() | 408 | avatar = this.Avatar.toFormattedJSON() |
400 | } | 409 | } |
401 | 410 | ||
402 | return { | 411 | return { |
403 | id: this.id, | ||
404 | url: this.url, | 412 | url: this.url, |
405 | name: this.preferredUsername, | 413 | name: this.preferredUsername, |
406 | host: this.getHost(), | 414 | host: this.getHost(), |
415 | avatar | ||
416 | } | ||
417 | } | ||
418 | |||
419 | toFormattedJSON (this: MActorFormattable) { | ||
420 | const base = this.toFormattedSummaryJSON() | ||
421 | |||
422 | return Object.assign(base, { | ||
423 | id: this.id, | ||
407 | hostRedundancyAllowed: this.getRedundancyAllowed(), | 424 | hostRedundancyAllowed: this.getRedundancyAllowed(), |
408 | followingCount: this.followingCount, | 425 | followingCount: this.followingCount, |
409 | followersCount: this.followersCount, | 426 | followersCount: this.followersCount, |
410 | avatar, | ||
411 | createdAt: this.createdAt, | 427 | createdAt: this.createdAt, |
412 | updatedAt: this.updatedAt | 428 | updatedAt: this.updatedAt |
413 | } | 429 | }) |
414 | } | 430 | } |
415 | 431 | ||
416 | toActivityPubObject (name: string, type: 'Account' | 'Application' | 'VideoChannel') { | 432 | toActivityPubObject (name: string, type: 'Account' | 'Application' | 'VideoChannel') { |
@@ -500,7 +516,7 @@ export class ActorModel extends Model<ActorModel> { | |||
500 | return this.serverId === null | 516 | return this.serverId === null |
501 | } | 517 | } |
502 | 518 | ||
503 | getWebfingerUrl () { | 519 | getWebfingerUrl (this: MActorServer) { |
504 | return 'acct:' + this.preferredUsername + '@' + this.getHost() | 520 | return 'acct:' + this.preferredUsername + '@' + this.getHost() |
505 | } | 521 | } |
506 | 522 | ||
@@ -508,11 +524,11 @@ export class ActorModel extends Model<ActorModel> { | |||
508 | return this.Server ? `${this.preferredUsername}@${this.Server.host}` : this.preferredUsername | 524 | return this.Server ? `${this.preferredUsername}@${this.Server.host}` : this.preferredUsername |
509 | } | 525 | } |
510 | 526 | ||
511 | getHost () { | 527 | getHost (this: MActorHost) { |
512 | return this.Server ? this.Server.host : WEBSERVER.HOST | 528 | return this.Server ? this.Server.host : WEBSERVER.HOST |
513 | } | 529 | } |
514 | 530 | ||
515 | getRedundancyAllowed () { | 531 | getRedundancyAllowed (this: MActorRedundancyAllowed) { |
516 | return this.Server ? this.Server.redundancyAllowed : false | 532 | return this.Server ? this.Server.redundancyAllowed : false |
517 | } | 533 | } |
518 | 534 | ||