Sharkey/src/remote/activitypub/act/index.ts

30 lines
602 B
TypeScript
Raw Normal View History

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