2018-03-31 10:55:00 +00:00
|
|
|
import create from './create';
|
2018-04-03 08:50:52 +00:00
|
|
|
import performDeleteActivity from './delete';
|
2018-04-02 10:50:40 +00:00
|
|
|
import follow from './follow';
|
2018-04-03 07:33:16 +00:00
|
|
|
import undo from './undo';
|
2018-04-07 07:36:40 +00:00
|
|
|
import { Object } from '../type';
|
2018-04-06 10:26:17 +00:00
|
|
|
import { IRemoteUser } from '../../../models/user';
|
2018-04-04 14:12:35 +00:00
|
|
|
|
2018-04-07 07:36:40 +00:00
|
|
|
const self = async (actor: IRemoteUser, activity: Object): Promise<void> => {
|
2018-04-04 14:12:35 +00:00
|
|
|
switch (activity.type) {
|
|
|
|
case 'Create':
|
2018-04-04 16:22:41 +00:00
|
|
|
await create(actor, activity);
|
2018-04-04 14:12:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Delete':
|
2018-04-04 16:22:41 +00:00
|
|
|
await performDeleteActivity(actor, activity);
|
2018-04-04 14:12:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Follow':
|
2018-04-04 16:22:41 +00:00
|
|
|
await follow(actor, activity);
|
2018-04-04 14:12:35 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-05 10:19:00 +00:00
|
|
|
case 'Accept':
|
|
|
|
// noop
|
|
|
|
break;
|
|
|
|
|
2018-04-04 14:12:35 +00:00
|
|
|
case 'Undo':
|
2018-04-04 16:22:41 +00:00
|
|
|
await undo(actor, activity);
|
2018-04-04 14:12:35 +00:00
|
|
|
break;
|
|
|
|
|
2018-04-06 15:07:30 +00:00
|
|
|
case 'Collection':
|
|
|
|
case 'OrderedCollection':
|
|
|
|
// TODO
|
|
|
|
break;
|
|
|
|
|
2018-04-04 14:12:35 +00:00
|
|
|
default:
|
|
|
|
console.warn(`unknown activity type: ${activity.type}`);
|
|
|
|
return null;
|
|
|
|
}
|
2018-04-01 12:17:46 +00:00
|
|
|
};
|
2018-04-06 15:07:30 +00:00
|
|
|
|
|
|
|
export default self;
|