perf: 通知支持meow

This commit is contained in:
xiaojunnuo
2025-10-25 00:09:54 +08:00
parent 6531002d61
commit c77645e173
5 changed files with 96 additions and 1 deletions

View File

@@ -107,6 +107,9 @@ export class NotificationController extends CrudController<NotificationService>
icon: item.icon,
});
}
dict = dict.sort(a => {
return a.order ? 0 : -1;
});
dict = dict.sort(a => {
return a.needPlus ? 0 : -1;
});

View File

@@ -4,6 +4,7 @@ import { BaseNotification, IsNotification, NotificationBody, NotificationInput }
name: 'email',
title: '电子邮件',
desc: '电子邮件通知',
order: -100,
})
export class EmailNotification extends BaseNotification {
@NotificationInput({

View File

@@ -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';
export * from './onebot/index.js';
export * from './meow/index.js';

View File

@@ -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": "<p><b>欢迎使用</b>,这是 <i>HTML</i> 格式的消息</p>",
"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);
}
}
}

View File

@@ -5,6 +5,7 @@ import qs from 'qs';
name: 'webhook',
title: '自定义webhook',
desc: '根据模版自定义http请求',
order: -100,
})
export class WebhookNotification extends BaseNotification {
@NotificationInput({