iceshrimp/packages/backend/src/server/api/endpoints/pinned-users.ts

34 lines
854 B
TypeScript
Raw Normal View History

import define from '../define';
import { Users } from '@/models/index';
import { fetchMeta } from '@/misc/fetch-meta';
2021-11-12 02:02:25 +09:00
import * as Acct from 'misskey-js/built/acct';
import { User } from '@/models/entities/user';
export const meta = {
tags: ['users'],
2020-02-15 21:33:32 +09:00
requireCredential: false as const,
params: {
},
res: {
2019-06-27 18:04:09 +09:00
type: 'array' as const,
optional: false as const, nullable: false as const,
items: {
2019-06-27 18:04:09 +09:00
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'User',
2021-12-09 23:58:30 +09:00
},
},
};
2022-01-03 02:12:50 +09:00
// eslint-disable-next-line import/no-default-export
export default define(meta, async (ps, me) => {
const meta = await fetchMeta();
2021-11-12 02:02:25 +09:00
const users = await Promise.all(meta.pinnedUsers.map(acct => Users.findOne(Acct.parse(acct))));
return await Users.packMany(users.filter(x => x !== undefined) as User[], me, { detail: true });
});