mirror of
https://github.com/paricafe/misskey.git
synced 2024-12-02 16:26:44 -06:00
efb0ffc4ec
* Fix API Schema Error * Delete SimpleSchema/SimpleObj and Move schemas to dedicated files * Userのスキーマを分割してみる * define packMany type * add , * Ensure enum schema and Make "as const" put once * test? * Revert "test?" This reverts commit 97dc9bfa70851bfb7d1cf38e883f8df20fb78b79. * Revert "Fix API Schema Error" This reverts commit 21b6176d974ed8e3eb73723ad21a105c5d297323. * ✌️ * clean up * test? * wip * wip * better schema def * ✌️ * fix * add minLength property * wip * wip * wip * anyOf/oneOf/allOfに対応? ~ relation.ts * refactor! * Define MinimumSchema * wip * wip * anyOf/oneOf/allOfが動作するようにUnionSchemaTypeを修正 * anyOf/oneOf/allOfが動作するようにUnionSchemaTypeを修正 * Update packages/backend/src/misc/schema.ts Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> * fix * array oneOfをより正確な型に * array oneOfをより正確な型に * wip * ✌️ * なんかもういろいろ * remove * very good schema * api schema * wip * refactor: awaitAllの型定義を変えてみる * fix * specify types in awaitAll * specify types in awaitAll * ✌️ * wip * ... * ✌️ * AllowDateはやめておく * 不必要なoptional: false, nullable: falseを廃止 * Packedが展開されないように * 続packed * wip * define note type * wip * UserDetailedをMeDetailedかUserDetailedNotMeかを区別できるように * wip * wip * wip specify user type of other schemas * ok * convertSchemaToOpenApiSchemaを改修 * convertSchemaToOpenApiSchemaを改修 * Fix * fix * ✌️ * wip * 分割代入ではなくallOfで定義するように Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
60 lines
1.4 KiB
TypeScript
60 lines
1.4 KiB
TypeScript
import $ from 'cafy';
|
|
import { ID } from '@/misc/cafy-id';
|
|
import { addPinned } from '@/services/i/pin';
|
|
import define from '../../define';
|
|
import { ApiError } from '../../error';
|
|
import { Users } from '@/models/index';
|
|
|
|
export const meta = {
|
|
tags: ['account', 'notes'],
|
|
|
|
requireCredential: true,
|
|
|
|
kind: 'write:account',
|
|
|
|
params: {
|
|
noteId: {
|
|
validator: $.type(ID),
|
|
},
|
|
},
|
|
|
|
errors: {
|
|
noSuchNote: {
|
|
message: 'No such note.',
|
|
code: 'NO_SUCH_NOTE',
|
|
id: '56734f8b-3928-431e-bf80-6ff87df40cb3',
|
|
},
|
|
|
|
pinLimitExceeded: {
|
|
message: 'You can not pin notes any more.',
|
|
code: 'PIN_LIMIT_EXCEEDED',
|
|
id: '72dab508-c64d-498f-8740-a8eec1ba385a',
|
|
},
|
|
|
|
alreadyPinned: {
|
|
message: 'That note has already been pinned.',
|
|
code: 'ALREADY_PINNED',
|
|
id: '8b18c2b7-68fe-4edb-9892-c0cbaeb6c913',
|
|
},
|
|
},
|
|
|
|
res: {
|
|
type: 'object',
|
|
optional: false, nullable: false,
|
|
ref: 'MeDetailed',
|
|
},
|
|
} as const;
|
|
|
|
// eslint-disable-next-line import/no-default-export
|
|
export default define(meta, async (ps, user) => {
|
|
await addPinned(user, ps.noteId).catch(e => {
|
|
if (e.id === '70c4e51f-5bea-449c-a030-53bee3cce202') throw new ApiError(meta.errors.noSuchNote);
|
|
if (e.id === '15a018eb-58e5-4da1-93be-330fcc5e4e1a') throw new ApiError(meta.errors.pinLimitExceeded);
|
|
if (e.id === '23f0cf4e-59a3-4276-a91d-61a5891c1514') throw new ApiError(meta.errors.alreadyPinned);
|
|
throw e;
|
|
});
|
|
|
|
return await Users.pack<true, true>(user.id, user, {
|
|
detail: true,
|
|
});
|
|
});
|