2022-02-27 03:07:39 +01:00
|
|
|
import { IRemoteUser } from '@/models/entities/user.js';
|
|
|
|
import follow from '@/services/following/create.js';
|
|
|
|
import { IFollow } from '../type.js';
|
|
|
|
import DbResolver from '../db-resolver.js';
|
2018-04-02 12:50:40 +02:00
|
|
|
|
2020-05-09 01:21:42 +02:00
|
|
|
export default async (actor: IRemoteUser, activity: IFollow): Promise<string> => {
|
|
|
|
const dbResolver = new DbResolver();
|
|
|
|
const followee = await dbResolver.getUserFromApId(activity.object);
|
2018-04-02 12:50:40 +02:00
|
|
|
|
2019-04-07 14:50:36 +02:00
|
|
|
if (followee == null) {
|
2020-05-09 01:21:42 +02:00
|
|
|
return `skip: followee not found`;
|
2018-04-08 08:15:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (followee.host != null) {
|
2020-05-09 01:21:42 +02:00
|
|
|
return `skip: フォローしようとしているユーザーはローカルユーザーではありません`;
|
2018-04-02 12:50:40 +02:00
|
|
|
}
|
|
|
|
|
2018-10-15 09:51:23 +02:00
|
|
|
await follow(actor, followee, activity.id);
|
2020-05-09 01:21:42 +02:00
|
|
|
return `ok`;
|
2018-04-02 12:50:40 +02:00
|
|
|
};
|