2021-08-19 14:55:45 +02:00
|
|
|
import { IRemoteUser } from '@/models/entities/user';
|
|
|
|
import follow from '@/services/following/create';
|
|
|
|
import { IFollow } from '../type';
|
|
|
|
import DbResolver from '../db-resolver';
|
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
|
|
|
};
|