Skip to content

Commit

Permalink
feat: EMS/FD/LEO incident webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 committed Oct 23, 2023
1 parent ea8a1c7 commit 02e93ac
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- AlterEnum
-- This migration adds more than one value to an enum.
-- With PostgreSQL versions 11 and earlier, this is not possible
-- in a single migration. This can be worked around by creating
-- multiple migrations, each migration adding only one value to
-- the enum.


ALTER TYPE "DiscordWebhookType" ADD VALUE 'LEO_INCIDENT_CREATED';
ALTER TYPE "DiscordWebhookType" ADD VALUE 'EMS_FD_INCIDENT_CREATED';
2 changes: 2 additions & 0 deletions apps/api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -1909,6 +1909,8 @@ enum DiscordWebhookType {
CITIZEN_DECLARED_DEAD
DEPARTMENT_WHITELIST_STATUS
USER_WHITELIST_STATUS
LEO_INCIDENT_CREATED
EMS_FD_INCIDENT_CREATED
}

enum JailTimeScale {
Expand Down
6 changes: 5 additions & 1 deletion apps/client/locales/en/cad-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@
"departmentWhitelistStatusChannelInfo": "When a unit is pending approval or gets accepted/denied this channel will be used to send a webhook to.",
"departmentWhitelistStatusChannel": "Department Whitelist Status Change Channel",
"userWhitelistStatusChannelInfo": "When a user is pending approval or gets accepted/denied this channel will be used to send a webhook to.",
"userWhitelistStatusChannel": "User Whitelist Status Change Channel"
"userWhitelistStatusChannel": "User Whitelist Status Change Channel",
"leoIncidentCreatedInfo": "When an LEO incident is created this channel will be used to send a webhook to.",
"leoIncidentCreated": "LEO Incident Created",
"emsFdIncidentCreatedInfo": "When an EMS/FD incident is created this channel will be used to send a webhook to.",
"emsFdIncidentCreated": "EMS/FD Incident Created"
},
"RawWebhooksTab": {
"rawWebhooks": "Raw Webhooks",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,22 @@ export function DiscordWebhooksTab() {
label={t("userWhitelistStatusChannel")}
/>

<WebhookSettingsField
disabled={Boolean(fetchError)}
fieldName={DiscordWebhookType.LEO_INCIDENT_CREATED}
channels={channels}
description={t("leoIncidentCreatedInfo")}
label={t("leoIncidentCreated")}
/>

<WebhookSettingsField
disabled={Boolean(fetchError)}
fieldName={DiscordWebhookType.EMS_FD_INCIDENT_CREATED}
channels={channels}
description={t("emsFdIncidentCreatedInfo")}
label={t("emsFdIncidentCreated")}
/>

<Button
className="flex items-center float-right"
type="submit"
Expand Down
2 changes: 1 addition & 1 deletion packages/schemas/src/admin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const DISCORD_SETTINGS_SCHEMA = z.object({

/** discord webhooks */
const DISCORD_WEBHOOK_TYPE =
/CALL_911|BOLO|UNIT_STATUS|PANIC_BUTTON|VEHICLE_IMPOUNDED|CITIZEN_RECORD|WARRANTS|BLEETER_POST|CITIZEN_DECLARED_DEAD|USER_WHITELIST_STATUS|DEPARTMENT_WHITELIST_STATUS/;
/CALL_911|BOLO|UNIT_STATUS|PANIC_BUTTON|VEHICLE_IMPOUNDED|CITIZEN_RECORD|WARRANTS|BLEETER_POST|CITIZEN_DECLARED_DEAD|USER_WHITELIST_STATUS|DEPARTMENT_WHITELIST_STATUS|LEO_INCIDENT_CREATED|EMS_FD_INCIDENT_CREATED/;

export const DISCORD_WEBHOOK = z.object({
id: z.string().max(255).nullish(),
Expand Down
2 changes: 2 additions & 0 deletions packages/types/src/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ export const DiscordWebhookType = {
CITIZEN_DECLARED_DEAD: "CITIZEN_DECLARED_DEAD",
DEPARTMENT_WHITELIST_STATUS: "DEPARTMENT_WHITELIST_STATUS",
USER_WHITELIST_STATUS: "USER_WHITELIST_STATUS",
LEO_INCIDENT_CREATED: "LEO_INCIDENT_CREATED",
EMS_FD_INCIDENT_CREATED: "EMS_FD_INCIDENT_CREATED",
} as const;

export type DiscordWebhookType = (typeof DiscordWebhookType)[keyof typeof DiscordWebhookType];
Expand Down

0 comments on commit 02e93ac

Please sign in to comment.