revert excess fixes

This commit is contained in:
samunohito 2024-02-27 21:11:45 +09:00
parent 1b720b36b9
commit 53f858d736
3 changed files with 75 additions and 6 deletions

View File

@ -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

View File

@ -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;

View File

@ -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<typeof meta, typeof paramDef> { // 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 =>