From 4f07c88abb32a6c2c9e53c112fbcfcdc33c045fa Mon Sep 17 00:00:00 2001 From: PrivateGER Date: Thu, 25 May 2023 02:19:42 +0200 Subject: [PATCH] Fix wrong parameter ordering --- packages/backend/src/db/meilisearch.ts | 6 ++++-- .../src/server/api/endpoints/notes/search.ts | 14 ++++++-------- packages/backend/src/services/note/create.ts | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/backend/src/db/meilisearch.ts b/packages/backend/src/db/meilisearch.ts index 756c092e9b..f404b47214 100644 --- a/packages/backend/src/db/meilisearch.ts +++ b/packages/backend/src/db/meilisearch.ts @@ -17,8 +17,8 @@ const port = hasConfig ? config.meilisearch.port ?? 7700 : 0; const auth = hasConfig ? config.meilisearch.apiKey ?? "" : ""; const client = new MeiliSearch({ - host: 'http://127.0.0.1:7700', - apiKey: 'masterKey', + host: `http://${host}:${port}`, + apiKey: auth, }) const posts = client.index('posts'); @@ -39,6 +39,8 @@ export type MeilisearchNote = { export default hasConfig ? { search: (query : string, limit : number, offset : number) => { logger.info(`Searching for ${query}`); + logger.info(`Limit: ${limit}`); + logger.info(`Offset: ${offset}`); return posts.search(query, { limit: limit, diff --git a/packages/backend/src/server/api/endpoints/notes/search.ts b/packages/backend/src/server/api/endpoints/notes/search.ts index 0a6737c9b2..425414561b 100644 --- a/packages/backend/src/server/api/endpoints/notes/search.ts +++ b/packages/backend/src/server/api/endpoints/notes/search.ts @@ -179,7 +179,7 @@ export default define(meta, paramDef, async (ps, me) => { // Use meilisearch to fetch and step through all search results that could match the requirements const ids = []; while (true) { - const results = await meilisearch.search(ps.query, start, chunkSize); + const results = await meilisearch.search(ps.query, chunkSize, start); start += chunkSize; @@ -188,19 +188,17 @@ export default define(meta, paramDef, async (ps, me) => { } const res = results.hits - .filter((key) => { - let note = key as MeilisearchNote; - - if (ps.userId && note.userId !== ps.userId) { + .filter((key: MeilisearchNote) => { + if (ps.userId && key.userId !== ps.userId) { return false; } - if (ps.channelId && note.channelId !== ps.channelId) { + if (ps.channelId && key.channelId !== ps.channelId) { return false; } - if (ps.sinceId && note.id <= ps.sinceId) { + if (ps.sinceId && key.id <= ps.sinceId) { return false; } - if (ps.untilId && note.id >= ps.untilId) { + if (ps.untilId && key.id >= ps.untilId) { return false; } return true; diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index 158460421f..f6285a61d2 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -67,7 +67,7 @@ import type { UserProfile } from "@/models/entities/user-profile.js"; import { db } from "@/db/postgre.js"; import { getActiveWebhooks } from "@/misc/webhook-cache.js"; import { shouldSilenceInstance } from "@/misc/should-block-instance.js"; -import meilisearch from "@/db/meilisearch"; +import meilisearch from "../../db/meilisearch.js"; const mutedWordsCache = new Cache< { userId: UserProfile["userId"]; mutedWords: UserProfile["mutedWords"] }[]