@waline/vercel 1.8.0 → 1.8.1
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 +7 -7
- package/src/controller/comment.js +13 -4
- package/src/controller/index.js +3 -2
- package/src/service/avatar.js +10 -2
package/package.json
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waline/vercel",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "vercel server for waline comment system",
|
|
5
5
|
"repository": "https://github.com/walinejs/waline",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "lizheming <i@imnerd.org>",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@byteinspire/api": "^1.0.12",
|
|
10
|
-
"@cloudbase/node-sdk": "^2.
|
|
11
|
-
"@koa/cors": "^3.
|
|
10
|
+
"@cloudbase/node-sdk": "^2.9.0",
|
|
11
|
+
"@koa/cors": "^3.2.0",
|
|
12
12
|
"akismet": "^2.0.6",
|
|
13
|
-
"deta": "^1.0
|
|
13
|
+
"deta": "^1.1.0",
|
|
14
14
|
"dompurify": "^2.3.6",
|
|
15
15
|
"fast-csv": "^4.3.6",
|
|
16
16
|
"jsdom": "^19.0.0",
|
|
17
17
|
"jsonwebtoken": "^8.5.1",
|
|
18
|
-
"katex": "^0.15.
|
|
18
|
+
"katex": "^0.15.3",
|
|
19
19
|
"leancloud-storage": "^4.12.2",
|
|
20
20
|
"markdown-it": "^12.3.2",
|
|
21
21
|
"markdown-it-emoji": "^2.0.0",
|
|
22
22
|
"markdown-it-sub": "^1.0.0",
|
|
23
23
|
"markdown-it-sup": "^1.0.0",
|
|
24
24
|
"mathjax-full": "^3.2.0",
|
|
25
|
-
"nodemailer": "^6.7.
|
|
25
|
+
"nodemailer": "^6.7.3",
|
|
26
26
|
"nunjucks": "^3.2.3",
|
|
27
27
|
"phpass": "^0.1.1",
|
|
28
28
|
"prismjs": "^1.27.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"request-promise-native": "^1.0.9",
|
|
31
31
|
"think-logger3": "^1.3.1",
|
|
32
32
|
"think-model": "^1.5.4",
|
|
33
|
-
"think-model-mysql": "^1.1.
|
|
33
|
+
"think-model-mysql": "^1.1.7",
|
|
34
34
|
"think-model-postgresql": "^1.1.6",
|
|
35
35
|
"think-model-sqlite": "^1.2.2",
|
|
36
36
|
"think-mongo": "^2.1.2",
|
|
@@ -441,7 +441,12 @@ module.exports = class extends BaseRest {
|
|
|
441
441
|
|
|
442
442
|
async putAction() {
|
|
443
443
|
const data = this.post();
|
|
444
|
-
|
|
444
|
+
let oldData = await this.modelInstance.select({ objectId: this.id });
|
|
445
|
+
if (think.isEmpty(oldData)) {
|
|
446
|
+
return this.success();
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
oldData = oldData[0];
|
|
445
450
|
const preUpdateResp = await this.hook('preUpdate', {
|
|
446
451
|
...data,
|
|
447
452
|
objectId: this.id,
|
|
@@ -451,18 +456,22 @@ module.exports = class extends BaseRest {
|
|
|
451
456
|
return this.fail(preUpdateResp);
|
|
452
457
|
}
|
|
453
458
|
|
|
454
|
-
await this.modelInstance.update(data, {
|
|
459
|
+
const newData = await this.modelInstance.update(data, {
|
|
460
|
+
objectId: this.id,
|
|
461
|
+
});
|
|
455
462
|
|
|
456
463
|
if (
|
|
457
464
|
oldData.status === 'waiting' &&
|
|
458
465
|
data.status === 'approved' &&
|
|
459
466
|
oldData.pid
|
|
460
467
|
) {
|
|
461
|
-
let pComment = await this.modelInstance.select({
|
|
468
|
+
let pComment = await this.modelInstance.select({
|
|
469
|
+
objectId: oldData.pid,
|
|
470
|
+
});
|
|
462
471
|
pComment = pComment[0];
|
|
463
472
|
|
|
464
473
|
const notify = this.service('notify');
|
|
465
|
-
await notify.run(
|
|
474
|
+
await notify.run(newData, pComment, true);
|
|
466
475
|
}
|
|
467
476
|
|
|
468
477
|
await this.hook('postUpdate', data);
|
package/src/controller/index.js
CHANGED
|
@@ -19,10 +19,11 @@ module.exports = class extends think.Controller {
|
|
|
19
19
|
'color: white; background: #0078E7; padding:5px 0;',
|
|
20
20
|
'padding:4px;border:1px solid #0078E7;'
|
|
21
21
|
);
|
|
22
|
+
const params = new URLSearchParams(location.search.slice(1));
|
|
22
23
|
const waline = new Waline({
|
|
23
24
|
el: '#waline',
|
|
24
|
-
path: '/',
|
|
25
|
-
lang:
|
|
25
|
+
path: params.get('path') || '/',
|
|
26
|
+
lang: params.get('lng'),
|
|
26
27
|
serverURL: location.protocol + '//' + location.host + location.pathname.replace(/\\/+$/, '')
|
|
27
28
|
});
|
|
28
29
|
</script>
|
package/src/service/avatar.js
CHANGED
|
@@ -5,6 +5,15 @@ const { GRAVATAR_STR } = process.env;
|
|
|
5
5
|
const env = new nunjucks.Environment();
|
|
6
6
|
env.addFilter('md5', (str) => helper.md5(str));
|
|
7
7
|
|
|
8
|
+
const DEFAULT_GRAVATAR_STR = `{%- set numExp = r/^[0-9]+$/g -%}
|
|
9
|
+
{%- set qqMailExp = r/^[0-9]+@qq.com$/ig -%}
|
|
10
|
+
{%- if numExp.test(nick) -%}
|
|
11
|
+
https://q1.qlogo.cn/g?b=qq&nk={{nick}}&s=100
|
|
12
|
+
{%- elif qqMailExp.test(mail) -%}
|
|
13
|
+
https://q1.qlogo.cn/g?b=qq&nk={{mail|replace('@qq.com', '')}}&s=100
|
|
14
|
+
{%- else -%}
|
|
15
|
+
https://seccdn.libravatar.org/avatar/{{mail|md5}}
|
|
16
|
+
{%- endif -%}`;
|
|
8
17
|
module.exports = class extends think.Service {
|
|
9
18
|
async stringify(comment) {
|
|
10
19
|
const fn = think.config('avatarUrl');
|
|
@@ -15,8 +24,7 @@ module.exports = class extends think.Service {
|
|
|
15
24
|
}
|
|
16
25
|
}
|
|
17
26
|
|
|
18
|
-
const gravatarStr =
|
|
19
|
-
GRAVATAR_STR || 'https://seccdn.libravatar.org/avatar/{{mail|md5}}';
|
|
27
|
+
const gravatarStr = GRAVATAR_STR || DEFAULT_GRAVATAR_STR;
|
|
20
28
|
return env.renderString(gravatarStr, comment);
|
|
21
29
|
}
|
|
22
30
|
};
|