monkeeShark/src/common/remote/activitypub/act/index.ts

23 lines
548 B
TypeScript
Raw Normal View History

2018-03-31 10:55:00 +00:00
import create from './create';
import createObject from '../create';
import Resolver from '../resolver';
export default (actor, value) => {
2018-04-01 12:16:37 +00:00
return new Resolver().resolve(value).then(resolved => Promise.all(resolved.map(async asyncResult => {
2018-03-31 10:55:00 +00:00
const { resolver, object } = await asyncResult;
const created = await (await createObject(resolver, actor, [object]))[0];
if (created !== null) {
return created;
}
switch (object.type) {
case 'Create':
return create(resolver, actor, object);
default:
return null;
}
})));
2018-04-01 12:17:46 +00:00
};