import { IsNull } from "typeorm";
import { Users } from "../../../models/index.js";
import { fetchMeta } from "../../../misc/fetch-meta.js";
import * as Acct from "../../../misc/acct.js";
import define from "../define.js";
export const meta = {
    tags: [
        "users"
    ],
    requireCredential: false,
    requireCredentialPrivateMode: false,
    res: {
        type: "array",
        optional: false,
        nullable: false,
        items: {
            type: "object",
            optional: false,
            nullable: false,
            ref: "UserDetailed"
        }
    }
};
export const paramDef = {
    type: "object",
    properties: {},
    required: []
};
export default define(meta, paramDef, async (ps, me)=>{
    const meta = await fetchMeta();
    const users = await Promise.all(meta.pinnedUsers.map((acct)=>Acct.parse(acct)).map((acct)=>Users.findOneBy({
            usernameLower: acct.username.toLowerCase(),
            host: acct.host ?? IsNull()
        })));
    return await Users.packMany(users.filter((x)=>x !== undefined), me, {
        detail: true
    });
});
