1
0
mirror of https://github.com/misskey-dev/misskey synced 2024-12-25 20:18:28 +09:00
misskey/src/remote/activitypub/kernel/index.ts
2019-02-03 18:16:57 +09:00

74 lines
1.4 KiB
TypeScript

import { Object } from '../type';
import { IRemoteUser } from '../../../models/user';
import create from './create';
import performDeleteActivity from './delete';
import follow from './follow';
import undo from './undo';
import like from './like';
import announce from './announce';
import accept from './accept';
import reject from './reject';
import add from './add';
import remove from './remove';
import block from './block';
import { apLogger } from '../logger';
const self = async (actor: IRemoteUser, activity: Object): Promise<void> => {
switch (activity.type) {
case 'Create':
await create(actor, activity);
break;
case 'Delete':
await performDeleteActivity(actor, activity);
break;
case 'Follow':
await follow(actor, activity);
break;
case 'Accept':
await accept(actor, activity);
break;
case 'Reject':
await reject(actor, activity);
break;
case 'Add':
await add(actor, activity).catch(err => apLogger.error(err));
break;
case 'Remove':
await remove(actor, activity).catch(err => apLogger.error(err));
break;
case 'Announce':
await announce(actor, activity);
break;
case 'Like':
await like(actor, activity);
break;
case 'Undo':
await undo(actor, activity);
break;
case 'Block':
await block(actor, activity);
break;
case 'Collection':
case 'OrderedCollection':
// TODO
break;
default:
apLogger.warn(`unknown activity type: ${(activity as any).type}`);
return null;
}
};
export default self;