From 37b053258bcfcc2cec6fe16f691ef81806d58bbc Mon Sep 17 00:00:00 2001 From: mei23 Date: Sun, 21 Apr 2024 05:27:52 +0900 Subject: [PATCH] Fix attachment/Document detection --- src/remote/activitypub/models/image.ts | 9 ++++++--- src/remote/activitypub/type.ts | 7 +++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/remote/activitypub/models/image.ts b/src/remote/activitypub/models/image.ts index 8c3a34e7d6..969a5076f3 100644 --- a/src/remote/activitypub/models/image.ts +++ b/src/remote/activitypub/models/image.ts @@ -6,13 +6,14 @@ import { apLogger } from '../logger'; import { DriveFile } from '../../../models/entities/drive-file'; import { DriveFiles } from '../../../models'; import { ensure } from '../../../prelude/ensure'; +import { isDocument } from '../type'; const logger = apLogger; /** * Imageを作成します。 */ -export async function createImage(actor: IRemoteUser, value: any): Promise { +export async function createImage(actor: IRemoteUser, value: any): Promise { // 投稿者が凍結されていたらスキップ if (actor.isSuspended) { throw new Error('actor has been suspended'); @@ -20,8 +21,10 @@ export async function createImage(actor: IRemoteUser, value: any): Promise { +export async function resolveImage(actor: IRemoteUser, value: any): Promise { // TODO // リモートサーバーからフェッチしてきて登録 diff --git a/src/remote/activitypub/type.ts b/src/remote/activitypub/type.ts index 0ffe82ba57..89d4c79ad7 100644 --- a/src/remote/activitypub/type.ts +++ b/src/remote/activitypub/type.ts @@ -178,6 +178,13 @@ export const isOrderedCollection = (object: IObject): object is IOrderedCollecti export const isCollectionOrOrderedCollection = (object: IObject): object is ICollection | IOrderedCollection => isCollection(object) || isOrderedCollection(object); +export interface IApDocument extends IObject { + type: 'Audio' | 'Document' | 'Image' | 'Page' | 'Video'; +} + +export const isDocument = (object: IObject): object is IApDocument => + ['Audio', 'Document', 'Image', 'Page', 'Video'].includes(getApType(object)); + export interface IApPropertyValue extends IObject { type: 'PropertyValue'; identifier: IApPropertyValue;