2018-04-03 16:33:16 +09:00
|
|
|
import act from '../../act';
|
|
|
|
|
import unfollow from './unfollow';
|
2018-04-03 20:09:26 +09:00
|
|
|
import Resolver from '../../resolver';
|
2018-04-03 16:33:16 +09:00
|
|
|
|
2018-04-03 23:59:03 +09:00
|
|
|
export default async (resolver: Resolver, actor, activity): Promise<void> => {
|
2018-04-03 16:33:16 +09:00
|
|
|
if ('actor' in activity && actor.account.uri !== activity.actor) {
|
|
|
|
|
throw new Error();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const results = await act(resolver, actor, activity.object);
|
|
|
|
|
|
2018-04-03 22:19:11 +09:00
|
|
|
await Promise.all(results.map(async promisedResult => {
|
|
|
|
|
const result = await promisedResult;
|
|
|
|
|
|
2018-04-03 16:33:16 +09:00
|
|
|
if (result === null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (result.object.$ref) {
|
|
|
|
|
case 'following':
|
2018-04-03 17:18:06 +09:00
|
|
|
await unfollow(result.object);
|
2018-04-03 16:33:16 +09:00
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
};
|