Merge branch 'develop' of https://github.com/syuilo/misskey into develop

This commit is contained in:
syuilo 2019-04-11 12:59:16 +09:00
commit 91c1ceefbd
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
4 changed files with 8 additions and 3 deletions

View file

@ -13,6 +13,7 @@ import { instanceChart } from '../../services/chart';
import { UserPublickey } from '../../models/entities/user-publickey'; import { UserPublickey } from '../../models/entities/user-publickey';
import fetchMeta from '../../misc/fetch-meta'; import fetchMeta from '../../misc/fetch-meta';
import { toPuny } from '../../misc/convert-host'; import { toPuny } from '../../misc/convert-host';
import { validActor } from '../../remote/activitypub/type';
const logger = new Logger('inbox'); const logger = new Logger('inbox');
@ -93,7 +94,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, key.keyPem)) { } else if (!httpSignature.verifySignature(signature, key.keyPem)) {

View file

@ -24,6 +24,7 @@ import { UserPublickey } from '../../../models/entities/user-publickey';
import { isDuplicateKeyValueError } from '../../../misc/is-duplicate-key-value-error'; import { isDuplicateKeyValueError } from '../../../misc/is-duplicate-key-value-error';
import { toPuny } from '../../../misc/convert-host'; import { toPuny } from '../../../misc/convert-host';
import { UserProfile } from '../../../models/entities/user-profile'; import { UserProfile } from '../../../models/entities/user-profile';
import { validActor } from '../../../remote/activitypub/type';
const logger = apLogger; const logger = apLogger;
/** /**
@ -38,7 +39,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 { Users, Notes } from '../../../../models';
import { Note } from '../../../../models/entities/note'; import { Note } from '../../../../models/entities/note';
import { User } from '../../../../models/entities/user'; import { User } from '../../../../models/entities/user';
import fetchMeta from '../../../../misc/fetch-meta'; import fetchMeta from '../../../../misc/fetch-meta';
import { validActor } from '../../../../remote/activitypub/type';
export const meta = { export const meta = {
tags: ['federation'], tags: ['federation'],
@ -110,7 +111,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',