Wlork RelicSystem
I know this is not exactly what you requested, but I started just to try and ended up creating a code that nearly fulfills your request.
If a comment is flagged by 2 different people (you can adjust the number next to the flagCount
value in the code), it will turn into an unapproved comment and will be hidden from all users except for administrators.
I tested it on my own forum and did not encounter any errors or performance issues. Although I cannot yet make this into an extension, if you paste this code into the extend.php
file in the main directory, it should work without any problems.
Note: I am aware that this is not exactly what you wanted, I wrote it to learn more about Flarum listeners and to improve myself. I wanted to share it here in case anyone wants to use it until a better solution is made. If you have any additional variables or different requests, feel free to let me know.
extend.php
<?php
use Flarum\Extend;
use Flarum\Flags\Event\Created as FlagCreated;
use Flarum\Flags\Flag;
return [
(new Extend\Event())
->listen(FlagCreated::class, function (FlagCreated $event) {
$post = $event->flag->post;
if ($post) {
$flagCount = Flag::where('post_id', $post->id)->count();
if ($flagCount >= 2) {
$post->is_approved = false;
$post->save();
}
}
}),
];