From a8d05cba5a2ae5da44c47e37167f279ff0fe5f50 Mon Sep 17 00:00:00 2001 From: syuilo <syuilotan@yahoo.co.jp> Date: Wed, 7 Nov 2018 19:43:21 +0900 Subject: [PATCH] Fix #3149 --- src/remote/activitypub/models/image.ts | 6 +++++- src/services/drive/upload-from-url.ts | 8 +++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/remote/activitypub/models/image.ts b/src/remote/activitypub/models/image.ts index 76e1bac90..ae353f5ef 100644 --- a/src/remote/activitypub/models/image.ts +++ b/src/remote/activitypub/models/image.ts @@ -4,6 +4,7 @@ import uploadFromUrl from '../../../services/drive/upload-from-url'; import { IRemoteUser } from '../../../models/user'; import DriveFile, { IDriveFile } from '../../../models/drive-file'; import Resolver from '../resolver'; +import fetchMeta from '../../../misc/fetch-meta'; const log = debug('misskey:activitypub'); @@ -24,7 +25,10 @@ export async function createImage(actor: IRemoteUser, value: any): Promise<IDriv log(`Creating the Image: ${image.url}`); - let file = await uploadFromUrl(image.url, actor, null, image.url, image.sensitive); + const instance = await fetchMeta(); + const cache = instance.cacheRemoteFiles; + + let file = await uploadFromUrl(image.url, actor, null, image.url, image.sensitive, false, !cache); if (file.metadata.isRemote) { // URLが異なっている場合、同じ画像が以前に異なるURLで登録されていたということなので、 diff --git a/src/services/drive/upload-from-url.ts b/src/services/drive/upload-from-url.ts index fa37615a9..ac1b04f5b 100644 --- a/src/services/drive/upload-from-url.ts +++ b/src/services/drive/upload-from-url.ts @@ -10,7 +10,6 @@ import create from './add-file'; import config from '../../config'; import { IUser } from '../../models/user'; import * as mongodb from 'mongodb'; -import fetchMeta from '../../misc/fetch-meta'; const log = debug('misskey:drive:upload-from-url'); @@ -20,7 +19,8 @@ export default async ( folderId: mongodb.ObjectID = null, uri: string = null, sensitive = false, - force = false + force = false, + link = false ): Promise<IDriveFile> => { log(`REQUESTED: ${url}`); @@ -77,13 +77,11 @@ export default async ( }); }); - const instance = await fetchMeta(); - let driveFile: IDriveFile; let error; try { - driveFile = await create(user, path, name, null, folderId, force, !instance.cacheRemoteFiles, url, uri, sensitive); + driveFile = await create(user, path, name, null, folderId, force, link, url, uri, sensitive); log(`got: ${driveFile._id}`); } catch (e) { error = e;