@waline/vercel 1.19.0 → 1.19.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waline/vercel",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.3",
|
|
4
4
|
"description": "vercel server for waline comment system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"waline",
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
"markdown-it-sub": "1.0.0",
|
|
33
33
|
"markdown-it-sup": "1.0.0",
|
|
34
34
|
"mathjax-full": "3.2.2",
|
|
35
|
-
"
|
|
35
|
+
"node-fetch": "2.6.7",
|
|
36
|
+
"nodemailer": "6.7.8",
|
|
36
37
|
"nunjucks": "3.2.3",
|
|
37
38
|
"phpass": "0.1.1",
|
|
38
39
|
"prismjs": "1.28.0",
|
|
@@ -42,12 +43,11 @@
|
|
|
42
43
|
"think-model": "1.5.4",
|
|
43
44
|
"think-model-mysql": "1.1.7",
|
|
44
45
|
"think-model-postgresql": "1.1.7",
|
|
45
|
-
"think-model-sqlite": "1.
|
|
46
|
+
"think-model-sqlite": "1.3.0",
|
|
46
47
|
"think-mongo": "2.2.1",
|
|
47
48
|
"think-router-rest": "1.0.5",
|
|
48
49
|
"thinkjs": "3.2.14",
|
|
49
|
-
"ua-parser-js": "1.0.2"
|
|
50
|
-
"undici": "^5.8.0"
|
|
50
|
+
"ua-parser-js": "1.0.2"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
53
53
|
"node": ">=14"
|
package/src/config/extend.js
CHANGED
|
@@ -567,10 +567,20 @@ module.exports = class extends BaseRest {
|
|
|
567
567
|
think.logger.debug(`Comment have been added to storage.`);
|
|
568
568
|
|
|
569
569
|
let parentComment;
|
|
570
|
+
let parentUser;
|
|
570
571
|
|
|
571
572
|
if (pid) {
|
|
572
573
|
parentComment = await this.modelInstance.select({ objectId: pid });
|
|
573
574
|
parentComment = parentComment[0];
|
|
575
|
+
if (parentComment.user_id) {
|
|
576
|
+
parentUser = await this.service(
|
|
577
|
+
`storage/${this.config('storage')}`,
|
|
578
|
+
'User'
|
|
579
|
+
).select({
|
|
580
|
+
objectId: parentComment.user_id,
|
|
581
|
+
});
|
|
582
|
+
parentUser = parentUser[0];
|
|
583
|
+
}
|
|
574
584
|
}
|
|
575
585
|
|
|
576
586
|
await this.ctx.webhook('new_comment', {
|
|
@@ -578,14 +588,27 @@ module.exports = class extends BaseRest {
|
|
|
578
588
|
reply: parentComment,
|
|
579
589
|
});
|
|
580
590
|
|
|
591
|
+
const cmtReturn = await formatCmt(
|
|
592
|
+
resp,
|
|
593
|
+
[userInfo],
|
|
594
|
+
this.config(),
|
|
595
|
+
userInfo
|
|
596
|
+
);
|
|
597
|
+
const parentReturn = parentComment
|
|
598
|
+
? await formatCmt(
|
|
599
|
+
parentComment,
|
|
600
|
+
parentUser ? [parentUser] : [],
|
|
601
|
+
this.config(),
|
|
602
|
+
userInfo
|
|
603
|
+
)
|
|
604
|
+
: undefined;
|
|
605
|
+
|
|
581
606
|
if (comment.status !== 'spam') {
|
|
582
607
|
const notify = this.service('notify');
|
|
583
608
|
|
|
584
609
|
await notify.run(
|
|
585
|
-
{ ...
|
|
586
|
-
parentComment
|
|
587
|
-
? { ...parentComment, comment: markdownParser(parentComment.comment) }
|
|
588
|
-
: undefined
|
|
610
|
+
{ ...cmtReturn, mail: resp.mail, rawComment: comment },
|
|
611
|
+
parentReturn ? { ...parentReturn, mail: parentComment.mail } : undefined
|
|
589
612
|
);
|
|
590
613
|
}
|
|
591
614
|
|
|
@@ -642,17 +665,53 @@ module.exports = class extends BaseRest {
|
|
|
642
665
|
data.status === 'approved' &&
|
|
643
666
|
oldData.pid
|
|
644
667
|
) {
|
|
668
|
+
let cmtUser;
|
|
669
|
+
|
|
670
|
+
if (newData.user_id) {
|
|
671
|
+
cmtUser = await this.service(
|
|
672
|
+
`storage/${this.config('storage')}`,
|
|
673
|
+
'User'
|
|
674
|
+
).select({
|
|
675
|
+
objectId: newData.user_id,
|
|
676
|
+
});
|
|
677
|
+
cmtUser = cmtUser[0];
|
|
678
|
+
}
|
|
679
|
+
|
|
645
680
|
let pComment = await this.modelInstance.select({
|
|
646
681
|
objectId: oldData.pid,
|
|
647
682
|
});
|
|
648
683
|
|
|
649
684
|
pComment = pComment[0];
|
|
650
685
|
|
|
686
|
+
let pUser;
|
|
687
|
+
|
|
688
|
+
if (pComment.user_id) {
|
|
689
|
+
pUser = await this.service(
|
|
690
|
+
`storage/${this.config('storage')}`,
|
|
691
|
+
'User'
|
|
692
|
+
).select({
|
|
693
|
+
objectId: pComment.user_id,
|
|
694
|
+
});
|
|
695
|
+
pUser = pUser[0];
|
|
696
|
+
}
|
|
697
|
+
|
|
651
698
|
const notify = this.service('notify');
|
|
699
|
+
const cmtReturn = await formatCmt(
|
|
700
|
+
newData,
|
|
701
|
+
cmtUser ? [cmtUser] : [],
|
|
702
|
+
this.config(),
|
|
703
|
+
userInfo
|
|
704
|
+
);
|
|
705
|
+
const pcmtReturn = await formatCmt(
|
|
706
|
+
pComment,
|
|
707
|
+
pUser ? [pUser] : [],
|
|
708
|
+
this.config(),
|
|
709
|
+
userInfo
|
|
710
|
+
);
|
|
652
711
|
|
|
653
712
|
await notify.run(
|
|
654
|
-
{ ...
|
|
655
|
-
{ ...
|
|
713
|
+
{ ...cmtReturn, mail: newData.mail },
|
|
714
|
+
{ ...pcmtReturn, mail: pComment.mail },
|
|
656
715
|
true
|
|
657
716
|
);
|
|
658
717
|
}
|
package/src/controller/db.js
CHANGED
|
@@ -6,8 +6,10 @@ const readFileAsync = util.promisify(fs.readFile);
|
|
|
6
6
|
|
|
7
7
|
function formatID(data, idGenerator) {
|
|
8
8
|
const objectIdMap = {};
|
|
9
|
+
|
|
9
10
|
for (let i = 0; i < data.length; i++) {
|
|
10
11
|
const { objectId } = data[i];
|
|
12
|
+
|
|
11
13
|
objectIdMap[objectId] = idGenerator(data[i], i, data);
|
|
12
14
|
}
|
|
13
15
|
|
|
@@ -42,6 +44,7 @@ module.exports = class extends BaseRest {
|
|
|
42
44
|
const model = this.service(`storage/${storage}`, tableName);
|
|
43
45
|
|
|
44
46
|
const data = await model.select({});
|
|
47
|
+
|
|
45
48
|
exportData.data[tableName] = data;
|
|
46
49
|
}
|
|
47
50
|
|
|
@@ -68,8 +71,10 @@ module.exports = class extends BaseRest {
|
|
|
68
71
|
|
|
69
72
|
idMaps[tableName] = new Map();
|
|
70
73
|
let data = importData.data[tableName];
|
|
74
|
+
|
|
71
75
|
if (['postgresql', 'mysql', 'sqlite'].includes(storage)) {
|
|
72
76
|
let i = 0;
|
|
77
|
+
|
|
73
78
|
data = formatID(data, () => (i = i + 1));
|
|
74
79
|
} else if (storage === 'leancloud') {
|
|
75
80
|
data
|
|
@@ -131,6 +136,7 @@ module.exports = class extends BaseRest {
|
|
|
131
136
|
return this.success();
|
|
132
137
|
}
|
|
133
138
|
console.log(e);
|
|
139
|
+
|
|
134
140
|
return this.fail(e.message);
|
|
135
141
|
}
|
|
136
142
|
}
|
package/src/controller/oauth.js
CHANGED
package/src/service/notify.js
CHANGED
|
@@ -9,7 +9,7 @@ module.exports = class extends Base {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
for (const k in filter) {
|
|
12
|
-
if (k === 'objectId') {
|
|
12
|
+
if (k === 'objectId' || k === 'objectid') {
|
|
13
13
|
where.id = filter[k];
|
|
14
14
|
continue;
|
|
15
15
|
}
|
|
@@ -78,6 +78,11 @@ module.exports = class extends Base {
|
|
|
78
78
|
data.id = data.objectId;
|
|
79
79
|
delete data.objectId;
|
|
80
80
|
}
|
|
81
|
+
const date = new Date();
|
|
82
|
+
if (!data.createdAt)
|
|
83
|
+
data.createdAt = date;
|
|
84
|
+
if (!data.updatedAt)
|
|
85
|
+
data.updatedAt = date;
|
|
81
86
|
|
|
82
87
|
const instance = this.model(this.tableName);
|
|
83
88
|
const id = await instance.add(data);
|