Split code
This commit is contained in:
parent
574e3b0bfd
commit
4e9ae8e8d5
6 changed files with 137 additions and 120 deletions
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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue