mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-05-09 23:26:59 +00:00
27 lines
671 B
TypeScript
27 lines
671 B
TypeScript
import act from '../../act';
|
|
import deleteObject from '../../delete';
|
|
import unfollow from './unfollow';
|
|
import Resolver from '../../resolver';
|
|
|
|
export default async (resolver: Resolver, actor, activity): Promise<void> => {
|
|
if ('actor' in activity && actor.account.uri !== activity.actor) {
|
|
throw new Error();
|
|
}
|
|
|
|
const results = await act(resolver, actor, activity.object);
|
|
|
|
await Promise.all(results.map(async promisedResult => {
|
|
const result = await promisedResult;
|
|
|
|
if (result === null || await deleteObject(result) !== null) {
|
|
return;
|
|
}
|
|
|
|
switch (result.object.$ref) {
|
|
case 'following':
|
|
await unfollow(result.object);
|
|
}
|
|
}));
|
|
|
|
return null;
|
|
};
|