Fix: AP actor Service のサポートが不完全 (#4661)

This commit is contained in:
MeiMei 2019-04-11 02:46:29 +09:00 committed by syuilo
parent 03a3c56a54
commit 6abc053a48
4 changed files with 8 additions and 4 deletions

View file

@ -11,6 +11,7 @@ import Logger from '../../services/logger';
import { registerOrFetchInstanceDoc } from '../../services/register-or-fetch-instance-doc'; import { registerOrFetchInstanceDoc } from '../../services/register-or-fetch-instance-doc';
import Instance from '../../models/instance'; import Instance from '../../models/instance';
import instanceChart from '../../services/chart/instance'; import instanceChart from '../../services/chart/instance';
import { validActor } from '../../remote/activitypub/type';
const logger = new Logger('inbox'); const logger = new Logger('inbox');
@ -79,7 +80,7 @@ export default async (job: Bull.Job): Promise<void> => {
// Update Person activityの場合は、ここで署名検証/更新処理まで実施して終了 // Update Person activityの場合は、ここで署名検証/更新処理まで実施して終了
if (activity.type === 'Update') { if (activity.type === 'Update') {
if (activity.object && activity.object.type === 'Person') { if (activity.object && validActor.includes(activity.object.type)) {
if (user == null) { if (user == null) {
logger.warn('Update activity received, but user not registed.'); logger.warn('Update activity received, but user not registed.');
} else if (!httpSignature.verifySignature(signature, user.publicKey.publicKeyPem)) { } else if (!httpSignature.verifySignature(signature, user.publicKey.publicKeyPem)) {

View file

@ -6,7 +6,7 @@ import config from '../../../config';
import User, { validateUsername, isValidName, IUser, IRemoteUser, isRemoteUser } from '../../../models/user'; import User, { validateUsername, isValidName, IUser, IRemoteUser, isRemoteUser } from '../../../models/user';
import Resolver from '../resolver'; import Resolver from '../resolver';
import { resolveImage } from './image'; import { resolveImage } from './image';
import { isCollectionOrOrderedCollection, isCollection, IPerson } from '../type'; import { isCollectionOrOrderedCollection, isCollection, IPerson, validActor } from '../type';
import { IDriveFile } from '../../../models/drive-file'; import { IDriveFile } from '../../../models/drive-file';
import Meta from '../../../models/meta'; import Meta from '../../../models/meta';
import { fromHtml } from '../../../mfm/fromHtml'; import { fromHtml } from '../../../mfm/fromHtml';
@ -38,7 +38,7 @@ function validatePerson(x: any, uri: string) {
return new Error('invalid person: object is null'); return new Error('invalid person: object is null');
} }
if (x.type != 'Person' && x.type != 'Service') { if (!validActor.includes(x.type)) {
return new Error(`invalid person: object is not a person or service '${x.type}'`); return new Error(`invalid person: object is not a person or service '${x.type}'`);
} }

View file

@ -65,6 +65,8 @@ interface IQuestionChoice {
_misskey_votes?: number; _misskey_votes?: number;
} }
export const validActor = ['Person', 'Service'];
export interface IPerson extends IObject { export interface IPerson extends IObject {
type: 'Person'; type: 'Person';
name: string; name: string;

View file

@ -10,6 +10,7 @@ import Resolver from '../../../../remote/activitypub/resolver';
import { ApiError } from '../../error'; import { ApiError } from '../../error';
import Instance from '../../../../models/instance'; import Instance from '../../../../models/instance';
import { extractDbHost } from '../../../../misc/convert-host'; import { extractDbHost } from '../../../../misc/convert-host';
import { validActor } from '../../../../remote/activitypub/type';
export const meta = { export const meta = {
tags: ['federation'], tags: ['federation'],
@ -95,7 +96,7 @@ async function fetchAny(uri: string) {
} }
// それでもみつからなければ新規であるため登録 // それでもみつからなければ新規であるため登録
if (object.type === 'Person') { if (validActor.includes(object.type)) {
const user = await createPerson(object.id); const user = await createPerson(object.id);
return { return {
type: 'User', type: 'User',