Skip to content

Commit

Permalink
fix(backend): search user with trailing space
Browse files Browse the repository at this point in the history
  • Loading branch information
yahuli committed Jul 8, 2023
1 parent adffdd4 commit a87201b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/backend/src/server/api/endpoints/users/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
import { UserEntityService } from '@/core/entities/UserEntityService.js';
import { DI } from '@/di-symbols.js';
import { sqlLikeEscape } from '@/misc/sql-like-escape.js';
import { query } from '@/misc/prelude/url.js';

export const meta = {
tags: ['users'],
Expand Down Expand Up @@ -52,6 +53,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
super(meta, paramDef, async (ps, me) => {
const activeThreshold = new Date(Date.now() - (1000 * 60 * 60 * 24 * 30)); // 30日

ps.query = ps.query.trim();
const isUsername = ps.query.startsWith('@');

let users: User[] = [];
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/server/api/endpoints/users/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
let user;

const isModerator = await this.roleService.isModerator(me);
ps.username = ps.username?.trim();

if (ps.userIds) {
if (ps.userIds.length === 0) {
Expand Down

0 comments on commit a87201b

Please sign in to comment.