2018-04-07 17:05:14 +09:00
|
|
|
import { Object } from '../type';
|
|
|
|
import { IRemoteUser } from '../../../models/user';
|
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-07 17:05:14 +09:00
|
|
|
import like from './like';
|
2018-04-08 06:55:26 +09:00
|
|
|
import announce from './announce';
|
2018-06-01 00:42:37 +09:00
|
|
|
import accept from './accept';
|
|
|
|
import reject from './reject';
|
2018-10-02 16:27:36 +09:00
|
|
|
import add from './add';
|
|
|
|
import remove from './remove';
|
2018-10-29 20:32:42 +09:00
|
|
|
import block from './block';
|
2019-02-03 18:16:57 +09:00
|
|
|
import { apLogger } from '../logger';
|
2018-04-04 23:12:35 +09:00
|
|
|
|
2018-04-07 16:36:40 +09:00
|
|
|
const self = async (actor: IRemoteUser, activity: Object): 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':
|
2018-06-01 00:42:37 +09:00
|
|
|
await accept(actor, activity);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Reject':
|
|
|
|
await reject(actor, activity);
|
2018-04-05 19:19:00 +09:00
|
|
|
break;
|
|
|
|
|
2018-10-02 16:27:36 +09:00
|
|
|
case 'Add':
|
2019-02-03 18:16:57 +09:00
|
|
|
await add(actor, activity).catch(err => apLogger.error(err));
|
2018-10-02 16:27:36 +09:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Remove':
|
2019-02-03 18:16:57 +09:00
|
|
|
await remove(actor, activity).catch(err => apLogger.error(err));
|
2018-10-02 16:27:36 +09:00
|
|
|
break;
|
|
|
|
|
2018-04-08 06:55:26 +09:00
|
|
|
case 'Announce':
|
|
|
|
await announce(actor, activity);
|
|
|
|
break;
|
|
|
|
|
2018-04-07 17:05:14 +09:00
|
|
|
case 'Like':
|
|
|
|
await like(actor, activity);
|
|
|
|
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;
|
|
|
|
|
2018-10-29 20:32:42 +09:00
|
|
|
case 'Block':
|
|
|
|
await block(actor, activity);
|
|
|
|
break;
|
|
|
|
|
2018-04-07 00:07:30 +09:00
|
|
|
case 'Collection':
|
|
|
|
case 'OrderedCollection':
|
|
|
|
// TODO
|
|
|
|
break;
|
|
|
|
|
2018-04-04 23:12:35 +09:00
|
|
|
default:
|
2019-02-03 18:16:57 +09:00
|
|
|
apLogger.warn(`unknown activity type: ${(activity as any).type}`);
|
2018-04-04 23:12:35 +09:00
|
|
|
return null;
|
|
|
|
}
|
2018-04-01 21:17:46 +09:00
|
|
|
};
|
2018-04-07 00:07:30 +09:00
|
|
|
|
|
|
|
export default self;
|