From 1a51b9870039da8b328acc673b2e8cb08ae2e663 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 31 Oct 2018 22:35:02 +0900 Subject: Refactor --- src/remote/activitypub/models/person.ts | 5 +++-- src/remote/activitypub/renderer/document.ts | 4 ++-- src/remote/activitypub/renderer/image.ts | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src/remote') diff --git a/src/remote/activitypub/models/person.ts b/src/remote/activitypub/models/person.ts index f115dee87d..7842e87882 100644 --- a/src/remote/activitypub/models/person.ts +++ b/src/remote/activitypub/models/person.ts @@ -15,6 +15,7 @@ import { URL } from 'url'; import { resolveNote } from './note'; import registerInstance from '../../../services/register-instance'; import Instance from '../../../models/instance'; +import getDriveFileUrl from '../../../misc/get-drive-file-url'; const log = debug('misskey:activitypub'); @@ -303,8 +304,8 @@ export async function updatePerson(uri: string, resolver?: Resolver, hint?: obje featured: person.featured, avatarId: avatar ? avatar._id : null, bannerId: banner ? banner._id : null, - avatarUrl: (avatar && avatar.metadata.thumbnailUrl) ? avatar.metadata.thumbnailUrl : (avatar && avatar.metadata.url) ? avatar.metadata.url : null, - bannerUrl: banner && banner.metadata.url ? banner.metadata.url : null, + avatarUrl: getDriveFileUrl(avatar, true), + bannerUrl: getDriveFileUrl(banner, true), description: htmlToMFM(person.summary), followersCount, followingCount, diff --git a/src/remote/activitypub/renderer/document.ts b/src/remote/activitypub/renderer/document.ts index 1f4543d7ee..17721e9417 100644 --- a/src/remote/activitypub/renderer/document.ts +++ b/src/remote/activitypub/renderer/document.ts @@ -1,8 +1,8 @@ -import config from '../../../config'; import { IDriveFile } from '../../../models/drive-file'; +import getDriveFileUrl from '../../../misc/get-drive-file-url'; export default (file: IDriveFile) => ({ type: 'Document', mediaType: file.contentType, - url: file.metadata.url || `${config.drive_url}/${file._id}` + url: getDriveFileUrl(file) }); diff --git a/src/remote/activitypub/renderer/image.ts b/src/remote/activitypub/renderer/image.ts index b2f2555003..ec637b9521 100644 --- a/src/remote/activitypub/renderer/image.ts +++ b/src/remote/activitypub/renderer/image.ts @@ -1,8 +1,8 @@ -import config from '../../../config'; import { IDriveFile } from '../../../models/drive-file'; +import getDriveFileUrl from '../../../misc/get-drive-file-url'; export default (file: IDriveFile) => ({ type: 'Image', - url: file.metadata.url || `${config.drive_url}/${file._id}`, + url: getDriveFileUrl(file), sensitive: file.metadata.isSensitive }); -- cgit v1.2.3-freya