wip
This commit is contained in:
parent
fba46b4c7f
commit
eb304cb5fb
8 changed files with 114 additions and 108 deletions
25
src/remote/activitypub/act/unfollow.ts
Normal file
25
src/remote/activitypub/act/unfollow.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import parseAcct from '../../../acct/parse';
|
||||
import User from '../../../models/user';
|
||||
import config from '../../../config';
|
||||
import unfollow from '../../../api/following/delete';
|
||||
|
||||
export default async (actor, activity): Promise<void> => {
|
||||
const prefix = config.url + '/@';
|
||||
const id = activity.object.id || activity.object;
|
||||
|
||||
if (!id.startsWith(prefix)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { username, host } = parseAcct(id.slice(prefix.length));
|
||||
if (host !== null) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
const followee = await User.findOne({ username, host });
|
||||
if (followee === null) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
await unfollow(actor, followee, activity);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue