@waline/vercel 1.32.0 → 1.32.2
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/index.js +2 -1
- package/package.json +9 -9
- package/src/controller/db.js +10 -16
- package/src/extend/controller.js +3 -3
- package/src/logic/comment.js +3 -10
- package/src/service/notify.js +20 -10
- package/src/service/storage/base.js +0 -1
- package/src/service/storage/deta.js +1 -1
- package/vanilla.js +1 -1
package/index.js
CHANGED
|
@@ -22,7 +22,8 @@ module.exports = function (configParams = {}) {
|
|
|
22
22
|
|
|
23
23
|
return function (req, res) {
|
|
24
24
|
for (const k in config) {
|
|
25
|
-
|
|
25
|
+
// fix https://github.com/walinejs/waline/issues/2649 with alias model config name
|
|
26
|
+
think.config(k === 'model' ? 'customModel' : k, config[k]);
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
return think
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waline/vercel",
|
|
3
|
-
"version": "1.32.
|
|
3
|
+
"version": "1.32.2",
|
|
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": "^
|
|
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,20 +23,20 @@
|
|
|
23
23
|
"@mdit/plugin-sup": "0.8.0",
|
|
24
24
|
"akismet": "^2.0.7",
|
|
25
25
|
"deta": "^2.0.0",
|
|
26
|
-
"dompurify": "^3.1.
|
|
26
|
+
"dompurify": "^3.1.7",
|
|
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
|
-
"katex": "^0.16.
|
|
32
|
+
"katex": "^0.16.11",
|
|
33
33
|
"koa-compose": "^4.1.0",
|
|
34
34
|
"leancloud-storage": "^4.15.2",
|
|
35
35
|
"markdown-it": "^14.1.0",
|
|
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": "^1.0.
|
|
54
|
+
"ua-parser-js": "^1.0.39"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=16"
|
package/src/controller/db.js
CHANGED
|
@@ -32,27 +32,21 @@ module.exports = class extends BaseRest {
|
|
|
32
32
|
const model = this.getModel(table);
|
|
33
33
|
|
|
34
34
|
if (storage === 'leancloud' || storage === 'mysql') {
|
|
35
|
-
item.insertedAt
|
|
36
|
-
item.createdAt
|
|
37
|
-
item.updatedAt
|
|
35
|
+
if (item.insertedAt) item.insertedAt = new Date(item.insertedAt);
|
|
36
|
+
if (item.createdAt) item.createdAt = new Date(item.createdAt);
|
|
37
|
+
if (item.updatedAt) item.updatedAt = new Date(item.updatedAt);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
if (storage === 'mysql') {
|
|
41
|
-
item.insertedAt
|
|
42
|
-
|
|
41
|
+
if (item.insertedAt)
|
|
42
|
+
item.insertedAt = think.datetime(
|
|
43
43
|
item.insertedAt,
|
|
44
44
|
'YYYY-MM-DD HH:mm:ss',
|
|
45
|
-
)
|
|
46
|
-
item.createdAt
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
));
|
|
51
|
-
item.updatedAt &&
|
|
52
|
-
(item.updatedAt = think.datetime(
|
|
53
|
-
item.updatedAt,
|
|
54
|
-
'YYYY-MM-DD HH:mm:ss',
|
|
55
|
-
));
|
|
45
|
+
);
|
|
46
|
+
if (item.createdAt)
|
|
47
|
+
item.createdAt = think.datetime(item.createdAt, 'YYYY-MM-DD HH:mm:ss');
|
|
48
|
+
if (item.updatedAt)
|
|
49
|
+
item.updatedAt = think.datetime(item.updatedAt, 'YYYY-MM-DD HH:mm:ss');
|
|
56
50
|
}
|
|
57
51
|
|
|
58
52
|
delete item.objectId;
|
package/src/extend/controller.js
CHANGED
|
@@ -38,10 +38,10 @@ module.exports = {
|
|
|
38
38
|
return nunjucks.renderString(message, variables);
|
|
39
39
|
},
|
|
40
40
|
getModel(modelName) {
|
|
41
|
-
const { storage,
|
|
41
|
+
const { storage, customModel } = this.config();
|
|
42
42
|
|
|
43
|
-
if (typeof
|
|
44
|
-
const modelInstance =
|
|
43
|
+
if (typeof customModel === 'function') {
|
|
44
|
+
const modelInstance = customModel(modelName, this);
|
|
45
45
|
|
|
46
46
|
if (modelInstance) {
|
|
47
47
|
return modelInstance;
|
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,7 @@ 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 } = process.env;
|
|
114
|
+
const { QYWX_AM, QYWX_PROXY, QYWX_PROXY_PORT, SITE_NAME, SITE_URL } = process.env;
|
|
115
115
|
|
|
116
116
|
if (!QYWX_AM) {
|
|
117
117
|
return false;
|
|
@@ -136,6 +136,7 @@ module.exports = class extends think.Service {
|
|
|
136
136
|
postUrl: SITE_URL + self.url + '#' + self.objectId,
|
|
137
137
|
},
|
|
138
138
|
};
|
|
139
|
+
|
|
139
140
|
const contentWechat =
|
|
140
141
|
think.config('WXTemplate') ||
|
|
141
142
|
`💬 {{site.name|safe}}的文章《{{postName}}》有新评论啦
|
|
@@ -154,8 +155,17 @@ module.exports = class extends think.Service {
|
|
|
154
155
|
querystring.set('corpid', `${QYWX_AM_AY[0]}`);
|
|
155
156
|
querystring.set('corpsecret', `${QYWX_AM_AY[1]}`);
|
|
156
157
|
|
|
158
|
+
let baseUrl = 'https://qyapi.weixin.qq.com';
|
|
159
|
+
if (QYWX_PROXY) {
|
|
160
|
+
if (!QYWX_PROXY_PORT) {
|
|
161
|
+
baseUrl = `http://${QYWX_PROXY}`;
|
|
162
|
+
} else {
|
|
163
|
+
baseUrl = `http://${QYWX_PROXY}:${QYWX_PROXY_PORT}`;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
157
167
|
const { access_token } = await fetch(
|
|
158
|
-
|
|
168
|
+
`${baseUrl}/cgi-bin/gettoken?${querystring.toString()}`,
|
|
159
169
|
{
|
|
160
170
|
headers: {
|
|
161
171
|
'content-type': 'application/json',
|
|
@@ -164,7 +174,7 @@ module.exports = class extends think.Service {
|
|
|
164
174
|
).then((resp) => resp.json());
|
|
165
175
|
|
|
166
176
|
return fetch(
|
|
167
|
-
|
|
177
|
+
`${baseUrl}/cgi-bin/message/send?access_token=${access_token}`,
|
|
168
178
|
{
|
|
169
179
|
method: 'POST',
|
|
170
180
|
headers: {
|
|
@@ -346,13 +356,13 @@ module.exports = class extends think.Service {
|
|
|
346
356
|
|
|
347
357
|
const form = new FormData();
|
|
348
358
|
|
|
349
|
-
topic
|
|
350
|
-
template
|
|
351
|
-
channel
|
|
352
|
-
webhook
|
|
353
|
-
callbackUrl
|
|
354
|
-
title
|
|
355
|
-
content
|
|
359
|
+
if (topic) form.append('topic', topic);
|
|
360
|
+
if (template) form.append('template', template);
|
|
361
|
+
if (channel) form.append('channel', channel);
|
|
362
|
+
if (webhook) form.append('webhook', webhook);
|
|
363
|
+
if (callbackUrl) form.append('callbackUrl', callbackUrl);
|
|
364
|
+
if (title) form.append('title', title);
|
|
365
|
+
if (content) form.append('content', content);
|
|
356
366
|
|
|
357
367
|
return fetch(`http://www.pushplus.plus/send/${PUSH_PLUS_KEY}`, {
|
|
358
368
|
method: 'POST',
|