2023-01-13 05:40:33 +01:00
|
|
|
import { UserLists } from "@/models/index.js";
|
|
|
|
import define from "../../../define.js";
|
|
|
|
import { ApiError } from "../../../error.js";
|
2018-04-25 12:53:16 +02:00
|
|
|
|
2018-07-16 21:36:44 +02:00
|
|
|
export const meta = {
|
2023-01-13 05:40:33 +01:00
|
|
|
tags: ["lists", "account"],
|
2019-02-23 03:20:58 +01:00
|
|
|
|
2022-01-18 14:27:10 +01:00
|
|
|
requireCredential: true,
|
2018-07-16 21:36:44 +02:00
|
|
|
|
2023-01-13 05:40:33 +01:00
|
|
|
kind: "read:account",
|
2018-11-01 19:32:24 +01:00
|
|
|
|
2023-01-13 05:40:33 +01:00
|
|
|
description: "Show the properties of a list.",
|
2022-06-10 07:25:20 +02:00
|
|
|
|
2019-02-24 19:35:45 +01:00
|
|
|
res: {
|
2023-01-13 05:40:33 +01:00
|
|
|
type: "object",
|
|
|
|
optional: false,
|
|
|
|
nullable: false,
|
|
|
|
ref: "UserList",
|
2019-02-24 19:35:45 +01:00
|
|
|
},
|
|
|
|
|
2019-02-22 03:46:58 +01:00
|
|
|
errors: {
|
|
|
|
noSuchList: {
|
2023-01-13 05:40:33 +01:00
|
|
|
message: "No such list.",
|
|
|
|
code: "NO_SUCH_LIST",
|
|
|
|
id: "7bc05c21-1d7a-41ae-88f1-66820f4dc686",
|
2019-02-22 03:46:58 +01:00
|
|
|
},
|
2021-12-09 15:58:30 +01:00
|
|
|
},
|
2022-01-18 14:27:10 +01:00
|
|
|
} as const;
|
2018-07-16 21:36:44 +02:00
|
|
|
|
2022-02-20 05:15:40 +01:00
|
|
|
export const paramDef = {
|
2023-01-13 05:40:33 +01:00
|
|
|
type: "object",
|
2022-02-19 06:05:32 +01:00
|
|
|
properties: {
|
2023-01-13 05:40:33 +01:00
|
|
|
listId: { type: "string", format: "misskey:id" },
|
2022-02-19 06:05:32 +01:00
|
|
|
},
|
2023-01-13 05:40:33 +01:00
|
|
|
required: ["listId"],
|
2022-02-19 06:05:32 +01:00
|
|
|
} as const;
|
|
|
|
|
|
|
|
export default define(meta, paramDef, async (ps, me) => {
|
2018-04-25 12:53:16 +02:00
|
|
|
// Fetch the list
|
2023-07-18 16:00:48 +02:00
|
|
|
const userList = await UserLists.findOneBy({
|
|
|
|
id: ps.listId,
|
|
|
|
userId: me.id,
|
2018-04-25 12:53:16 +02:00
|
|
|
});
|
|
|
|
|
2023-07-18 16:00:48 +02:00
|
|
|
if (!userList) {
|
2019-02-22 03:46:58 +01:00
|
|
|
throw new ApiError(meta.errors.noSuchList);
|
2018-04-25 12:53:16 +02:00
|
|
|
}
|
|
|
|
|
2019-04-07 14:50:36 +02:00
|
|
|
return await UserLists.pack(userList);
|
2019-02-22 03:46:58 +01:00
|
|
|
});
|