APリファクタとLD-Signatureの検証に対応 (#6300)
* DbResolver * inbox types * 認証順を変更 * User/Keyあたりをまとめる * LD-Signatue * Validate contexts url * LD-Signature DocumentLoaderにProxyとTimeout
This commit is contained in:
parent
234294d564
commit
070f1f3c6e
20 changed files with 1052 additions and 233 deletions
|
|
@ -1,28 +1,34 @@
|
|||
import { IRemoteUser } from '../../../../models/entities/user';
|
||||
import { IUpdate, IObject } from '../../type';
|
||||
import { IUpdate, validActor } from '../../type';
|
||||
import { apLogger } from '../../logger';
|
||||
import { updateQuestion } from '../../models/question';
|
||||
import Resolver from '../../resolver';
|
||||
import { updatePerson } from '../../models/person';
|
||||
|
||||
/**
|
||||
* Updateアクティビティを捌きます
|
||||
*/
|
||||
export default async (actor: IRemoteUser, activity: IUpdate): Promise<void> => {
|
||||
export default async (actor: IRemoteUser, activity: IUpdate): Promise<string> => {
|
||||
if ('actor' in activity && actor.uri !== activity.actor) {
|
||||
throw new Error('invalid actor');
|
||||
return `skip: invalid actor`;
|
||||
}
|
||||
|
||||
apLogger.debug('Update');
|
||||
|
||||
const object = activity.object as IObject;
|
||||
const resolver = new Resolver();
|
||||
|
||||
switch (object.type) {
|
||||
case 'Question':
|
||||
apLogger.debug('Question');
|
||||
await updateQuestion(object).catch(e => console.log(e));
|
||||
break;
|
||||
const object = await resolver.resolve(activity.object).catch(e => {
|
||||
apLogger.error(`Resolution failed: ${e}`);
|
||||
throw e;
|
||||
});
|
||||
|
||||
default:
|
||||
apLogger.warn(`Unknown type: ${object.type}`);
|
||||
break;
|
||||
if (validActor.includes(object.type)) {
|
||||
await updatePerson(actor.uri!, resolver, object);
|
||||
return `ok: Person updated`;
|
||||
} else if (object.type === 'Question') {
|
||||
await updateQuestion(object).catch(e => console.log(e));
|
||||
return `ok: Question updated`;
|
||||
} else {
|
||||
return `skip: Unknown type: ${object.type}`;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue