commit 33a41503f8df0b17c5fc105c6aadb78287388ea3 Author: Victor Jay Date: Fri May 29 04:32:11 2026 +0800 feat: 编辑已过审帖子自动退回审核队列 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7e4d90f --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 MetaLab + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..c8f0601 --- /dev/null +++ b/composer.json @@ -0,0 +1,29 @@ +{ + "name": "metazone/reapprove-on-edit", + "description": "编辑已通过审核的帖子时自动退回审核队列,防止恶意绕过审核。", + "type": "flarum-extension", + "license": "MIT", + "require": { + "flarum/core": "^1.0", + "flarum/approval": "^1.0" + }, + "autoload": { + "psr-4": { + "MetaZone\\ReapproveOnEdit\\": "src/" + } + }, + "extra": { + "flarum-extension": { + "title": "Reapprove On Edit", + "icon": { + "name": "fas fa-shield-alt", + "backgroundColor": "#e67e22", + "color": "#fff" + } + }, + "flarum-locale": { + "code": "en", + "title": "English" + } + } +} diff --git a/extend.php b/extend.php new file mode 100644 index 0000000..2ede3d0 --- /dev/null +++ b/extend.php @@ -0,0 +1,12 @@ +listen(Saving::class, ReapproveOnEditListener::class), +]; diff --git a/src/Listener/ReapproveOnEditListener.php b/src/Listener/ReapproveOnEditListener.php new file mode 100644 index 0000000..142b985 --- /dev/null +++ b/src/Listener/ReapproveOnEditListener.php @@ -0,0 +1,36 @@ +post; + + // 新帖子不处理 + if (! $post->exists) { + return; + } + + // 帖子未被审核通过 + if ($post->is_approved != 1) { + return; + } + + // 内容未变动 + if (! $post->isDirty('content')) { + return; + } + + // 管理员免审 + if (isset($event->actor) && $event->actor->isAdmin()) { + return; + } + + // 退回审核队列 + $post->is_approved = null; + } +}