Sharkey/src/server/api/endpoints/pinned-users.ts
syuilo b9cb6d1c10 refactor: refactoring imports
将来ESMに移行しやすいように
Related: #7658

なんかmochaが起動しなくなってるけど理由不明
すぐ直したい
2021-08-19 18:33:41 +09:00

32 lines
808 B
TypeScript

import define from '../define.js';
import { Users } from '@/models/index.js';
import { fetchMeta } from '@/misc/fetch-meta.js';
import { parseAcct } from '@/misc/acct.js';
import { User } from '@/models/entities/user.js';
export const meta = {
tags: ['users'],
requireCredential: false as const,
params: {
},
res: {
type: 'array' as const,
optional: false as const, nullable: false as const,
items: {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'User',
}
},
};
export default define(meta, async (ps, me) => {
const meta = await fetchMeta();
const users = await Promise.all(meta.pinnedUsers.map(acct => Users.findOne(parseAcct(acct))));
return await Users.packMany(users.filter(x => x !== undefined) as User[], me, { detail: true });
});