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-03-31 13:55:00 +03:00
|
|
|
import createObject from '../create';
|
2018-04-03 14:09:26 +03:00
|
|
|
import Resolver from '../resolver';
|
2018-03-31 13:55:00 +03:00
|
|
|
|
2018-04-03 14:39:27 +03:00
|
|
|
export default async (parentResolver: Resolver, actor, value, distribute?: boolean) => {
|
|
|
|
const collection = await parentResolver.resolveCollection(value);
|
|
|
|
|
|
|
|
return collection.object.map(async element => {
|
|
|
|
const { resolver, object } = await collection.resolver.resolveOne(element);
|
|
|
|
const created = await (await createObject(resolver, actor, [object], distribute))[0];
|
2018-03-31 13:55:00 +03:00
|
|
|
|
|
|
|
if (created !== null) {
|
|
|
|
return created;
|
|
|
|
}
|
|
|
|
|
2018-04-03 14:39:27 +03:00
|
|
|
switch (object.type) {
|
2018-03-31 13:55:00 +03:00
|
|
|
case 'Create':
|
2018-04-03 14:39:27 +03:00
|
|
|
return create(resolver, actor, object, distribute);
|
2018-03-31 13:55:00 +03:00
|
|
|
|
2018-04-03 11:50:52 +03:00
|
|
|
case 'Delete':
|
|
|
|
return performDeleteActivity(resolver, actor, object);
|
|
|
|
|
2018-04-02 13:50:40 +03:00
|
|
|
case 'Follow':
|
2018-04-03 14:39:27 +03:00
|
|
|
return follow(resolver, actor, object, distribute);
|
2018-04-03 10:33:16 +03:00
|
|
|
|
|
|
|
case 'Undo':
|
2018-04-03 14:39:27 +03:00
|
|
|
return undo(resolver, actor, object);
|
2018-04-02 13:50:40 +03:00
|
|
|
|
2018-03-31 13:55:00 +03:00
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
2018-04-03 14:39:27 +03:00
|
|
|
});
|
2018-04-01 15:17:46 +03:00
|
|
|
};
|