2018-05-31 10:42:37 -05:00
|
|
|
import * as debug from 'debug';
|
|
|
|
|
|
|
|
import Resolver from '../../resolver';
|
|
|
|
import { IRemoteUser } from '../../../../models/user';
|
|
|
|
import rejectFollow from './follow';
|
2018-06-18 00:28:43 -05:00
|
|
|
import { IReject, IFollow } from '../../type';
|
2018-05-31 10:42:37 -05:00
|
|
|
|
|
|
|
const log = debug('misskey:activitypub');
|
|
|
|
|
|
|
|
export default async (actor: IRemoteUser, activity: IReject): Promise<void> => {
|
|
|
|
const uri = activity.id || activity;
|
|
|
|
|
|
|
|
log(`Reject: ${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':
|
2018-06-18 00:28:43 -05:00
|
|
|
rejectFollow(actor, object as IFollow);
|
2018-05-31 10:42:37 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
console.warn(`Unknown reject type: ${object.type}`);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|