wip
This commit is contained in:
parent
08beb45935
commit
536277122d
13 changed files with 7 additions and 0 deletions
24
src/remote/activitypub/kernel/undo/follow.ts
Normal file
24
src/remote/activitypub/kernel/undo/follow.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import User, { IRemoteUser } from '../../../../models/user';
|
||||
import config from '../../../../config';
|
||||
import unfollow from '../../../../services/following/delete';
|
||||
import { IFollow } from '../../type';
|
||||
|
||||
export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
||||
const id = typeof activity.object == 'string' ? activity.object : activity.object.id;
|
||||
|
||||
if (!id.startsWith(config.url + '/')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const followee = await User.findOne({ _id: id.split('/').pop() });
|
||||
|
||||
if (followee === null) {
|
||||
throw new Error('followee not found');
|
||||
}
|
||||
|
||||
if (followee.host != null) {
|
||||
throw new Error('フォロー解除しようとしているユーザーはローカルユーザーではありません');
|
||||
}
|
||||
|
||||
await unfollow(actor, followee, activity);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue