1
0
mirror of https://github.com/MisskeyIO/misskey synced 2024-11-27 22:38:30 +09:00

fix null in query

This commit is contained in:
syuilo 2022-03-26 19:48:22 +09:00
parent fa1a53270e
commit e6f455a9bb

View File

@ -6,6 +6,7 @@ import { links } from './nodeinfo.js';
import { escapeAttribute, escapeValue } from '@/prelude/xml.js';
import { Users } from '@/models/index.js';
import { User } from '@/models/entities/user.js';
import { FindOptionsWhere, IsNull } from 'typeorm';
// Init router
const router = new Router();
@ -66,13 +67,13 @@ router.get('/.well-known/change-password', async ctx => {
*/
router.get(webFingerPath, async ctx => {
const fromId = (id: User['id']): Record<string, any> => ({
const fromId = (id: User['id']): FindOptionsWhere<User> => ({
id,
host: null,
host: IsNull(),
isSuspended: false,
});
const generateQuery = (resource: string) =>
const generateQuery = (resource: string): FindOptionsWhere<User> | number =>
resource.startsWith(`${config.url.toLowerCase()}/users/`) ?
fromId(resource.split('/').pop()!) :
fromAcct(Acct.parse(
@ -80,10 +81,10 @@ router.get(webFingerPath, async ctx => {
resource.startsWith('acct:') ? resource.slice('acct:'.length) :
resource));
const fromAcct = (acct: Acct.Acct): Record<string, any> | number =>
const fromAcct = (acct: Acct.Acct): FindOptionsWhere<User> | number =>
!acct.host || acct.host === config.host.toLowerCase() ? {
usernameLower: acct.username,
host: null,
host: IsNull(),
isSuspended: false,
} : 422;