Add new webhook code

This commit is contained in:
zkldi
2021-09-05 06:49:43 +01:00
parent bea45dac12
commit 3b1be3d7b1
3 changed files with 61 additions and 24 deletions
+1
View File
@@ -5,3 +5,4 @@ export * as gameClasses from "./game-classes";
export * as ESDCore from "./lib/esd";
export * as StaticConfig from "./config/static-config";
export * from "./utils/util";
export * from "./webhooks";
+1 -24
View File
@@ -1,6 +1,6 @@
import { IObjectID } from "monk";
import { FilterQuery } from "mongodb";
import { AllClassSets, GameClasses, GameClassSets } from "./game-classes";
import { AllClassSets, GameClasses } from "./game-classes";
export interface CounterDocument {
counterName: string;
@@ -1256,29 +1256,6 @@ export interface BMSCourseDocument {
value: integer;
}
export type RedisIPCChannels = "class-update" | "goal-achieved" | "milestone-achieved";
export type RedisIPCData = {
"class-update": {
userID: integer;
set: GameClassSets[IDStrings];
old: integer | null;
new: integer | null;
};
"goal-achieved": {
userID: integer;
goalID: string;
old: GoalImportStat;
new: GoalImportStat;
};
"milestone-achieved": {
userID: integer;
milestoneID: string;
old: MilestoneImportStat;
new: MilestoneImportStat;
};
};
/**
* All the permissions a token may have.
*/
+59
View File
@@ -0,0 +1,59 @@
import { GameClassSets } from "./game-classes";
import { GoalImportStat, IDStrings, integer, MilestoneImportStat } from "./types";
/**
* An event fired when a users class improves.
*/
export interface WebhookEventClassUpdateV1 {
type: "class-update/v1";
content: {
userID: integer;
set: GameClassSets[IDStrings];
old: integer | null;
new: integer | null;
};
}
/**
* An event fired when a goal is achieved.
*/
export interface WebhookEventGoalAchievedV1 {
type: "goal-achieved/v1";
content: {
userID: integer;
goalID: string;
old: GoalImportStat;
new: GoalImportStat;
};
}
/**
* An event fired when a milestone is achieved.
*/
export interface WebhookEventMilestoneAchievedV1 {
type: "milestone-achieved/v1";
content: {
userID: integer;
milestoneID: string;
old: MilestoneImportStat;
new: MilestoneImportStat;
};
}
/**
* An event used for debugging. Contains information about the
* registered client and the server.
*/
export interface WebhookEventStatusV1 {
type: "status/v1";
content: {
clientName: string;
clientID: string;
serverVersion: string;
};
}
export type WebhookEvents =
| WebhookEventClassUpdateV1
| WebhookEventGoalAchievedV1
| WebhookEventMilestoneAchievedV1;