monkeeShark/src/server/api/endpoints/pinned-users.ts

33 lines
801 B
TypeScript
Raw Normal View History

import define from '../define';
import { Users } from '../../../models';
2021-03-23 08:43:07 +00:00
import { fetchMeta } from '@/misc/fetch-meta';
2021-07-15 11:45:32 +00:00
import { parseAcct } from '@/misc/acct';
import { User } from '../../../models/entities/user';
export const meta = {
tags: ['users'],
2020-02-15 12:33:32 +00:00
requireCredential: false as const,
params: {
},
res: {
2019-06-27 09:04:09 +00:00
type: 'array' as const,
optional: false as const, nullable: false as const,
items: {
2019-06-27 09:04:09 +00:00
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 });
});