mirror of
https://github.com/spacebarchat/server.git
synced 2026-08-14 13:20:32 +00:00
Clean up some types
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -21,7 +21,7 @@ import path from "node:path";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { HTTPError } from "lambert-server/HTTPError";
|
||||
import { route } from "@spacebar/api/middlewares";
|
||||
import { ReportMenuType, ReportMenuTypeNames, CreateReportSchema } from "@spacebar/schemas";
|
||||
import { ReportMenuTypeNames, ReportMenuType, type CreateReportSchema, ReportMenuTypeNameArray } from "@spacebar/schemas";
|
||||
import { FieldErrors } from "@spacebar/util";
|
||||
|
||||
const router = Router({ mergeParams: true });
|
||||
@@ -32,7 +32,7 @@ router.get(
|
||||
description: "[EXT] Get available reporting menu types.",
|
||||
responses: {
|
||||
200: {
|
||||
body: "Array<ReportMenuTypeNames>",
|
||||
body: "ReportMenuTypeNames",
|
||||
},
|
||||
},
|
||||
}),
|
||||
@@ -161,9 +161,7 @@ for (const type of Object.values(ReportMenuTypeNames)) {
|
||||
);
|
||||
};
|
||||
|
||||
const t = Number(Object.entries(ReportMenuTypeNames).find((x) => x[1] === type)?.[0]) as ReportMenuType;
|
||||
// TODO: did i miss anything?
|
||||
switch (t) {
|
||||
switch (type) {
|
||||
case ReportMenuType.GUILD:
|
||||
case ReportMenuType.GUILD_DISCOVERY:
|
||||
requireFields(body, ["guild_id"]);
|
||||
|
||||
@@ -23,7 +23,7 @@ import { route } from "@spacebar/api/middlewares";
|
||||
import { Webhook, Message } from "@spacebar/database";
|
||||
import { Config, DiscordApiErrors, emitEvent, handleFile, ValidateName, WebhooksUpdateEvent } from "@spacebar/util";
|
||||
import { executeWebhook } from "@spacebar/api/util/handlers/Webhook";
|
||||
import { WebhookResponse, WebhookUpdateSchema } from "@spacebar/schemas";
|
||||
import type { WebhookResponse, WebhookUpdateSchema } from "@spacebar/schemas";
|
||||
|
||||
const router = Router({ mergeParams: true });
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import { In } from "typeorm";
|
||||
import { route } from "@spacebar/api/middlewares";
|
||||
import { Webhook, Channel, Message } from "@spacebar/database";
|
||||
import { Config, DiscordApiErrors, getPermission, WebhooksUpdateEvent, emitEvent, handleFile, ValidateName, MessageDeleteBulkEvent } from "@spacebar/util";
|
||||
import { WebhookResponse, WebhookUpdateSchema } from "@spacebar/schemas";
|
||||
import type { WebhookResponse, WebhookUpdateSchema } from "@spacebar/schemas";
|
||||
|
||||
const router = Router({ mergeParams: true });
|
||||
|
||||
|
||||
@@ -17,18 +17,19 @@
|
||||
*/
|
||||
|
||||
export enum ReportMenuType {
|
||||
GUILD,
|
||||
GUILD_DISCOVERY,
|
||||
GUILD_DIRECTORY_ENTRY,
|
||||
GUILD_SCHEDULED_EVENT,
|
||||
MESSAGE,
|
||||
STAGE_CHANNEL,
|
||||
FIRST_DM,
|
||||
USER,
|
||||
APPLICATION,
|
||||
WIDGET,
|
||||
GUILD = "guild",
|
||||
GUILD_DISCOVERY = "guild_discovery",
|
||||
GUILD_DIRECTORY_ENTRY = "guild_directory_entry",
|
||||
GUILD_SCHEDULED_EVENT = "guild_scheduled_event",
|
||||
MESSAGE = "message",
|
||||
STAGE_CHANNEL = "stage_channel",
|
||||
FIRST_DM = "first_dm",
|
||||
USER = "user",
|
||||
APPLICATION = "application",
|
||||
WIDGET = "widget",
|
||||
}
|
||||
|
||||
export type ReportMenuTypeNameArray = ReportMenuType[];
|
||||
export const ReportMenuTypeNames: Record<ReportMenuType, string> = {
|
||||
[ReportMenuType.GUILD]: "guild",
|
||||
[ReportMenuType.GUILD_DISCOVERY]: "guild_discovery",
|
||||
@@ -48,3 +49,48 @@ export enum ReportButtonType {
|
||||
CANCEL = "cancel",
|
||||
NEXT = "next",
|
||||
}
|
||||
|
||||
export interface ReportingMenuResponse {
|
||||
name: string;
|
||||
version: string;
|
||||
variant: string;
|
||||
postback_url: string;
|
||||
language?: string;
|
||||
root_node_id: number;
|
||||
success_node_id: number;
|
||||
fail_node_id: number;
|
||||
nodes: Record<number, ReportNode>;
|
||||
}
|
||||
|
||||
export interface ReportNode {
|
||||
id: number;
|
||||
report_type?: string;
|
||||
key: string;
|
||||
header: string;
|
||||
subheader?: string;
|
||||
info?: string;
|
||||
children: ReportNodeChild[];
|
||||
elements: ReportElement[];
|
||||
button?: ReportButton;
|
||||
is_multi_select_required: boolean;
|
||||
is_auto_submit: boolean;
|
||||
}
|
||||
|
||||
export interface ReportButton {
|
||||
type: ReportButtonType;
|
||||
target: number | null;
|
||||
}
|
||||
|
||||
export interface ReportNodeChild {
|
||||
name: string;
|
||||
target_node_id: number;
|
||||
}
|
||||
|
||||
export interface ReportElement {
|
||||
name: string;
|
||||
type: string;
|
||||
data: object;
|
||||
should_submit_data: boolean;
|
||||
skip_if_unlocalized: boolean;
|
||||
is_localized: boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user