diff --git a/packages/ui/certd-server/src/controller/user/pipeline/notification-controller.ts b/packages/ui/certd-server/src/controller/user/pipeline/notification-controller.ts index 97b28e3dd..2f0028577 100644 --- a/packages/ui/certd-server/src/controller/user/pipeline/notification-controller.ts +++ b/packages/ui/certd-server/src/controller/user/pipeline/notification-controller.ts @@ -107,6 +107,9 @@ export class NotificationController extends CrudController icon: item.icon, }); } + dict = dict.sort(a => { + return a.order ? 0 : -1; + }); dict = dict.sort(a => { return a.needPlus ? 0 : -1; }); diff --git a/packages/ui/certd-server/src/plugins/plugin-notification/email/index.ts b/packages/ui/certd-server/src/plugins/plugin-notification/email/index.ts index 91e4946a0..666075484 100644 --- a/packages/ui/certd-server/src/plugins/plugin-notification/email/index.ts +++ b/packages/ui/certd-server/src/plugins/plugin-notification/email/index.ts @@ -4,6 +4,7 @@ import { BaseNotification, IsNotification, NotificationBody, NotificationInput } name: 'email', title: '电子邮件', desc: '电子邮件通知', + order: -100, }) export class EmailNotification extends BaseNotification { @NotificationInput({ diff --git a/packages/ui/certd-server/src/plugins/plugin-notification/index.ts b/packages/ui/certd-server/src/plugins/plugin-notification/index.ts index ee1a12bdc..cba9458cc 100644 --- a/packages/ui/certd-server/src/plugins/plugin-notification/index.ts +++ b/packages/ui/certd-server/src/plugins/plugin-notification/index.ts @@ -12,4 +12,5 @@ export * from './bark/index.js'; export * from './feishu/index.js'; export * from './dingtalk/index.js'; export * from './vocechat/index.js'; -export * from './onebot/index.js'; \ No newline at end of file +export * from './onebot/index.js'; +export * from './meow/index.js'; diff --git a/packages/ui/certd-server/src/plugins/plugin-notification/meow/index.ts b/packages/ui/certd-server/src/plugins/plugin-notification/meow/index.ts new file mode 100644 index 000000000..3cc6f235f --- /dev/null +++ b/packages/ui/certd-server/src/plugins/plugin-notification/meow/index.ts @@ -0,0 +1,89 @@ +import { BaseNotification, IsNotification, NotificationBody, NotificationInput } from '@certd/pipeline'; + +/** + * POST请求 +支持格式 +application/json +text/plain +multipart/form-data +application/x-www-form-urlencoded +表单格式 +POST /{昵称}/[title] HTTP/1.1 +Content-Type: application/x-www-form-urlencoded + +title=可选标题&msg=必填内容&url=可选链接&msgType=html&htmlHeight=400 + +纯文本格式 +POST /{昵称}/[title] HTTP/1.1 +Content-Type: text/plain + +这里放置消息内容 + +POST JSON示例 +POST /JohnDoe?msgType=html&htmlHeight=350 HTTP/1.1 +Host: api.chuckfang.com +Content-Type: application/json + +{ + "title": "系统通知", + "msg": "

欢迎使用,这是 HTML 格式的消息

", + "url": "https://example.com" +} + +=== +返回值: +{ + "status": 200, + "message": "推送成功" +} + */ +@IsNotification({ + name: 'meow', + title: 'MeoW通知', + desc: 'https://api.chuckfang.com/', + needPlus: false, +}) +export class MeowNotification extends BaseNotification { + + @NotificationInput({ + title: 'MeoW接口地址', + component: { + placeholder: 'https://api.xxxxxx.com', + }, + required: true, + }) + endpoint = ''; + + @NotificationInput({ + title: '昵称', + component: { + placeholder: '', + }, + required: true, + }) + nickName = ''; + + async send(body: NotificationBody) { + if (!this.nickName) { + throw new Error('昵称不能为空'); + } + let endpoint = this.endpoint; + if (!endpoint.endsWith('/')) { + endpoint += '/'; + } + const url = `${endpoint}${this.nickName}/`; + const res = await this.http.request({ + url: url, + method: 'POST', + data: { + text: body.title, + msg: body.content, + url: body.url, + }, + }); + + if (res.status !== 200) { + throw new Error(res.message || res.msg); + } + } +} diff --git a/packages/ui/certd-server/src/plugins/plugin-notification/webhook/index.ts b/packages/ui/certd-server/src/plugins/plugin-notification/webhook/index.ts index 4e2fba05a..a173a6ab7 100644 --- a/packages/ui/certd-server/src/plugins/plugin-notification/webhook/index.ts +++ b/packages/ui/certd-server/src/plugins/plugin-notification/webhook/index.ts @@ -5,6 +5,7 @@ import qs from 'qs'; name: 'webhook', title: '自定义webhook', desc: '根据模版自定义http请求', + order: -100, }) export class WebhookNotification extends BaseNotification { @NotificationInput({