refactor: Expand schema (#7772)
* packedNotificationSchemaを更新 * read:gallery, write:gallery, read:gallery-likes, write:gallery-likesに翻訳を追加 * fix * add header, choice, invitation * test * fix * yatta * remove no longer needed "as PackedUser/PackedNote" * clean up * add simple-schema * fix lint * define items in full Schema * revert https://github.com/misskey-dev/misskey/pull/7772#discussion_r706627736 * user packとnote packの型不整合を修正
This commit is contained in:
@ -3,7 +3,7 @@ import { dirname } from 'path';
|
||||
import { Context } from 'cafy';
|
||||
import * as path from 'path';
|
||||
import * as glob from 'glob';
|
||||
import { Schema } from '@/misc/schema';
|
||||
import { SimpleSchema } from '@/misc/simple-schema';
|
||||
|
||||
//const _filename = fileURLToPath(import.meta.url);
|
||||
const _filename = __filename;
|
||||
@ -34,7 +34,7 @@ export interface IEndpointMeta {
|
||||
};
|
||||
};
|
||||
|
||||
res?: Schema;
|
||||
res?: SimpleSchema;
|
||||
|
||||
/**
|
||||
* このエンドポイントにリクエストするのにユーザー情報が必須か否か
|
||||
|
@ -1,26 +1,4 @@
|
||||
import { packedUserSchema } from '@/models/repositories/user';
|
||||
import { Schema } from '@/misc/schema';
|
||||
import { packedNoteSchema } from '@/models/repositories/note';
|
||||
import { packedUserListSchema } from '@/models/repositories/user-list';
|
||||
import { packedAppSchema } from '@/models/repositories/app';
|
||||
import { packedMessagingMessageSchema } from '@/models/repositories/messaging-message';
|
||||
import { packedNotificationSchema } from '@/models/repositories/notification';
|
||||
import { packedDriveFileSchema } from '@/models/repositories/drive-file';
|
||||
import { packedDriveFolderSchema } from '@/models/repositories/drive-folder';
|
||||
import { packedFollowingSchema } from '@/models/repositories/following';
|
||||
import { packedMutingSchema } from '@/models/repositories/muting';
|
||||
import { packedBlockingSchema } from '@/models/repositories/blocking';
|
||||
import { packedNoteReactionSchema } from '@/models/repositories/note-reaction';
|
||||
import { packedHashtagSchema } from '@/models/repositories/hashtag';
|
||||
import { packedPageSchema } from '@/models/repositories/page';
|
||||
import { packedUserGroupSchema } from '@/models/repositories/user-group';
|
||||
import { packedNoteFavoriteSchema } from '@/models/repositories/note-favorite';
|
||||
import { packedChannelSchema } from '@/models/repositories/channel';
|
||||
import { packedAntennaSchema } from '@/models/repositories/antenna';
|
||||
import { packedClipSchema } from '@/models/repositories/clip';
|
||||
import { packedFederationInstanceSchema } from '@/models/repositories/federation-instance';
|
||||
import { packedQueueCountSchema } from '@/models/repositories/queue';
|
||||
import { packedGalleryPostSchema } from '@/models/repositories/gallery-post';
|
||||
import { refs, Schema } from '@/misc/schema';
|
||||
|
||||
export function convertSchemaToOpenApiSchema(schema: Schema) {
|
||||
const res: any = schema;
|
||||
@ -72,26 +50,7 @@ export const schemas = {
|
||||
required: ['error']
|
||||
},
|
||||
|
||||
User: convertSchemaToOpenApiSchema(packedUserSchema),
|
||||
UserList: convertSchemaToOpenApiSchema(packedUserListSchema),
|
||||
UserGroup: convertSchemaToOpenApiSchema(packedUserGroupSchema),
|
||||
App: convertSchemaToOpenApiSchema(packedAppSchema),
|
||||
MessagingMessage: convertSchemaToOpenApiSchema(packedMessagingMessageSchema),
|
||||
Note: convertSchemaToOpenApiSchema(packedNoteSchema),
|
||||
NoteReaction: convertSchemaToOpenApiSchema(packedNoteReactionSchema),
|
||||
NoteFavorite: convertSchemaToOpenApiSchema(packedNoteFavoriteSchema),
|
||||
Notification: convertSchemaToOpenApiSchema(packedNotificationSchema),
|
||||
DriveFile: convertSchemaToOpenApiSchema(packedDriveFileSchema),
|
||||
DriveFolder: convertSchemaToOpenApiSchema(packedDriveFolderSchema),
|
||||
Following: convertSchemaToOpenApiSchema(packedFollowingSchema),
|
||||
Muting: convertSchemaToOpenApiSchema(packedMutingSchema),
|
||||
Blocking: convertSchemaToOpenApiSchema(packedBlockingSchema),
|
||||
Hashtag: convertSchemaToOpenApiSchema(packedHashtagSchema),
|
||||
Page: convertSchemaToOpenApiSchema(packedPageSchema),
|
||||
Channel: convertSchemaToOpenApiSchema(packedChannelSchema),
|
||||
QueueCount: convertSchemaToOpenApiSchema(packedQueueCountSchema),
|
||||
Antenna: convertSchemaToOpenApiSchema(packedAntennaSchema),
|
||||
Clip: convertSchemaToOpenApiSchema(packedClipSchema),
|
||||
FederationInstance: convertSchemaToOpenApiSchema(packedFederationInstanceSchema),
|
||||
GalleryPost: convertSchemaToOpenApiSchema(packedGalleryPostSchema),
|
||||
...Object.fromEntries(
|
||||
Object.entries(refs).map(([key, schema]) => [key, convertSchemaToOpenApiSchema(schema)])
|
||||
),
|
||||
};
|
||||
|
@ -43,7 +43,7 @@ export default class extends Channel {
|
||||
|
||||
// 関係ない返信は除外
|
||||
if (note.reply) {
|
||||
const reply = note.reply as PackedNote;
|
||||
const reply = note.reply;
|
||||
// 「チャンネル接続主への返信」でもなければ、「チャンネル接続主が行った返信」でもなければ、「投稿者の投稿者自身への返信」でもない場合
|
||||
if (reply.userId !== this.user!.id && note.userId !== this.user!.id && reply.userId !== note.userId) return;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ export default class extends Channel {
|
||||
|
||||
// 関係ない返信は除外
|
||||
if (note.reply) {
|
||||
const reply = note.reply as PackedNote;
|
||||
const reply = note.reply;
|
||||
// 「チャンネル接続主への返信」でもなければ、「チャンネル接続主が行った返信」でもなければ、「投稿者の投稿者自身への返信」でもない場合
|
||||
if (reply.userId !== this.user!.id && note.userId !== this.user!.id && reply.userId !== note.userId) return;
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import Channel from '../channel';
|
||||
import { fetchMeta } from '@/misc/fetch-meta';
|
||||
import { Notes } from '@/models/index';
|
||||
import { PackedNote } from '@/models/repositories/note';
|
||||
import { PackedUser } from '@/models/repositories/user';
|
||||
import { checkWordMute } from '@/misc/check-word-mute';
|
||||
import { isBlockerUserRelated } from '@/misc/is-blocker-user-related';
|
||||
|
||||
@ -31,7 +30,7 @@ export default class extends Channel {
|
||||
if (!(
|
||||
(note.channelId == null && this.user!.id === note.userId) ||
|
||||
(note.channelId == null && this.following.has(note.userId)) ||
|
||||
(note.channelId == null && ((note.user as PackedUser).host == null && note.visibility === 'public')) ||
|
||||
(note.channelId == null && (note.user.host == null && note.visibility === 'public')) ||
|
||||
(note.channelId != null && this.followingChannels.has(note.channelId))
|
||||
)) return;
|
||||
|
||||
@ -60,7 +59,7 @@ export default class extends Channel {
|
||||
|
||||
// 関係ない返信は除外
|
||||
if (note.reply) {
|
||||
const reply = note.reply as PackedNote;
|
||||
const reply = note.reply;
|
||||
// 「チャンネル接続主への返信」でもなければ、「チャンネル接続主が行った返信」でもなければ、「投稿者の投稿者自身への返信」でもない場合
|
||||
if (reply.userId !== this.user!.id && note.userId !== this.user!.id && reply.userId !== note.userId) return;
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import Channel from '../channel';
|
||||
import { fetchMeta } from '@/misc/fetch-meta';
|
||||
import { Notes } from '@/models/index';
|
||||
import { PackedNote } from '@/models/repositories/note';
|
||||
import { PackedUser } from '@/models/repositories/user';
|
||||
import { checkWordMute } from '@/misc/check-word-mute';
|
||||
import { isBlockerUserRelated } from '@/misc/is-blocker-user-related';
|
||||
|
||||
@ -26,7 +25,7 @@ export default class extends Channel {
|
||||
|
||||
@autobind
|
||||
private async onNote(note: PackedNote) {
|
||||
if ((note.user as PackedUser).host !== null) return;
|
||||
if (note.user.host !== null) return;
|
||||
if (note.visibility !== 'public') return;
|
||||
if (note.channelId != null && !this.followingChannels.has(note.channelId)) return;
|
||||
|
||||
@ -45,7 +44,7 @@ export default class extends Channel {
|
||||
|
||||
// 関係ない返信は除外
|
||||
if (note.reply) {
|
||||
const reply = note.reply as PackedNote;
|
||||
const reply = note.reply;
|
||||
// 「チャンネル接続主への返信」でもなければ、「チャンネル接続主が行った返信」でもなければ、「投稿者の投稿者自身への返信」でもない場合
|
||||
if (reply.userId !== this.user!.id && note.userId !== this.user!.id && reply.userId !== note.userId) return;
|
||||
}
|
||||
|
@ -165,8 +165,8 @@ export default class Connection {
|
||||
};
|
||||
|
||||
add(note);
|
||||
if (note.reply) add(note.reply as PackedNote);
|
||||
if (note.renote) add(note.renote as PackedNote);
|
||||
if (note.reply) add(note.reply);
|
||||
if (note.renote) add(note.renote);
|
||||
}
|
||||
|
||||
@autobind
|
||||
|
Reference in New Issue
Block a user