summaryrefslogtreecommitdiff
path: root/src/misc
diff options
context:
space:
mode:
authortamaina <tamaina@hotmail.co.jp>2021-09-22 22:35:55 +0900
committerGitHub <noreply@github.com>2021-09-22 22:35:55 +0900
commit14795b68f2234c90504cd0a979de42ff4d757441 (patch)
treeaef21d0af6db7f373fe095806fbccce414375fc3 /src/misc
parentNew Crowdin updates (#7764) (diff)
downloadsharkey-14795b68f2234c90504cd0a979de42ff4d757441.tar.gz
sharkey-14795b68f2234c90504cd0a979de42ff4d757441.tar.bz2
sharkey-14795b68f2234c90504cd0a979de42ff4d757441.zip
refactor: PackedHoge型をPacked<'Hoge'>型に書き換える (#7792)
* 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の型不整合を修正 * add prelude/types.ts * emoji * signin * game * matching * fix * add emoji schema * add reversiGame * add reversiMatching * remove signin schema (use Signin entity) * add Packed type * note-reaction * user * user-group * user-list * note * app, messaging-message * notification * drive-file * drive-folder * following * muting * blocking * hashtag * page * app (with modifying schema) * import user? * channel * antenna * clip * gallery-post * emoji * Packed * reversi-matching * add changelog * add changelog * revert fix
Diffstat (limited to 'src/misc')
-rw-r--r--src/misc/check-hit-antenna.ts4
-rw-r--r--src/misc/schema.ts10
2 files changed, 11 insertions, 3 deletions
diff --git a/src/misc/check-hit-antenna.ts b/src/misc/check-hit-antenna.ts
index 38965f4b0d..3789054b26 100644
--- a/src/misc/check-hit-antenna.ts
+++ b/src/misc/check-hit-antenna.ts
@@ -3,13 +3,13 @@ import { Note } from '@/models/entities/note';
import { User } from '@/models/entities/user';
import { UserListJoinings, UserGroupJoinings } from '@/models/index';
import { getFullApAccount } from './convert-host';
-import { PackedNote } from '../models/repositories/note';
import { parseAcct } from '@/misc/acct';
+import { Packed } from './schema';
/**
* noteUserFollowers / antennaUserFollowing はどちらか一方が指定されていればよい
*/
-export async function checkHitAntenna(antenna: Antenna, note: (Note | PackedNote), noteUser: { username: string; host: string | null; }, noteUserFollowers?: User['id'][], antennaUserFollowing?: User['id'][]): Promise<boolean> {
+export async function checkHitAntenna(antenna: Antenna, note: (Note | Packed<'Note'>), noteUser: { username: string; host: string | null; }, noteUserFollowers?: User['id'][], antennaUserFollowing?: User['id'][]): Promise<boolean> {
if (note.visibility === 'specified') return false;
if (note.visibility === 'followers') {
diff --git a/src/misc/schema.ts b/src/misc/schema.ts
index d27c9eff99..4131875ef7 100644
--- a/src/misc/schema.ts
+++ b/src/misc/schema.ts
@@ -21,6 +21,9 @@ 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 { packedEmojiSchema } from '@/models/repositories/emoji';
+import { packedReversiGameSchema } from '@/models/repositories/games/reversi/game';
+import { packedReversiMatchingSchema } from '@/models/repositories/games/reversi/matching';
export const refs = {
User: packedUserSchema,
@@ -45,8 +48,13 @@ export const refs = {
Clip: packedClipSchema,
FederationInstance: packedFederationInstanceSchema,
GalleryPost: packedGalleryPostSchema,
+ Emoji: packedEmojiSchema,
+ ReversiGame: packedReversiGameSchema,
+ ReversiMatching: packedReversiMatchingSchema,
};
+export type Packed<x extends keyof typeof refs> = ObjType<(typeof refs[x])['properties']>;
+
export interface Schema extends SimpleSchema {
items?: Schema;
properties?: Obj;
@@ -92,7 +100,7 @@ export type SchemaType<p extends Schema> =
p['type'] extends 'array' ? NullOrUndefined<p, MyType<NonNullable<p['items']>>[]> :
p['type'] extends 'object' ? (
p['ref'] extends keyof typeof refs
- ? NullOrUndefined<p, SchemaType<typeof refs[p['ref']]>>
+ ? NullOrUndefined<p, Packed<p['ref']>>
: NullOrUndefined<p, ObjType<NonNullable<p['properties']>>>
) :
p['type'] extends 'any' ? NullOrUndefined<p, any> :