This commit is contained in:
naskya 2023-05-23 14:11:03 +09:00
parent c7943ca177
commit 6dba4a145c
No known key found for this signature in database
GPG key ID: 164DFF24E2D40139
4 changed files with 12 additions and 4 deletions

View file

@ -107,7 +107,9 @@ export default define(meta, paramDef, async (ps) => {
} }
if (ps.query) { if (ps.query) {
q.andWhere('emoji.name like :query', { query: `%${sqlLikeEscape(ps.query)}%` }); q.andWhere("emoji.name like :query", {
query: `%${sqlLikeEscape(ps.query)}%`,
});
} }
const emojis = await q.orderBy("emoji.id", "DESC").take(ps.limit).getMany(); const emojis = await q.orderBy("emoji.id", "DESC").take(ps.limit).getMany();

View file

@ -32,7 +32,9 @@ export const paramDef = {
export default define(meta, paramDef, async (ps) => { export default define(meta, paramDef, async (ps) => {
const hashtags = await Hashtags.createQueryBuilder("tag") const hashtags = await Hashtags.createQueryBuilder("tag")
.where("tag.name like :q", { q: `${sqlLikeEscape(ps.query.toLowerCase())}%` }) .where("tag.name like :q", {
q: `${sqlLikeEscape(ps.query.toLowerCase())}%`,
})
.orderBy("tag.count", "DESC") .orderBy("tag.count", "DESC")
.groupBy("tag.id") .groupBy("tag.id")
.take(ps.limit) .take(ps.limit)

View file

@ -45,7 +45,9 @@ export default define(meta, paramDef, async (ps, me) => {
if (ps.host) { if (ps.host) {
const q = Users.createQueryBuilder("user") const q = Users.createQueryBuilder("user")
.where("user.isSuspended = FALSE") .where("user.isSuspended = FALSE")
.andWhere("user.host LIKE :host", { host: `${sqlLikeEscape(ps.host.toLowerCase())}%` }); .andWhere("user.host LIKE :host", {
host: `${sqlLikeEscape(ps.host.toLowerCase())}%`,
});
if (ps.username) { if (ps.username) {
q.andWhere("user.usernameLower LIKE :username", { q.andWhere("user.usernameLower LIKE :username", {

View file

@ -78,7 +78,9 @@ export default define(meta, paramDef, async (ps, me) => {
const nameQuery = Users.createQueryBuilder("user") const nameQuery = Users.createQueryBuilder("user")
.where( .where(
new Brackets((qb) => { new Brackets((qb) => {
qb.where("user.name ILIKE :query", { query: `%${sqlLikeEscape(ps.query)}%` }); qb.where("user.name ILIKE :query", {
query: `%${sqlLikeEscape(ps.query)}%`,
});
// Also search username if it qualifies as username // Also search username if it qualifies as username
if (Users.validateLocalUsername(ps.query)) { if (Users.validateLocalUsername(ps.query)) {