|
1 | 1 | /*! |
2 | | - * Twikoo vercel function v1.4.12 |
| 2 | + * Twikoo vercel function v1.4.13 |
3 | 3 | * (c) 2020-present iMaeGoo |
4 | 4 | * Released under the MIT License. |
5 | 5 | */ |
@@ -27,7 +27,7 @@ const window = new JSDOM('').window |
27 | 27 | const DOMPurify = createDOMPurify(window) |
28 | 28 |
|
29 | 29 | // 常量 / constants |
30 | | -const VERSION = '1.4.12' |
| 30 | +const VERSION = '1.4.13' |
31 | 31 | const RES_CODE = { |
32 | 32 | SUCCESS: 0, |
33 | 33 | NO_PARAM: 100, |
@@ -852,7 +852,7 @@ async function commentSubmit (event) { |
852 | 852 | axios.post(`https://${process.env.VERCEL_URL}`, { |
853 | 853 | event: 'POST_SUBMIT', |
854 | 854 | comment |
855 | | - }, { headers: { 'x-twikoo-recursion': 'true' } }), |
| 855 | + }, { headers: { 'x-twikoo-recursion': config.ADMIN_PASS || 'true' } }), |
856 | 856 | // 如果超过 5 秒还没收到异步返回,直接继续,减少用户等待的时间 |
857 | 857 | new Promise((resolve) => setTimeout(resolve, 5000)) |
858 | 858 | ]) |
@@ -950,7 +950,7 @@ async function noticeMaster (comment) { |
950 | 950 | if (hasIMPushConfig && config.SC_MAIL_NOTIFY !== 'true') return |
951 | 951 | const SITE_NAME = config.SITE_NAME |
952 | 952 | const NICK = comment.nick |
953 | | - const IMG = comment.avatar |
| 953 | + const IMG = getAvatar(comment) |
954 | 954 | const IP = comment.ip |
955 | 955 | const MAIL = comment.mail |
956 | 956 | const COMMENT = comment.comment |
@@ -1113,8 +1113,8 @@ async function noticeReply (currentComment) { |
1113 | 1113 | // 回复自己的评论,不邮件通知 |
1114 | 1114 | if (currentComment.mail === parentComment.mail) return |
1115 | 1115 | const PARENT_NICK = parentComment.nick |
1116 | | - const IMG = currentComment.avatar |
1117 | | - const PARENT_IMG = parentComment.avatar |
| 1116 | + const IMG = getAvatar(currentComment) |
| 1117 | + const PARENT_IMG = getAvatar(parentComment) |
1118 | 1118 | const SITE_NAME = config.SITE_NAME |
1119 | 1119 | const NICK = currentComment.nick |
1120 | 1120 | const COMMENT = currentComment.comment |
@@ -1192,7 +1192,6 @@ async function parse (comment) { |
1192 | 1192 | ip: request.headers['x-real-ip'], |
1193 | 1193 | master: isBloggerMail, |
1194 | 1194 | url: comment.url, |
1195 | | - avatar: getAvatar(comment), |
1196 | 1195 | href: comment.href, |
1197 | 1196 | comment: DOMPurify.sanitize(comment.comment, { FORBID_TAGS: ['style'], FORBID_ATTR: ['style'] }), |
1198 | 1197 | pid: comment.pid ? comment.pid : comment.rid, |
@@ -1626,7 +1625,7 @@ async function isAdmin () { |
1626 | 1625 |
|
1627 | 1626 | // 判断是否为递归调用(即云函数调用自身) |
1628 | 1627 | function isRecursion () { |
1629 | | - return request.headers['x-twikoo-recursion'] === 'true' |
| 1628 | + return request.headers['x-twikoo-recursion'] === (config.ADMIN_PASS || 'true') |
1630 | 1629 | } |
1631 | 1630 |
|
1632 | 1631 | // 建立数据库 collections |
|
0 commit comments