2018-04-07 23:55:26 +02:00
|
|
|
import * as debug from 'debug';
|
|
|
|
|
|
|
|
import Resolver from '../../resolver';
|
|
|
|
import { IRemoteUser } from '../../../../models/user';
|
|
|
|
import announceNote from './note';
|
2018-06-18 07:28:43 +02:00
|
|
|
import { IAnnounce, INote } from '../../type';
|
2018-04-07 23:55:26 +02:00
|
|
|
|
|
|
|
const log = debug('misskey:activitypub');
|
|
|
|
|
|
|
|
export default async (actor: IRemoteUser, activity: IAnnounce): Promise<void> => {
|
|
|
|
const uri = activity.id || activity;
|
|
|
|
|
|
|
|
log(`Announce: ${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 'Note':
|
2018-06-18 07:28:43 +02:00
|
|
|
announceNote(resolver, actor, activity, object as INote);
|
2018-04-07 23:55:26 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
console.warn(`Unknown announce type: ${object.type}`);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|