This commit is contained in:
syuilo
2019-04-13 16:54:21 +09:00
parent cfee87d3ef
commit ae16b45c11
6 changed files with 15 additions and 10 deletions

View File

@ -1,7 +1,7 @@
import $ from 'cafy';
import define from '../../../define';
import { Emojis } from '../../../../../models';
import { toPuny } from '../../../../../misc/convert-host';
import { toPunyNullable } from '../../../../../misc/convert-host';
export const meta = {
desc: {
@ -23,7 +23,7 @@ export const meta = {
export default define(meta, async (ps) => {
const emojis = await Emojis.find({
host: ps.host ? toPuny(ps.host) : null
host: toPunyNullable(ps.host)
});
return emojis.map(e => ({

View File

@ -4,7 +4,7 @@ import define from '../../define';
import { ApiError } from '../../error';
import { Users, Followings } from '../../../../models';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { toPuny } from '../../../../misc/convert-host';
import { toPunyNullable } from '../../../../misc/convert-host';
export const meta = {
desc: {
@ -66,7 +66,7 @@ export const meta = {
export default define(meta, async (ps, me) => {
const user = await Users.findOne(ps.userId != null
? { id: ps.userId }
: { usernameLower: ps.username!.toLowerCase(), host: toPuny(ps.host!) });
: { usernameLower: ps.username!.toLowerCase(), host: toPunyNullable(ps.host) });
if (user == null) {
throw new ApiError(meta.errors.noSuchUser);

View File

@ -4,7 +4,7 @@ import define from '../../define';
import { ApiError } from '../../error';
import { Users, Followings } from '../../../../models';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { toPuny } from '../../../../misc/convert-host';
import { toPunyNullable } from '../../../../misc/convert-host';
export const meta = {
desc: {
@ -66,7 +66,7 @@ export const meta = {
export default define(meta, async (ps, me) => {
const user = await Users.findOne(ps.userId != null
? { id: ps.userId }
: { usernameLower: ps.username!.toLowerCase(), host: toPuny(ps.host!) });
: { usernameLower: ps.username!.toLowerCase(), host: toPunyNullable(ps.host) });
if (user == null) {
throw new ApiError(meta.errors.noSuchUser);

View File

@ -10,7 +10,7 @@ import { genId } from '../../../misc/gen-id';
import { usersChart } from '../../../services/chart';
import { User } from '../../../models/entities/user';
import { UserKeypair } from '../../../models/entities/user-keypair';
import { toPuny } from '../../../misc/convert-host';
import { toPunyNullable } from '../../../misc/convert-host';
import { UserProfile } from '../../../models/entities/user-profile';
import { getConnection } from 'typeorm';
@ -109,7 +109,7 @@ export default async (ctx: Koa.BaseContext) => {
createdAt: new Date(),
username: username,
usernameLower: username.toLowerCase(),
host: host ? toPuny(host) : null,
host: toPunyNullable(host),
token: secret,
isAdmin: config.autoAdmin && usersCount === 0,
}));