diff --git a/package.json b/package.json index 260c6148e..af43e59f6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "twikoo", - "version": "1.6.40", + "version": "1.6.41", "description": "A simple comment system.", "keywords": [ "twikoojs", @@ -49,13 +49,14 @@ "cross-env": "^7.0.3", "css-loader": "^6.5.1", "element-ui": "^2.15.6", - "eslint": "^8.2.0", - "eslint-config-standard": "^16.0.3", - "eslint-plugin-import": "^2.25.3", + "eslint": "^8.57.1", + "eslint-config-standard": "^17.1.0", + "eslint-plugin-import": "^2.26.0", + "eslint-plugin-n": "^17.15.1", "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^5.1.1", - "eslint-plugin-standard": "^4.1.0", - "eslint-plugin-vue": "^8.0.3", + "eslint-plugin-promise": "^6.0.0", + "eslint-plugin-standard": "^5.0.0", + "eslint-plugin-vue": "^9.0.0", "js-sha256": "^0.11.0", "marked": "^4.0.12", "mini-css-extract-plugin": "^2.6.1", diff --git a/src/client/utils/i18n/i18n.js b/src/client/utils/i18n/i18n.js index 306082c20..a72fe2df6 100644 --- a/src/client/utils/i18n/i18n.js +++ b/src/client/utils/i18n/i18n.js @@ -23,7 +23,8 @@ const pushooChannels = [ 'pushdeer', 'igot', 'telegram', - 'feishu' + 'feishu', + 'webhook' ].map(s => `"${s}"`) const smtpServices = [ diff --git a/src/server/function/twikoo/package.json b/src/server/function/twikoo/package.json index 82bc8255b..e137550fb 100644 --- a/src/server/function/twikoo/package.json +++ b/src/server/function/twikoo/package.json @@ -1,6 +1,6 @@ { "name": "twikoo-func", - "version": "1.6.40", + "version": "1.6.41", "description": "A simple comment system.", "author": "imaegoo (https://github.com/imaegoo)", "license": "MIT", diff --git a/src/server/function/twikoo/utils/notify.js b/src/server/function/twikoo/utils/notify.js index f67875112..5d5eaf4a6 100644 --- a/src/server/function/twikoo/utils/notify.js +++ b/src/server/function/twikoo/utils/notify.js @@ -11,7 +11,7 @@ const logger = require('./logger') let nodemailer -function lazilyGetNodemailer () { +function lazilyGetNodemailer() { return nodemailer ?? (nodemailer = getNodemailer()) } @@ -19,7 +19,7 @@ let transporter const fn = { // 发送通知 - async sendNotice (comment, config, getParentComment) { + async sendNotice(comment, config, getParentComment) { if (comment.isSpam && config.NOTIFY_SPAM === 'false') return await Promise.all([ fn.noticeMaster(comment, config), @@ -30,7 +30,7 @@ const fn = { }) }, // 初始化邮件插件 - async initMailer ({ config, throwErr = false } = {}) { + async initMailer({ config, throwErr = false } = {}) { try { if (!config || !config.SMTP_USER || !config.SMTP_PASS) { throw new Error('数据库配置不存在') @@ -69,7 +69,7 @@ const fn = { } }, // 博主通知 - async noticeMaster (comment, config) { + async noticeMaster(comment, config) { if (!transporter && !await fn.initMailer({ config })) { logger.info('未配置邮箱或邮箱配置有误,不通知') return @@ -130,7 +130,7 @@ const fn = { return sendResult }, // 即时消息通知 - async noticePushoo (comment, config) { + async noticePushoo(comment, config) { if (!config.PUSHOO_CHANNEL || !config.PUSHOO_TOKEN) { logger.info('没有配置 pushoo,放弃即时消息通知') return @@ -140,43 +140,59 @@ const fn = { return } const pushContent = fn.getIMPushContent(comment, config) - const sendResult = await pushoo(config.PUSHOO_CHANNEL, { - token: config.PUSHOO_TOKEN, - title: pushContent.subject, - content: pushContent.content, - options: { - bark: { - url: pushContent.url + try { + const sendResult = await pushoo(config.PUSHOO_CHANNEL, { + token: config.PUSHOO_TOKEN, + title: pushContent.subject, + content: pushContent.content, + options: { + data: { + url: pushContent.url, + text: pushContent.TEXT, + ip: pushContent.IP, + nick: pushContent.NICK, + mail: pushContent.MAIL, + } } - } - }) - logger.info('即时消息通知结果:', sendResult) + }) + logger.info('即时消息通知结果:', sendResult) + } catch (e) { + throw new Error(error); + } }, // 即时消息推送内容获取 - getIMPushContent (comment, config) { + getIMPushContent(comment, config) { const SITE_NAME = config.SITE_NAME const NICK = comment.nick const MAIL = comment.mail const IP = comment.ip const COMMENT = $(comment.comment).text() + const TEXT = COMMENT; const SITE_URL = config.SITE_URL const POST_URL = fn.appendHashToUrl(comment.href || SITE_URL + comment.url, comment.id) const subject = config.MAIL_SUBJECT_ADMIN || `${SITE_NAME}有新评论了` - const content = `评论人:${NICK} ([${MAIL}](mailto:${MAIL})) - -评论人IP:${IP} + const content = + ` + 评论人:${NICK} ([${MAIL}](mailto:${MAIL})) -评论内容:${COMMENT} + 评论人IP:${IP} + + 评论内容:${COMMENT} -原文链接:[${POST_URL}](${POST_URL})` - return { - subject, - content, - url: POST_URL - } - }, + 原文链接:[${POST_URL}](${POST_URL}) + ` + return { + subject, + content, + url: POST_URL, + NICK, + MAIL, + IP, + TEXT + } + }, // 回复通知 - async noticeReply (currentComment, config, getParentComment) { + async noticeReply(currentComment, config, getParentComment) { if (!currentComment.pid) { logger.info('无父级评论,不通知') return @@ -248,14 +264,14 @@ const fn = { logger.log('回复通知结果:', sendResult) return sendResult }, - appendHashToUrl (url, hash) { + appendHashToUrl(url, hash) { if (url.indexOf('#') === -1) { return `${url}#${hash}` } else { return `${url.substring(0, url.indexOf('#'))}#${hash}` } }, - async emailTest (event, config, isAdminUser) { + async emailTest(event, config, isAdminUser) { const res = {} if (isAdminUser) { try { diff --git a/src/server/netlify/package.json b/src/server/netlify/package.json index 6008941a9..263198e69 100644 --- a/src/server/netlify/package.json +++ b/src/server/netlify/package.json @@ -1,6 +1,6 @@ { "name": "twikoo-netlify", - "version": "1.6.40", + "version": "1.6.41", "description": "A simple comment system.", "author": "imaegoo (https://github.com/imaegoo)", "license": "MIT", diff --git a/src/server/self-hosted/package.json b/src/server/self-hosted/package.json index b405202cb..305517c18 100644 --- a/src/server/self-hosted/package.json +++ b/src/server/self-hosted/package.json @@ -1,6 +1,6 @@ { "name": "tkserver", - "version": "1.6.40", + "version": "1.6.41", "description": "A simple comment system.", "keywords": [ "twikoo", diff --git a/src/server/vercel/package.json b/src/server/vercel/package.json index a8dddfda9..be296deb9 100644 --- a/src/server/vercel/package.json +++ b/src/server/vercel/package.json @@ -1,6 +1,6 @@ { "name": "twikoo-vercel", - "version": "1.6.40", + "version": "1.6.41", "description": "A simple comment system.", "author": "imaegoo (https://github.com/imaegoo)", "license": "MIT",