From b68f36869301fbdee039a1d2cdb744dfa1ecc846 Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Sat, 2 Jul 2022 20:43:54 +0100 Subject: [PATCH] feat: add challenge types --- common/src/constants/permissions.ts | 1 + common/src/types.ts | 36 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/common/src/constants/permissions.ts b/common/src/constants/permissions.ts index 600809257..310419e71 100644 --- a/common/src/constants/permissions.ts +++ b/common/src/constants/permissions.ts @@ -10,4 +10,5 @@ export const ALL_PERMISSIONS: Record = { manage_rivals: true, manage_targets: true, submit_score: true, + manage_challenges: true, }; diff --git a/common/src/types.ts b/common/src/types.ts index cf9a689af..77c469931 100644 --- a/common/src/types.ts +++ b/common/src/types.ts @@ -1392,6 +1392,7 @@ export type APIPermissions = | "customise_score" | "customise_session" | "delete_score" + | "manage_challenges" | "manage_rivals" | "manage_targets" | "submit_score"; @@ -1579,6 +1580,19 @@ interface BaseNotification { } export type NotificationBody = + | { + type: "CHALLENGE_BEAT"; + content: { + userID: integer; + challengeSub: ChallengeSubscriptionDocument; + }; + } + | { + type: "CHALLENGE_RECEIVED"; + content: { + challenge: ChallengeWallDocument; + }; + } | { type: "MILESTONE_CHANGED"; // Emitted when a milestone the user is subscribed to changed. content: { @@ -1597,3 +1611,25 @@ export type NotificationBody = export type NotificationDocument = BaseNotification & { body: NotificationBody; }; + +export interface ChallengeSubscriptionDocument { + chartID: string; + authorID: integer; + type: "lamp" | "score"; + + game: Game; + playtype: Playtype; + + userID: integer; + achieved: boolean; + achievedAt: number | null; +} + +export interface ChallengeWallDocument { + chartID: string; + authorID: integer; + type: "lamp" | "score"; + + game: Game; + playtype: Playtype; +}