@waline/vercel 1.32.1 → 1.32.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/src/extend/controller.js +1 -1
- package/src/logic/comment.js +3 -10
- package/src/service/notify.js +15 -3
- package/src/service/storage/postgresql.js +18 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waline/vercel",
|
|
3
|
-
"version": "1.32.
|
|
3
|
+
"version": "1.32.3",
|
|
4
4
|
"description": "vercel server for waline comment system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"waline",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"author": "lizheming <i@imnerd.org>",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@cloudbase/node-sdk": "^3.
|
|
18
|
+
"@cloudbase/node-sdk": "^3.3.7",
|
|
19
19
|
"@koa/cors": "^5.0.0",
|
|
20
20
|
"@mdit/plugin-katex": "0.8.0",
|
|
21
21
|
"@mdit/plugin-mathjax": "0.4.8",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"@mdit/plugin-sup": "0.8.0",
|
|
24
24
|
"akismet": "^2.0.7",
|
|
25
25
|
"deta": "^2.0.0",
|
|
26
|
-
"dompurify": "^3.
|
|
26
|
+
"dompurify": "^3.2.2",
|
|
27
27
|
"dy-node-ip2region": "^1.0.1",
|
|
28
|
-
"fast-csv": "^5.0.
|
|
29
|
-
"form-data": "^4.0.
|
|
30
|
-
"jsdom": "^
|
|
28
|
+
"fast-csv": "^5.0.2",
|
|
29
|
+
"form-data": "^4.0.1",
|
|
30
|
+
"jsdom": "^25.0.1",
|
|
31
31
|
"jsonwebtoken": "^9.0.2",
|
|
32
32
|
"katex": "^0.16.11",
|
|
33
33
|
"koa-compose": "^4.1.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"markdown-it-emoji": "^3.0.0",
|
|
37
37
|
"mathjax-full": "^3.2.2",
|
|
38
38
|
"node-fetch": "^2.7.0",
|
|
39
|
-
"nodemailer": "^6.9.
|
|
39
|
+
"nodemailer": "^6.9.16",
|
|
40
40
|
"nunjucks": "^3.2.4",
|
|
41
41
|
"phpass": "^0.1.1",
|
|
42
42
|
"prismjs": "^1.29.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"think-mongo": "^2.2.1",
|
|
52
52
|
"think-router-rest": "^1.0.5",
|
|
53
53
|
"thinkjs": "^3.2.15",
|
|
54
|
-
"ua-parser-js": "^
|
|
54
|
+
"ua-parser-js": "^2.0.0"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=16"
|
package/src/extend/controller.js
CHANGED
|
@@ -20,7 +20,7 @@ module.exports = {
|
|
|
20
20
|
return this[this.ctx.state.deprecated ? 'json' : 'success'](...args);
|
|
21
21
|
},
|
|
22
22
|
locale(message, variables) {
|
|
23
|
-
const { userLang } = this.get();
|
|
23
|
+
const { lang: userLang } = this.get();
|
|
24
24
|
const lang = (userLang || defaultLang).toLowerCase();
|
|
25
25
|
|
|
26
26
|
const customLocales = this.config('locales');
|
package/src/logic/comment.js
CHANGED
|
@@ -249,17 +249,10 @@ module.exports = class extends Base {
|
|
|
249
249
|
*/
|
|
250
250
|
async putAction() {
|
|
251
251
|
const { userInfo } = this.ctx.state;
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
// 1. like
|
|
255
|
-
if (think.isEmpty(userInfo) && think.isBoolean(like)) {
|
|
256
|
-
this.rules = {
|
|
257
|
-
like: {
|
|
258
|
-
required: true,
|
|
259
|
-
boolean: true,
|
|
260
|
-
},
|
|
261
|
-
};
|
|
252
|
+
const data = this.post();
|
|
262
253
|
|
|
254
|
+
// 1. like action
|
|
255
|
+
if (think.isBoolean(data.like) && Object.keys(data).toString() === 'like') {
|
|
263
256
|
return;
|
|
264
257
|
}
|
|
265
258
|
|
package/src/service/notify.js
CHANGED
|
@@ -111,7 +111,8 @@ module.exports = class extends think.Service {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
async qywxAmWechat({ title, content }, self, parent) {
|
|
114
|
-
const { QYWX_AM, SITE_NAME, SITE_URL } =
|
|
114
|
+
const { QYWX_AM, QYWX_PROXY, QYWX_PROXY_PORT, SITE_NAME, SITE_URL } =
|
|
115
|
+
process.env;
|
|
115
116
|
|
|
116
117
|
if (!QYWX_AM) {
|
|
117
118
|
return false;
|
|
@@ -136,6 +137,7 @@ module.exports = class extends think.Service {
|
|
|
136
137
|
postUrl: SITE_URL + self.url + '#' + self.objectId,
|
|
137
138
|
},
|
|
138
139
|
};
|
|
140
|
+
|
|
139
141
|
const contentWechat =
|
|
140
142
|
think.config('WXTemplate') ||
|
|
141
143
|
`💬 {{site.name|safe}}的文章《{{postName}}》有新评论啦
|
|
@@ -154,8 +156,18 @@ module.exports = class extends think.Service {
|
|
|
154
156
|
querystring.set('corpid', `${QYWX_AM_AY[0]}`);
|
|
155
157
|
querystring.set('corpsecret', `${QYWX_AM_AY[1]}`);
|
|
156
158
|
|
|
159
|
+
let baseUrl = 'https://qyapi.weixin.qq.com';
|
|
160
|
+
|
|
161
|
+
if (QYWX_PROXY) {
|
|
162
|
+
if (!QYWX_PROXY_PORT) {
|
|
163
|
+
baseUrl = `http://${QYWX_PROXY}`;
|
|
164
|
+
} else {
|
|
165
|
+
baseUrl = `http://${QYWX_PROXY}:${QYWX_PROXY_PORT}`;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
157
169
|
const { access_token } = await fetch(
|
|
158
|
-
|
|
170
|
+
`${baseUrl}/cgi-bin/gettoken?${querystring.toString()}`,
|
|
159
171
|
{
|
|
160
172
|
headers: {
|
|
161
173
|
'content-type': 'application/json',
|
|
@@ -164,7 +176,7 @@ module.exports = class extends think.Service {
|
|
|
164
176
|
).then((resp) => resp.json());
|
|
165
177
|
|
|
166
178
|
return fetch(
|
|
167
|
-
|
|
179
|
+
`${baseUrl}/cgi-bin/message/send?access_token=${access_token}`,
|
|
168
180
|
{
|
|
169
181
|
method: 'POST',
|
|
170
182
|
headers: {
|
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
const MySQL = require('./mysql.js');
|
|
2
2
|
|
|
3
|
+
function mapKeys({ insertedat, createdat, updatedat, ...item }) {
|
|
4
|
+
const mapFields = {
|
|
5
|
+
insertedAt: insertedat,
|
|
6
|
+
createdAt: createdat,
|
|
7
|
+
updatedAt: updatedat,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
for (const field in mapFields) {
|
|
11
|
+
if (!mapFields[field]) {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
item[field] = mapFields[field];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return item;
|
|
18
|
+
}
|
|
3
19
|
module.exports = class extends MySQL {
|
|
4
20
|
model(tableName) {
|
|
5
21
|
return super.model(tableName.toLowerCase());
|
|
@@ -22,22 +38,7 @@ module.exports = class extends MySQL {
|
|
|
22
38
|
|
|
23
39
|
const data = await super.select(lowerWhere, options);
|
|
24
40
|
|
|
25
|
-
return data.map(
|
|
26
|
-
const mapFields = {
|
|
27
|
-
insertedAt: insertedat,
|
|
28
|
-
createdAt: createdat,
|
|
29
|
-
updatedAt: updatedat,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
for (const field in mapFields) {
|
|
33
|
-
if (!mapFields[field]) {
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
item[field] = mapFields[field];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return item;
|
|
40
|
-
});
|
|
41
|
+
return data.map(mapKeys);
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
async add(data) {
|
|
@@ -53,7 +54,7 @@ module.exports = class extends MySQL {
|
|
|
53
54
|
delete data[key];
|
|
54
55
|
});
|
|
55
56
|
|
|
56
|
-
return super.add(data);
|
|
57
|
+
return super.add(data).then(mapKeys);
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
async count(...args) {
|