diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2019-04-25 04:07:39 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2019-04-25 04:07:39 +0900 |
| commit | ee5720df2c93a852d5429cb3919cdecc8b8051f8 (patch) | |
| tree | 39a335cfe75dbdc9fac729ecf4de54a075dabaa5 /src/server/api/endpoints | |
| parent | 11.3.1 (diff) | |
| download | sharkey-ee5720df2c93a852d5429cb3919cdecc8b8051f8.tar.gz sharkey-ee5720df2c93a852d5429cb3919cdecc8b8051f8.tar.bz2 sharkey-ee5720df2c93a852d5429cb3919cdecc8b8051f8.zip | |
Fix #4704 (#4797)
* Fix #4632
* Fix #4795
Diffstat (limited to 'src/server/api/endpoints')
| -rw-r--r-- | src/server/api/endpoints/ap/show.ts | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/server/api/endpoints/ap/show.ts b/src/server/api/endpoints/ap/show.ts index 1bb15117dd..9724a044b1 100644 --- a/src/server/api/endpoints/ap/show.ts +++ b/src/server/api/endpoints/ap/show.ts @@ -101,6 +101,32 @@ async function fetchAny(uri: string) { // /@user のような正規id以外で取得できるURIが指定されていた場合、ここで初めて正規URIが確定する // これはDBに存在する可能性があるため再度DB検索 if (uri !== object.id) { + if (object.id.startsWith(config.url + '/')) { + const parts = object.id.split('/'); + const id = parts.pop(); + const type = parts.pop(); + + if (type === 'notes') { + const note = await Notes.findOne(id); + + if (note) { + return { + type: 'Note', + object: await Notes.pack(note, null, { detail: true }) + }; + } + } else if (type === 'users') { + const user = await Users.findOne(id); + + if (user) { + return { + type: 'User', + object: await Users.pack(user, null, { detail: true }) + }; + } + } + } + const [user, note] = await Promise.all([ Users.findOne({ uri: object.id }), Notes.findOne({ uri: object.id }) @@ -120,7 +146,7 @@ async function fetchAny(uri: string) { } if (['Note', 'Question', 'Article'].includes(object.type)) { - const note = await createNote(object.id); + const note = await createNote(object.id, undefined, true); return { type: 'Note', object: await Notes.pack(note!, null, { detail: true }) |