Enhance the message notification feature

This commit is contained in:
yoan
2024-09-24 22:39:42 +08:00
parent 4c9095400e
commit ac4904fb9a
18 changed files with 1322 additions and 337 deletions

View File

@@ -23,6 +23,7 @@ const Telegram = () => {
name: "notifyChannels",
data: {
apiToken: "",
chatId: "",
enabled: false,
},
});
@@ -31,6 +32,7 @@ const Telegram = () => {
const getDetailTelegram = () => {
const df: NotifyChannelTelegram = {
apiToken: "",
chatId: "",
enabled: false,
};
if (!config.content) {
@@ -98,6 +100,20 @@ const Telegram = () => {
}}
/>
<Input
placeholder="ChatId"
value={telegram.data.chatId}
onChange={(e) => {
setTelegram({
...telegram,
data: {
...telegram.data,
chatId: e.target.value,
},
});
}}
/>
<div className="flex items-center space-x-1 mt-2">
<Switch
id="airplane-mode"

View File

@@ -8,6 +8,7 @@ import { useEffect, useState } from "react";
import { update } from "@/repository/settings";
import { getErrMessage } from "@/lib/error";
import { useToast } from "../ui/use-toast";
import { isValidURL } from "@/lib/url";
type WebhookSetting = {
id: string;
@@ -55,6 +56,16 @@ const Webhook = () => {
const handleSaveClick = async () => {
try {
webhook.data.url = webhook.data.url.trim();
if (!isValidURL(webhook.data.url)) {
toast({
title: "保存失败",
description: "Url格式不正确",
variant: "destructive",
});
return;
}
const resp = await update({
...config,
name: "notifyChannels",