mirror of
https://github.com/usual2970/certimate.git
synced 2025-10-05 14:04:54 +00:00
Merge pull request #579 from catfishlty/feat/gotify
feat(notify): add gotify
This commit is contained in:
@@ -7,6 +7,7 @@ import { useAntdForm } from "@/hooks";
|
||||
import NotifyChannelEditFormBarkFields from "./NotifyChannelEditFormBarkFields";
|
||||
import NotifyChannelEditFormDingTalkFields from "./NotifyChannelEditFormDingTalkFields";
|
||||
import NotifyChannelEditFormEmailFields from "./NotifyChannelEditFormEmailFields";
|
||||
import NotifyChannelEditFormGotifyFields from "./NotifyChannelEditFormGotifyFields.tsx";
|
||||
import NotifyChannelEditFormLarkFields from "./NotifyChannelEditFormLarkFields";
|
||||
import NotifyChannelEditFormPushPlusFields from "./NotifyChannelEditFormPushPlusFields";
|
||||
import NotifyChannelEditFormServerChanFields from "./NotifyChannelEditFormServerChanFields";
|
||||
@@ -49,6 +50,8 @@ const NotifyChannelEditForm = forwardRef<NotifyChannelEditFormInstance, NotifyCh
|
||||
return <NotifyChannelEditFormDingTalkFields />;
|
||||
case NOTIFY_CHANNELS.EMAIL:
|
||||
return <NotifyChannelEditFormEmailFields />;
|
||||
case NOTIFY_CHANNELS.GOTIFY:
|
||||
return <NotifyChannelEditFormGotifyFields />;
|
||||
case NOTIFY_CHANNELS.LARK:
|
||||
return <NotifyChannelEditFormLarkFields />;
|
||||
case NOTIFY_CHANNELS.PUSHPLUS:
|
||||
|
@@ -0,0 +1,46 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, Input } from "antd";
|
||||
import { createSchemaFieldRule } from "antd-zod";
|
||||
import { z } from "zod";
|
||||
|
||||
const NotifyChannelEditFormGotifyFields = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
url: z.string({ message: t("settings.notification.channel.form.gotify_url.placeholder") }).url({ message: t("common.errmsg.url_invalid") }),
|
||||
token: z.string({ message: t("settings.notification.channel.form.gotify_token.placeholder") }),
|
||||
priority: z.preprocess(val => Number(val), z.number({ message: t("settings.notification.channel.form.gotify_priority.placeholder") }).gte(0, { message: t("settings.notification.channel.form.gotify_priority.error.gte0") })),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name="url"
|
||||
label={t("settings.notification.channel.form.gotify_url.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("settings.notification.channel.form.gotify_url.tooltip") }}></span>}
|
||||
>
|
||||
<Input placeholder={t("settings.notification.channel.form.gotify_url.placeholder")} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="token"
|
||||
label={t("settings.notification.channel.form.gotify_token.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("settings.notification.channel.form.gotify_token.tooltip") }}></span>}
|
||||
>
|
||||
<Input placeholder={t("settings.notification.channel.form.gotify_token.placeholder")} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="priority"
|
||||
label={t("settings.notification.channel.form.gotify_priority.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("settings.notification.channel.form.gotify_priority.tooltip") }}></span>}
|
||||
>
|
||||
<Input placeholder={t("settings.notification.channel.form.gotify_priority.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default NotifyChannelEditFormGotifyFields;
|
@@ -40,6 +40,7 @@ export const NOTIFY_CHANNELS = Object.freeze({
|
||||
BARK: "bark",
|
||||
DINGTALK: "dingtalk",
|
||||
EMAIL: "email",
|
||||
GOTIFY: "gotify",
|
||||
LARK: "lark",
|
||||
PUSHPLUS: "pushplus",
|
||||
SERVERCHAN: "serverchan",
|
||||
@@ -59,6 +60,7 @@ export type NotifyChannelsSettingsContent = {
|
||||
[NOTIFY_CHANNELS.BARK]?: BarkNotifyChannelConfig;
|
||||
[NOTIFY_CHANNELS.DINGTALK]?: DingTalkNotifyChannelConfig;
|
||||
[NOTIFY_CHANNELS.EMAIL]?: EmailNotifyChannelConfig;
|
||||
[NOTIFY_CHANNELS.GOTIFY]?: GotifyNotifyChannelConfig;
|
||||
[NOTIFY_CHANNELS.LARK]?: LarkNotifyChannelConfig;
|
||||
[NOTIFY_CHANNELS.PUSHPLUS]?: PushPlusNotifyChannelConfig;
|
||||
[NOTIFY_CHANNELS.SERVERCHAN]?: ServerChanNotifyChannelConfig;
|
||||
@@ -90,6 +92,13 @@ export type DingTalkNotifyChannelConfig = {
|
||||
enabled?: boolean;
|
||||
};
|
||||
|
||||
export type GotifyNotifyChannelConfig = {
|
||||
url: string;
|
||||
token: string;
|
||||
priority: string;
|
||||
enabled?: boolean;
|
||||
};
|
||||
|
||||
export type LarkNotifyChannelConfig = {
|
||||
webhookUrl: string;
|
||||
enabled?: boolean;
|
||||
@@ -130,6 +139,7 @@ export const notifyChannelsMap: Map<NotifyChannel["type"], NotifyChannel> = new
|
||||
[
|
||||
[NOTIFY_CHANNELS.EMAIL, "common.notifier.email"],
|
||||
[NOTIFY_CHANNELS.DINGTALK, "common.notifier.dingtalk"],
|
||||
[NOTIFY_CHANNELS.GOTIFY, "common.notifier.gotify"],
|
||||
[NOTIFY_CHANNELS.LARK, "common.notifier.lark"],
|
||||
[NOTIFY_CHANNELS.PUSHPLUS, "common.notifier.pushplus"],
|
||||
[NOTIFY_CHANNELS.WECOM, "common.notifier.wecom"],
|
||||
|
@@ -38,6 +38,7 @@
|
||||
"common.notifier.bark": "Bark",
|
||||
"common.notifier.dingtalk": "DingTalk",
|
||||
"common.notifier.email": "Email",
|
||||
"common.notifier.gotify": "Gotify",
|
||||
"common.notifier.lark": "Lark",
|
||||
"common.notifier.pushplus": "PushPlus",
|
||||
"common.notifier.serverchan": "ServerChan",
|
||||
|
@@ -53,6 +53,16 @@
|
||||
"settings.notification.channel.form.email_sender_address.placeholder": "Please enter sender email address",
|
||||
"settings.notification.channel.form.email_receiver_address.label": "Receiver email address",
|
||||
"settings.notification.channel.form.email_receiver_address.placeholder": "Please enter receiver email address",
|
||||
"settings.notification.channel.form.gotify_url.placeholder": "Please enter Service URL",
|
||||
"settings.notification.channel.form.gotify_url.label": "Service URL",
|
||||
"settings.notification.channel.form.gotify_url.tooltip": "Example: <b>https://gotify.exmaple.com</b>, the protocol needs to be included but the trailing '/' should not be included.<br>For more information, see <a href=\"https://gotify.net/docs/pushmsg\" target=\"_blank\">https://gotify.net/docs/pushmsg</a>",
|
||||
"settings.notification.channel.form.gotify_token.placeholder": "Please enter Application Token",
|
||||
"settings.notification.channel.form.gotify_token.label": "Application Token",
|
||||
"settings.notification.channel.form.gotify_token.tooltip": "For more information, see <a href=\"https://gotify.net/docs/pushmsg\" target=\"_blank\">https://gotify.net/docs/pushmsg</a>",
|
||||
"settings.notification.channel.form.gotify_priority.placeholder": "Please enter message priority",
|
||||
"settings.notification.channel.form.gotify_priority.label": "Message Priority",
|
||||
"settings.notification.channel.form.gotify_priority.tooltip": "Message Priority, you can set it to 1 as default.<br>For more information, see <a href=\"https://gotify.net/docs/pushmsg\" target=\"_blank\">https://gotify.net/docs/pushmsg</a><br><a href=\"https://github.com/gotify/android/issues/18#issuecomment-437403888\" target=\"_blank\">https://github.com/gotify/android/issues/18#issuecomment-437403888</a>",
|
||||
"settings.notification.channel.form.gotify_priority.error.gte0": "Message Priority must be greater than or equal to 0.",
|
||||
"settings.notification.channel.form.lark_webhook_url.label": "Webhook URL",
|
||||
"settings.notification.channel.form.lark_webhook_url.placeholder": "Please enter Webhook URL",
|
||||
"settings.notification.channel.form.lark_webhook_url.tooltip": "For more information, see <a href=\"https://www.feishu.cn/hc/en-US/articles/807992406756\" target=\"_blank\">https://www.feishu.cn/hc/en-US/articles/807992406756</a>",
|
||||
|
@@ -38,6 +38,7 @@
|
||||
"common.notifier.bark": "Bark",
|
||||
"common.notifier.dingtalk": "钉钉",
|
||||
"common.notifier.email": "邮件",
|
||||
"common.notifier.gotify": "Gotify",
|
||||
"common.notifier.lark": "飞书",
|
||||
"common.notifier.pushplus": "PushPlus推送加",
|
||||
"common.notifier.serverchan": "Server 酱",
|
||||
|
@@ -53,6 +53,16 @@
|
||||
"settings.notification.channel.form.email_sender_address.placeholder": "请输入发送邮箱地址",
|
||||
"settings.notification.channel.form.email_receiver_address.label": "接收邮箱地址",
|
||||
"settings.notification.channel.form.email_receiver_address.placeholder": "请输入接收邮箱地址",
|
||||
"settings.notification.channel.form.gotify_url.placeholder": "请输入服务地址",
|
||||
"settings.notification.channel.form.gotify_url.label": "服务地址",
|
||||
"settings.notification.channel.form.gotify_url.tooltip": "示例: <b>https://gotify.exmaple.com</>,需要包含协议但不要包含末尾的'/'。<br>请参阅 <a href=\"https://gotify.net/docs/pushmsg\" target=\"_blank\">https://gotify.net/docs/pushmsg</a>",
|
||||
"settings.notification.channel.form.gotify_token.placeholder": "请输入应用Token",
|
||||
"settings.notification.channel.form.gotify_token.label": "应用Token",
|
||||
"settings.notification.channel.form.gotify_token.tooltip": "应用Token。<br>请参阅 <a href=\"https://gotify.net/docs/pushmsg\" target=\"_blank\">https://gotify.net/docs/pushmsg</a>",
|
||||
"settings.notification.channel.form.gotify_priority.placeholder": "请输入消息优先级",
|
||||
"settings.notification.channel.form.gotify_priority.label": "消息优先级",
|
||||
"settings.notification.channel.form.gotify_priority.tooltip": "消息优先级, 可以设置为1作为默认值。<br>请参阅 <a href=\"https://gotify.net/docs/pushmsg\" target=\"_blank\">https://gotify.net/docs/pushmsg</a><br><a href=\"https://github.com/gotify/android/issues/18#issuecomment-437403888\" target=\"_blank\">https://github.com/gotify/android/issues/18#issuecomment-437403888</a>",
|
||||
"settings.notification.channel.form.gotify_priority.error.gte0": "消息优先级需要大于等于0",
|
||||
"settings.notification.channel.form.lark_webhook_url.label": "机器人 Webhook 地址",
|
||||
"settings.notification.channel.form.lark_webhook_url.placeholder": "请输入机器人 Webhook 地址",
|
||||
"settings.notification.channel.form.lark_webhook_url.tooltip": "这是什么?请参阅 <a href=\"https://www.feishu.cn/hc/zh-CN/articles/807992406756\" target=\"_blank\">https://www.feishu.cn/hc/zh-CN/articles/807992406756</a>",
|
||||
|
Reference in New Issue
Block a user