From 53f858d736d70cd9f7c1f0f01763e4bba5bf9f00 Mon Sep 17 00:00:00 2001 From: samunohito <46447427+samunohito@users.noreply.github.com> Date: Tue, 27 Feb 2024 21:11:45 +0900 Subject: [PATCH] revert excess fixes --- packages/backend/src/postgres.ts | 2 +- .../api/endpoints/admin/emoji/list-remote.ts | 34 +++++++++++++- .../server/api/endpoints/admin/emoji/list.ts | 45 +++++++++++++++++-- 3 files changed, 75 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/postgres.ts b/packages/backend/src/postgres.ts index ed5a1ae2be..2d14537bbb 100644 --- a/packages/backend/src/postgres.ts +++ b/packages/backend/src/postgres.ts @@ -97,7 +97,7 @@ class MyCustomLogger implements Logger { @bindThis public logQuery(query: string, parameters?: any[]) { - sqlLogger.info(this.highlight(query)); + sqlLogger.info(this.highlight(query).substring(0, 100)); } @bindThis diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts b/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts index 088f565e20..0889ceb76f 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/list-remote.ts @@ -24,7 +24,39 @@ export const meta = { optional: false, nullable: false, items: { type: 'object', - ref: 'EmojiDetailed', + optional: false, nullable: false, + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + }, + aliases: { + type: 'array', + optional: false, nullable: false, + items: { + type: 'string', + optional: false, nullable: false, + }, + }, + name: { + type: 'string', + optional: false, nullable: false, + }, + category: { + type: 'string', + optional: false, nullable: true, + }, + host: { + type: 'string', + optional: false, nullable: true, + description: 'The local host is represented with `null`.', + }, + url: { + type: 'string', + optional: false, nullable: false, + }, + }, }, }, } as const; diff --git a/packages/backend/src/server/api/endpoints/admin/emoji/list.ts b/packages/backend/src/server/api/endpoints/admin/emoji/list.ts index 5e42db1b85..ffb5dbf4b5 100644 --- a/packages/backend/src/server/api/endpoints/admin/emoji/list.ts +++ b/packages/backend/src/server/api/endpoints/admin/emoji/list.ts @@ -21,9 +21,42 @@ export const meta = { res: { type: 'array', + optional: false, nullable: false, items: { type: 'object', - ref: 'EmojiDetailed', + optional: false, nullable: false, + properties: { + id: { + type: 'string', + optional: false, nullable: false, + format: 'id', + }, + aliases: { + type: 'array', + optional: false, nullable: false, + items: { + type: 'string', + optional: false, nullable: false, + }, + }, + name: { + type: 'string', + optional: false, nullable: false, + }, + category: { + type: 'string', + optional: false, nullable: true, + }, + host: { + type: 'string', + optional: false, nullable: true, + description: 'The local host is represented with `null`. The field exists for compatibility with other API endpoints that return files.', + }, + url: { + type: 'string', + optional: false, nullable: false, + }, + }, }, }, } as const; @@ -55,11 +88,15 @@ export default class extends Endpoint { // eslint- let emojis: MiEmoji[]; if (ps.query) { + //q.andWhere('emoji.name ILIKE :q', { q: `%${ sqlLikeEscape(ps.query) }%` }); + //const emojis = await q.limit(ps.limit).getMany(); + emojis = await q.getMany(); - const queries = ps.query.match(/:([a-z0-9_]*):/g); - if (queries) { + const queryarry = ps.query.match(/\:([a-z0-9_]*)\:/g); + + if (queryarry) { emojis = emojis.filter(emoji => - queries.includes(`:${emoji.name}:`), + queryarry.includes(`:${emoji.name}:`), ); } else { emojis = emojis.filter(emoji =>