From e3bdab7cfcdca6962dbe7c060b3ee2353926d19e Mon Sep 17 00:00:00 2001 From: atsu1125 Date: Wed, 1 May 2024 14:20:58 +0900 Subject: [PATCH] Fix attachment/Document detection --- src/remote/activitypub/models/image.ts | 11 +++++++---- src/remote/activitypub/type.ts | 8 ++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/remote/activitypub/models/image.ts b/src/remote/activitypub/models/image.ts index be3e67896d..e56534e8f4 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 { - // TODO +export async function resolveImage(actor: IRemoteUser, value: any): Promise { + // TODO: Misskeyに対象のImageが登録されていればそれを返す // リモートサーバーからフェッチしてきて登録 return await createImage(actor, value); diff --git a/src/remote/activitypub/type.ts b/src/remote/activitypub/type.ts index 9cc25a294c..cae2800fb1 100644 --- a/src/remote/activitypub/type.ts +++ b/src/remote/activitypub/type.ts @@ -171,6 +171,14 @@ 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(object.type); + export interface IApPropertyValue extends IObject { type: 'PropertyValue'; identifier: IApPropertyValue;