From 4f2b4366f2f2ed84b8308abeb87eb83ba34aa99e Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Mon, 28 Oct 2019 20:34:01 +0900 Subject: [PATCH] Fix #5539 (#5542) --- src/remote/activitypub/models/person.ts | 6 +++--- src/remote/activitypub/type.ts | 27 +++++++++++++++---------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/remote/activitypub/models/person.ts b/src/remote/activitypub/models/person.ts index 09db5e1aed..198fd78bd5 100644 --- a/src/remote/activitypub/models/person.ts +++ b/src/remote/activitypub/models/person.ts @@ -3,7 +3,7 @@ import * as promiseLimit from 'promise-limit'; import config from '../../../config'; import Resolver from '../resolver'; import { resolveImage } from './image'; -import { isCollectionOrOrderedCollection, isCollection, IPerson } from '../type'; +import { isCollectionOrOrderedCollection, isCollection, IPerson, getApId } from '../type'; import { DriveFile } from '../../../models/entities/drive-file'; import { fromHtml } from '../../../mfm/fromHtml'; import { resolveNote, extractEmojis } from './note'; @@ -152,11 +152,11 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise<Us name: person.name, isLocked: !!person.manuallyApprovesFollowers, username: person.preferredUsername, - usernameLower: person.preferredUsername.toLowerCase(), + usernameLower: person.preferredUsername!.toLowerCase(), host, inbox: person.inbox, sharedInbox: person.sharedInbox || (person.endpoints ? person.endpoints.sharedInbox : undefined), - featured: person.featured, + featured: person.featured ? getApId(person.featured) : undefined, uri: person.id, tags, isBot, diff --git a/src/remote/activitypub/type.ts b/src/remote/activitypub/type.ts index 62475faefc..df9da42fa8 100644 --- a/src/remote/activitypub/type.ts +++ b/src/remote/activitypub/type.ts @@ -100,17 +100,22 @@ export const validActor = ['Person', 'Service']; export interface IPerson extends IObject { type: 'Person'; - name: string; - preferredUsername: string; - manuallyApprovesFollowers: boolean; - inbox: string; - sharedInbox?: string; - publicKey: any; - followers: any; - following: any; - featured?: any; - outbox: any; - endpoints: any; + name?: string; + preferredUsername?: string; + manuallyApprovesFollowers?: boolean; + inbox?: string; + sharedInbox?: string; // 後方互換性のため + publicKey: { + id: string; + publicKeyPem: string; + }; + followers?: string | ICollection | IOrderedCollection; + following?: string | ICollection | IOrderedCollection; + featured?: string | IOrderedCollection; + outbox?: string | IOrderedCollection; + endpoints?: { + sharedInbox?: string; + }; } export const isCollection = (object: IObject): object is ICollection =>