2018-05-31 15:42:37 +00:00
|
|
|
import Resolver from '../../resolver';
|
2019-04-07 12:50:36 +00:00
|
|
|
import { IRemoteUser } from '../../../../models/entities/user';
|
2018-05-31 15:42:37 +00:00
|
|
|
import rejectFollow from './follow';
|
2018-06-18 05:28:43 +00:00
|
|
|
import { IReject, IFollow } from '../../type';
|
2019-02-03 09:16:57 +00:00
|
|
|
import { apLogger } from '../../logger';
|
2018-05-31 15:42:37 +00:00
|
|
|
|
2019-02-03 09:16:57 +00:00
|
|
|
const logger = apLogger;
|
2018-05-31 15:42:37 +00:00
|
|
|
|
|
|
|
export default async (actor: IRemoteUser, activity: IReject): Promise<void> => {
|
|
|
|
const uri = activity.id || activity;
|
|
|
|
|
2019-02-03 09:16:57 +00:00
|
|
|
logger.info(`Reject: ${uri}`);
|
2018-05-31 15:42:37 +00:00
|
|
|
|
|
|
|
const resolver = new Resolver();
|
|
|
|
|
2019-11-17 21:23:44 +00:00
|
|
|
const object = await resolver.resolve(activity.object).catch(e => {
|
2019-02-03 09:16:57 +00:00
|
|
|
logger.error(`Resolution failed: ${e}`);
|
2018-05-31 15:42:37 +00:00
|
|
|
throw e;
|
2019-11-17 21:23:44 +00:00
|
|
|
});
|
2018-05-31 15:42:37 +00:00
|
|
|
|
|
|
|
switch (object.type) {
|
|
|
|
case 'Follow':
|
2018-06-18 05:28:43 +00:00
|
|
|
rejectFollow(actor, object as IFollow);
|
2018-05-31 15:42:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2019-02-03 09:16:57 +00:00
|
|
|
logger.warn(`Unknown reject type: ${object.type}`);
|
2018-05-31 15:42:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|