1
0
mirror of https://github.com/hotomoe/hotomoe synced 2025-01-09 19:32:53 +09:00
hotomoe/src/remote/activitypub/act/index.ts
2018-04-07 00:07:30 +09:00

42 lines
790 B
TypeScript

import create from './create';
import performDeleteActivity from './delete';
import follow from './follow';
import undo from './undo';
import { IObject } from '../type';
import { IRemoteUser } from '../../../models/user';
const self = async (actor: IRemoteUser, activity: IObject): 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':
// noop
break;
case 'Undo':
await undo(actor, activity);
break;
case 'Collection':
case 'OrderedCollection':
// TODO
break;
default:
console.warn(`unknown activity type: ${activity.type}`);
return null;
}
};
export default self;