Skip to content

Commit b4c49bd

Browse files
committed
删除评论和主题时,也删除积分
1 parent bfeadb3 commit b4c49bd

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

controllers/reply.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,9 @@ exports.delete = function (req, res, next) {
9292
reply.save();
9393
res.json({status: 'success'});
9494

95-
if (!reply.reply_id) {
96-
reply.author.score -= 5;
97-
reply.author.reply_count -= 1;
98-
reply.author.save();
99-
}
95+
reply.author.score -= 5;
96+
reply.author.reply_count -= 1;
97+
reply.author.save();
10098
} else {
10199
res.json({status: 'failed'});
102100
return;

controllers/topic.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ exports.delete = function (req, res, next) {
266266

267267
var topic_id = req.params.tid;
268268

269-
Topic.getTopic(topic_id, function (err, topic) {
269+
Topic.getFullTopic(topic_id, function (err, err_msg, topic, author, replies) {
270270
if (err) {
271271
return res.send({ success: false, message: err.message });
272272
}
@@ -278,6 +278,10 @@ exports.delete = function (req, res, next) {
278278
res.status(422);
279279
return res.send({ success: false, message: '此话题不存在或已被删除。' });
280280
}
281+
author.score -= 5;
282+
author.topic_count -= 1;
283+
author.save();
284+
281285
topic.deleted = true;
282286
topic.save(function (err) {
283287
if (err) {

0 commit comments

Comments
 (0)