hippofish/src/remote/activitypub/kernel/accept/index.ts
2018-06-18 14:28:43 +09:00

35 lines
744 B
TypeScript

import * as debug from 'debug';
import Resolver from '../../resolver';
import { IRemoteUser } from '../../../../models/user';
import acceptFollow from './follow';
import { IAccept, IFollow } from '../../type';
const log = debug('misskey:activitypub');
export default async (actor: IRemoteUser, activity: IAccept): Promise<void> => {
const uri = activity.id || activity;
log(`Accept: ${uri}`);
const resolver = new Resolver();
let object;
try {
object = await resolver.resolve(activity.object);
} catch (e) {
log(`Resolution failed: ${e}`);
throw e;
}
switch (object.type) {
case 'Follow':
acceptFollow(actor, object as IFollow);
break;
default:
console.warn(`Unknown accept type: ${object.type}`);
break;
}
};