1
0
mirror of https://github.com/flarum/core.git synced 2025-08-01 22:20:21 +02:00

ApproveContent then refresh user table DiscussionCount and CommentCount (#16)

This commit is contained in:
imzhi
2021-02-19 21:18:01 +08:00
committed by GitHub
parent 04f4b1f14e
commit 687e1c41db

8
extensions/approval/src/Listener/ApproveContent.php Normal file → Executable file
View File

@@ -44,14 +44,22 @@ class ApproveContent
{
$post = $event->post;
$discussion = $post->discussion;
$user = $discussion->user;
$discussion->refreshCommentCount();
$discussion->refreshLastPost();
if ($post->number == 1) {
$discussion->is_approved = true;
$discussion->afterSave(function () use ($user) {
$user->refreshDiscussionCount();
});
}
$discussion->save();
$user->refreshCommentCount();
$user->save();
}
}