mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-05 20:35:57 +02:00
Split code
This commit is contained in:
19
src/remote/activitypub/act/create/image.ts
Normal file
19
src/remote/activitypub/act/create/image.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import * as debug from 'debug';
|
||||
|
||||
import Resolver from '../../resolver';
|
||||
import uploadFromUrl from '../../../../services/drive/upload-from-url';
|
||||
import { IRemoteUser } from '../../../../models/user';
|
||||
import { IDriveFile } from '../../../../models/drive-file';
|
||||
|
||||
const log = debug('misskey:activitypub');
|
||||
|
||||
export default async function(resolver: Resolver, actor: IRemoteUser, image): Promise<IDriveFile> {
|
||||
if ('attributedTo' in image && actor.account.uri !== image.attributedTo) {
|
||||
log(`invalid image: ${JSON.stringify(image, null, 2)}`);
|
||||
throw new Error('invalid image');
|
||||
}
|
||||
|
||||
log(`Creating the Image: ${image.id}`);
|
||||
|
||||
return await uploadFromUrl(image.url, actor);
|
||||
}
|
||||
Reference in New Issue
Block a user