2018-03-31 19:55:00 +09:00
|
|
|
import create from './create';
|
2018-04-03 17:50:52 +09:00
|
|
|
import performDeleteActivity from './delete';
|
2018-04-02 19:50:40 +09:00
|
|
|
import follow from './follow';
|
2018-04-03 16:33:16 +09:00
|
|
|
import undo from './undo';
|
2018-04-04 23:12:35 +09:00
|
|
|
import { IObject } from '../type';
|
2018-04-05 22:49:41 +09:00
|
|
|
import { IUser } from '../../../models/user';
|
2018-04-04 23:12:35 +09:00
|
|
|
|
2018-04-05 22:49:41 +09:00
|
|
|
export default async (actor: IUser, activity: IObject): Promise<void> => {
|
2018-04-04 23:12:35 +09:00
|
|
|
switch (activity.type) {
|
|
|
|
case 'Create':
|
2018-04-05 01:22:41 +09:00
|
|
|
await create(actor, activity);
|
2018-04-04 23:12:35 +09:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Delete':
|
2018-04-05 01:22:41 +09:00
|
|
|
await performDeleteActivity(actor, activity);
|
2018-04-04 23:12:35 +09:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Follow':
|
2018-04-05 01:22:41 +09:00
|
|
|
await follow(actor, activity);
|
2018-04-04 23:12:35 +09:00
|
|
|
break;
|
|
|
|
|
2018-04-05 19:19:00 +09:00
|
|
|
case 'Accept':
|
|
|
|
// noop
|
|
|
|
break;
|
|
|
|
|
2018-04-04 23:12:35 +09:00
|
|
|
case 'Undo':
|
2018-04-05 01:22:41 +09:00
|
|
|
await undo(actor, activity);
|
2018-04-04 23:12:35 +09:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
console.warn(`unknown activity type: ${activity.type}`);
|
|
|
|
return null;
|
|
|
|
}
|
2018-04-01 21:17:46 +09:00
|
|
|
};
|