PushMe 通知支持自建服务 (#2358)

This commit is contained in:
雨思 2024-05-15 22:38:25 +08:00 committed by GitHub
parent 0b52e05af8
commit 8dd379b6b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 22 additions and 7 deletions

View File

@ -108,6 +108,7 @@ export class EmailNotification extends NotificationBaseInfo {
export class PushMeNotification extends NotificationBaseInfo {
public pushMeKey: string = '';
public pushMeUrl: string = '';
}
export class ChronocatNotification extends NotificationBaseInfo {

View File

@ -573,13 +573,14 @@ export default class NotificationService {
}
private async pushMe() {
const { pushMeKey } = this.params;
const { pushMeKey, pushMeUrl } = this.params;
try {
const res: any = await got.post(
`https://push.i-i.me/?push_key=${pushMeKey}`,
pushMeUrl || 'https://push.i-i.me/',
{
...this.gotOption,
json: {
push_key: pushMeKey,
title: this.title,
content: this.content,
},

View File

@ -176,7 +176,9 @@ export SMTP_NAME=""
## 15. PushMe
## 官方说明文档https://push.i-i.me/
## PUSHME_KEY (必填)填写PushMe APP上获取的push_key
## PUSHME_URL (选填)填写自建的PushMeServer消息服务接口地址例如http://127.0.0.1:3010不填则使用官方接口服务
export PUSHME_KEY=""
export PUSHME_URL=""
## 16. 飞书机器人
## 官方文档https://www.feishu.cn/hc/zh-CN/articles/360024984973

View File

@ -935,11 +935,11 @@ async function smtpNotify(text, desp) {
function pushMeNotify(text, desp, params = {}) {
return new Promise((resolve) => {
const { PUSHME_KEY } = push_config;
const { PUSHME_KEY, PUSHME_URL } = push_config;
if (PUSHME_KEY) {
const options = {
url: `https://push.i-i.me?push_key=${PUSHME_KEY}`,
json: { title: text, content: desp, ...params },
url: PUSHME_URL || 'https://push.i-i.me',
json: { push_key: PUSHME_KEY, title: text, content: desp, ...params },
headers: {
'Content-Type': 'application/json',
},

View File

@ -101,7 +101,8 @@ push_config = {
'SMTP_PASSWORD': '', # SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定
'SMTP_NAME': '', # SMTP 收发件人姓名,可随意填写
'PUSHME_KEY': '', # PushMe 酱的 PUSHME_KEY
'PUSHME_KEY': '', # PushMe 的 PUSHME_KEY
'PUSHME_URL': '', # PushMe 的 PUSHME_URL
'CHRONOCAT_QQ': '', # qq号
'CHRONOCAT_TOKEN': '', # CHRONOCAT 的token
@ -668,10 +669,13 @@ def pushme(title: str, content: str) -> None:
return
print("PushMe 服务启动")
url = f'https://push.i-i.me/?push_key={push_config.get("PUSHME_KEY")}'
url = push_config.get("PUSHME_URL") if push_config.get("PUSHME_URL") else "https://push.i-i.me/"
data = {
"push_key": push_config.get("PUSHME_KEY"),
"title": title,
"content": content,
"date": push_config.get("date") if push_config.get("date") else "",
"type": push_config.get("type") if push_config.get("type") else "",
}
response = requests.post(url, data=data)

View File

@ -383,6 +383,7 @@
"邮箱地址": "Email Address",
"SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定": "The SMTP login password may also be a special passphrase, depending on the specific email service provider's instructions",
"PushMe的Keyhttps://push.i-i.me/": "PushMe key, https://push.i-i.me/",
"自建的PushMeServer消息接口地址例如http://127.0.0.1:3010不填则使用官方消息接口": "The self built PushMeServer message interface address, for example: http://127.0.0.1:3010 If left blank, use the official message interface",
"请求方法": "Request Method",
"请求头Content-Type": "Request Header Content-Type",
"请求链接以http或者https开头。url或者body中必须包含$title$content可选对应api内容的位置": "Request URL should start with http or https. URL or body must contain $title, $content is optional and corresponds to the API content position.",

View File

@ -383,6 +383,7 @@
"邮箱地址": "邮箱地址",
"SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定": "SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定",
"PushMe的Keyhttps://push.i-i.me/": "PushMe的Keyhttps://push.i-i.me/",
"自建的PushMeServer消息接口地址例如http://127.0.0.1:3010不填则使用官方消息接口": "自建的PushMeServer消息接口地址例如http://127.0.0.1:3010不填则使用官方消息接口",
"请求方法": "请求方法",
"请求头Content-Type": "请求头Content-Type",
"请求链接以http或者https开头。url或者body中必须包含$title$content可选对应api内容的位置": "请求链接以http或者https开头。url或者body中必须包含$title$content可选对应api内容的位置",

View File

@ -338,6 +338,11 @@ export default {
tip: intl.get('PushMe的Keyhttps://push.i-i.me/'),
required: true,
},
{
label: 'pushMeUrl',
tip: intl.get('自建的PushMeServer消息接口地址例如http://127.0.0.1:3010不填则使用官方消息接口'),
required: false,
},
],
chronocat: [
{