2018-03-31 10:55:00 +00:00
|
|
|
import create from './create';
|
2018-04-02 10:50:40 +00:00
|
|
|
import follow from './follow';
|
2018-03-31 10:55:00 +00:00
|
|
|
import createObject from '../create';
|
|
|
|
import Resolver from '../resolver';
|
|
|
|
|
2018-04-02 08:11:14 +00:00
|
|
|
export default (actor, value, distribute) => {
|
2018-04-01 12:19:39 +00:00
|
|
|
return new Resolver().resolve(value).then(resolved => Promise.all(resolved.map(async promisedResult => {
|
|
|
|
const { resolver, object } = await promisedResult;
|
2018-04-02 08:11:14 +00:00
|
|
|
const created = await (await createObject(resolver, actor, [object], distribute))[0];
|
2018-03-31 10:55:00 +00:00
|
|
|
|
|
|
|
if (created !== null) {
|
|
|
|
return created;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (object.type) {
|
|
|
|
case 'Create':
|
2018-04-02 08:11:14 +00:00
|
|
|
return create(resolver, actor, object, distribute);
|
2018-03-31 10:55:00 +00:00
|
|
|
|
2018-04-02 10:50:40 +00:00
|
|
|
case 'Follow':
|
|
|
|
return follow(actor, object);
|
|
|
|
|
2018-03-31 10:55:00 +00:00
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
})));
|
2018-04-01 12:17:46 +00:00
|
|
|
};
|