summaryrefslogtreecommitdiff
path: root/src/remote/activitypub/act/index.ts
blob: 5be07c478ec571573f617399ec4f8e4c2a37ae5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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;