Fix wrong parameter ordering

This commit is contained in:
PrivateGER 2023-05-25 02:19:42 +02:00 committed by PrivateGER
parent 89f1b6357e
commit 090b5724b4
3 changed files with 11 additions and 11 deletions

View File

@ -17,8 +17,8 @@ const port = hasConfig ? config.meilisearch.port ?? 7700 : 0;
const auth = hasConfig ? config.meilisearch.apiKey ?? "" : ""; const auth = hasConfig ? config.meilisearch.apiKey ?? "" : "";
const client = new MeiliSearch({ const client = new MeiliSearch({
host: 'http://127.0.0.1:7700', host: `http://${host}:${port}`,
apiKey: 'masterKey', apiKey: auth,
}) })
const posts = client.index('posts'); const posts = client.index('posts');
@ -39,6 +39,8 @@ export type MeilisearchNote = {
export default hasConfig ? { export default hasConfig ? {
search: (query : string, limit : number, offset : number) => { search: (query : string, limit : number, offset : number) => {
logger.info(`Searching for ${query}`); logger.info(`Searching for ${query}`);
logger.info(`Limit: ${limit}`);
logger.info(`Offset: ${offset}`);
return posts.search(query, { return posts.search(query, {
limit: limit, limit: limit,

View File

@ -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 // Use meilisearch to fetch and step through all search results that could match the requirements
const ids = []; const ids = [];
while (true) { while (true) {
const results = await meilisearch.search(ps.query, start, chunkSize); const results = await meilisearch.search(ps.query, chunkSize, start);
start += chunkSize; start += chunkSize;
@ -188,19 +188,17 @@ export default define(meta, paramDef, async (ps, me) => {
} }
const res = results.hits const res = results.hits
.filter((key) => { .filter((key: MeilisearchNote) => {
let note = key as MeilisearchNote; if (ps.userId && key.userId !== ps.userId) {
if (ps.userId && note.userId !== ps.userId) {
return false; return false;
} }
if (ps.channelId && note.channelId !== ps.channelId) { if (ps.channelId && key.channelId !== ps.channelId) {
return false; return false;
} }
if (ps.sinceId && note.id <= ps.sinceId) { if (ps.sinceId && key.id <= ps.sinceId) {
return false; return false;
} }
if (ps.untilId && note.id >= ps.untilId) { if (ps.untilId && key.id >= ps.untilId) {
return false; return false;
} }
return true; return true;

View File

@ -67,7 +67,7 @@ import type { UserProfile } from "@/models/entities/user-profile.js";
import { db } from "@/db/postgre.js"; import { db } from "@/db/postgre.js";
import { getActiveWebhooks } from "@/misc/webhook-cache.js"; import { getActiveWebhooks } from "@/misc/webhook-cache.js";
import { shouldSilenceInstance } from "@/misc/should-block-instance.js"; import { shouldSilenceInstance } from "@/misc/should-block-instance.js";
import meilisearch from "@/db/meilisearch"; import meilisearch from "../../db/meilisearch.js";
const mutedWordsCache = new Cache< const mutedWordsCache = new Cache<
{ userId: UserProfile["userId"]; mutedWords: UserProfile["mutedWords"] }[] { userId: UserProfile["userId"]; mutedWords: UserProfile["mutedWords"] }[]