Skip to content

Commit

Permalink
削除したノートやユーザーがリモートから参照されると復活することがある のを修正 Fix #1774
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Oct 30, 2021
1 parent 64a9ebd commit 6bb8e9a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/remote/activitypub/models/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ export async function resolveNote(value: string | IObject, resolver?: Resolver):
}
//#endregion

if (uri.startsWith(config.url)) {
throw new StatusError('cannot resolve local note', 400, 'cannot resolve local note');
}

// リモートサーバーからフェッチしてきて登録
// ここでuriの代わりに添付されてきたNote Objectが指定されていると、サーバーフェッチを経ずにノートが生成されるが
// 添付されてきたNote Objectは偽装されている可能性があるため、常にuriを指定してサーバーフェッチを行う。
Expand Down
5 changes: 5 additions & 0 deletions src/remote/activitypub/models/person.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { toArray } from '../../../prelude/array';
import { fetchNodeinfo } from '../../../services/fetch-nodeinfo';
import { normalizeTag } from '../../../misc/normalize-tag';
import { resolveUser } from '../../resolve-user';
import { StatusError } from '../../../misc/fetch';

const logger = apLogger;

Expand Down Expand Up @@ -116,6 +117,10 @@ export async function fetchPerson(uri: string, resolver?: Resolver): Promise<Use
export async function createPerson(uri: string, resolver?: Resolver): Promise<User> {
if (typeof uri !== 'string') throw new Error('uri is not string');

if (uri.startsWith(config.url)) {
throw new StatusError('cannot resolve local user', 400, 'cannot resolve local user');
}

if (resolver == null) resolver = new Resolver();

const object = await resolver.resolve(uri) as any;
Expand Down

0 comments on commit 6bb8e9a

Please sign in to comment.