diff options
| author | Aya Morisawa <AyaMorisawa4869@gmail.com> | 2018-07-19 08:24:03 +0900 |
|---|---|---|
| committer | Aya Morisawa <AyaMorisawa4869@gmail.com> | 2018-07-19 08:24:03 +0900 |
| commit | e03ec67b5c2d53cbc43d4423cbc5d6c219595ac9 (patch) | |
| tree | 354fc7c3a5a86df7a822ad56baccaaeea3a9b082 /src/server/api/endpoints/notes | |
| parent | Hide delete button (diff) | |
| download | sharkey-e03ec67b5c2d53cbc43d4423cbc5d6c219595ac9.tar.gz sharkey-e03ec67b5c2d53cbc43d4423cbc5d6c219595ac9.tar.bz2 sharkey-e03ec67b5c2d53cbc43d4423cbc5d6c219595ac9.zip | |
Show error message if searching is not available
Diffstat (limited to 'src/server/api/endpoints/notes')
| -rw-r--r-- | src/server/api/endpoints/notes/search.ts | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/server/api/endpoints/notes/search.ts b/src/server/api/endpoints/notes/search.ts index badaa7afc0..9124899ad8 100644 --- a/src/server/api/endpoints/notes/search.ts +++ b/src/server/api/endpoints/notes/search.ts @@ -18,6 +18,8 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => const [limit = 10, limitErr] = $.num.optional.range(1, 30).get(params.limit); if (limitErr) return rej('invalid limit param'); + if (es == null) return rej('searching not available'); + es.search({ index: 'misskey', type: 'note', @@ -53,10 +55,10 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => $in: hits } }, { - sort: { - _id: -1 - } - }); + sort: { + _id: -1 + } + }); res(await Promise.all(notes.map(note => pack(note, me)))); }); |