Implement unfollow by remote account
This commit is contained in:
parent
1a347ae9a0
commit
6b66ec1231
6 changed files with 108 additions and 37 deletions
23
src/remote/activitypub/act/undo/index.ts
Normal file
23
src/remote/activitypub/act/undo/index.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import act from '../../act';
|
||||
import unfollow from './unfollow';
|
||||
|
||||
export default async (resolver, actor, activity) => {
|
||||
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 result => {
|
||||
if (result === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (result.object.$ref) {
|
||||
case 'following':
|
||||
await unfollow(result.resolver, result.object);
|
||||
}
|
||||
}));
|
||||
|
||||
return null;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue