@waline/vercel 1.19.1 → 1.19.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waline/vercel",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.2",
|
|
4
4
|
"description": "vercel server for waline comment system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"waline",
|
|
@@ -32,8 +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
|
-
"node-fetch": "2",
|
|
36
|
-
"nodemailer": "6.7.
|
|
35
|
+
"node-fetch": "2.6.7",
|
|
36
|
+
"nodemailer": "6.7.8",
|
|
37
37
|
"nunjucks": "3.2.3",
|
|
38
38
|
"phpass": "0.1.1",
|
|
39
39
|
"prismjs": "1.28.0",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"think-model": "1.5.4",
|
|
44
44
|
"think-model-mysql": "1.1.7",
|
|
45
45
|
"think-model-postgresql": "1.1.7",
|
|
46
|
-
"think-model-sqlite": "1.
|
|
46
|
+
"think-model-sqlite": "1.3.0",
|
|
47
47
|
"think-mongo": "2.2.1",
|
|
48
48
|
"think-router-rest": "1.0.5",
|
|
49
49
|
"thinkjs": "3.2.14",
|
|
@@ -567,10 +567,17 @@ 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.model('User').select({
|
|
577
|
+
objectId: parentComment.user_id,
|
|
578
|
+
});
|
|
579
|
+
parentUser = parentUser[0];
|
|
580
|
+
}
|
|
574
581
|
}
|
|
575
582
|
|
|
576
583
|
await this.ctx.webhook('new_comment', {
|
|
@@ -578,14 +585,27 @@ module.exports = class extends BaseRest {
|
|
|
578
585
|
reply: parentComment,
|
|
579
586
|
});
|
|
580
587
|
|
|
588
|
+
const cmtReturn = await formatCmt(
|
|
589
|
+
resp,
|
|
590
|
+
[userInfo],
|
|
591
|
+
this.config(),
|
|
592
|
+
userInfo
|
|
593
|
+
);
|
|
594
|
+
const parentReturn = parentComment
|
|
595
|
+
? await formatCmt(
|
|
596
|
+
parentComment,
|
|
597
|
+
parentUser ? [parentUser] : [],
|
|
598
|
+
this.config(),
|
|
599
|
+
userInfo
|
|
600
|
+
)
|
|
601
|
+
: undefined;
|
|
602
|
+
|
|
581
603
|
if (comment.status !== 'spam') {
|
|
582
604
|
const notify = this.service('notify');
|
|
583
605
|
|
|
584
606
|
await notify.run(
|
|
585
|
-
{ ...
|
|
586
|
-
parentComment
|
|
587
|
-
? { ...parentComment, comment: markdownParser(parentComment.comment) }
|
|
588
|
-
: undefined
|
|
607
|
+
{ ...cmtReturn, mail: resp.mail, rawComment: comment },
|
|
608
|
+
parentReturn ? { ...parentReturn, mail: parentComment.mail } : undefined
|
|
589
609
|
);
|
|
590
610
|
}
|
|
591
611
|
|
|
@@ -642,17 +662,47 @@ module.exports = class extends BaseRest {
|
|
|
642
662
|
data.status === 'approved' &&
|
|
643
663
|
oldData.pid
|
|
644
664
|
) {
|
|
665
|
+
let cmtUser;
|
|
666
|
+
|
|
667
|
+
if (newData.user_id) {
|
|
668
|
+
cmtUser = await this.model('User').select({
|
|
669
|
+
objectId: newData.user_id,
|
|
670
|
+
});
|
|
671
|
+
cmtUser = cmtUser[0];
|
|
672
|
+
}
|
|
673
|
+
|
|
645
674
|
let pComment = await this.modelInstance.select({
|
|
646
675
|
objectId: oldData.pid,
|
|
647
676
|
});
|
|
648
677
|
|
|
649
678
|
pComment = pComment[0];
|
|
650
679
|
|
|
680
|
+
let pUser;
|
|
681
|
+
|
|
682
|
+
if (pComment.user_id) {
|
|
683
|
+
pUser = await this.model('User').select({
|
|
684
|
+
objectId: pComment.user_id,
|
|
685
|
+
});
|
|
686
|
+
pUser = pUser[0];
|
|
687
|
+
}
|
|
688
|
+
|
|
651
689
|
const notify = this.service('notify');
|
|
690
|
+
const cmtReturn = await formatCmt(
|
|
691
|
+
newData,
|
|
692
|
+
cmtUser ? [cmtUser] : [],
|
|
693
|
+
this.config(),
|
|
694
|
+
userInfo
|
|
695
|
+
);
|
|
696
|
+
const pcmtReturn = await formatCmt(
|
|
697
|
+
pComment,
|
|
698
|
+
pUser ? [pUser] : [],
|
|
699
|
+
this.config(),
|
|
700
|
+
userInfo
|
|
701
|
+
);
|
|
652
702
|
|
|
653
703
|
await notify.run(
|
|
654
|
-
{ ...
|
|
655
|
-
{ ...
|
|
704
|
+
{ ...cmtReturn, mail: newData.mail },
|
|
705
|
+
{ ...pcmtReturn, mail: pComment.mail },
|
|
656
706
|
true
|
|
657
707
|
);
|
|
658
708
|
}
|
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
|
}
|
|
@@ -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);
|