1
0
mirror of https://github.com/misskey-dev/misskey synced 2024-12-27 04:59:10 +09:00
misskey/src/remote/activitypub/objects/image.ts

30 lines
908 B
TypeScript
Raw Normal View History

2018-04-09 04:08:56 +09:00
import * as debug from 'debug';
import uploadFromUrl from '../../../services/drive/upload-from-url';
import { IRemoteUser } from '../../../models/user';
import { IDriveFile } from '../../../models/drive-file';
const log = debug('misskey:activitypub');
/**
* Imageを作成します
*/
export async function createImage(actor: IRemoteUser, image): Promise<IDriveFile> {
log(`Creating the Image: ${image.url}`);
return await uploadFromUrl(image.url, actor);
}
/**
* Imageを解決します
*
* Misskeyに対象のImageが登録されていればそれを返し
* Misskeyに登録しそれを返します
*/
export async function resolveImage(actor: IRemoteUser, value: any): Promise<IDriveFile> {
// TODO
// リモートサーバーからフェッチしてきて登録
return await createImage(actor, value);
}