rudeshark.net/src/remote/activitypub/kernel/create/index.ts
MeiMei 0141affe05 Fix: AP object / actor type (#5086)
* attributedToがArrayの場合などに対応

* attachment以外で来るDocument系のObjectに対応

* Renote, Reply 対応

* 表示をいい感じに

* fix type

* revert as const

* Fix Note / Question type

* attributedToのtypeで複合配列を想定する
2019-06-28 18:54:09 +09:00

31 lines
732 B
TypeScript

import Resolver from '../../resolver';
import { IRemoteUser } from '../../../../models/entities/user';
import createNote from './note';
import { ICreate, getApId, validPost } from '../../type';
import { apLogger } from '../../logger';
const logger = apLogger;
export default async (actor: IRemoteUser, activity: ICreate): Promise<void> => {
const uri = getApId(activity);
logger.info(`Create: ${uri}`);
const resolver = new Resolver();
let object;
try {
object = await resolver.resolve(activity.object);
} catch (e) {
logger.error(`Resolution failed: ${e}`);
throw e;
}
if (validPost.includes(object.type)) {
createNote(resolver, actor, object);
} else {
logger.warn(`Unknown type: ${object.type}`);
}
};