Compare commits

..

No commits in common. "master" and "v1.0.0" have entirely different histories.

5 changed files with 10 additions and 45 deletions

1
.gitignore vendored
View File

@ -1,6 +1,5 @@
# Do not index node.js modules that are used for building # Do not index node.js modules that are used for building
node_modules node_modules
package-lock.json
# Do not index releases # Do not index releases
release release

View File

@ -28,8 +28,6 @@ use Mibew\EventDispatcher\EventDispatcher;
use Mibew\EventDispatcher\Events; use Mibew\EventDispatcher\Events;
use Mibew\Plugin\AbstractPlugin; use Mibew\Plugin\AbstractPlugin;
use Mibew\Plugin\PluginInterface; use Mibew\Plugin\PluginInterface;
use Mibew\Settings;
use Mibew\Thread;
/** /**
* The main plugin's file definition. * The main plugin's file definition.
@ -54,15 +52,9 @@ class Plugin extends AbstractPlugin implements PluginInterface
*/ */
public function run() public function run()
{ {
if (!Settings::get('enableban')) {
// Bans are disabled. The plugin should do nothing in this case.
return;
}
$dispatcher = EventDispatcher::getInstance(); $dispatcher = EventDispatcher::getInstance();
$dispatcher->attachListener(Events::USERS_UPDATE_THREADS_ALTER, $this, 'alterThreads'); $dispatcher->attachListener(Events::USERS_UPDATE_THREADS_ALTER, $this, 'alterThreads');
$dispatcher->attachListener(Events::USERS_UPDATE_VISITORS_ALTER, $this, 'alterVisitors'); $dispatcher->attachListener(Events::USERS_UPDATE_VISITORS_ALTER, $this, 'alterVisitors');
$dispatcher->attachListener(Events::THREAD_UPDATE, $this, 'handleThreadUpdate');
} }
/** /**
@ -117,34 +109,6 @@ class Plugin extends AbstractPlugin implements PluginInterface
$args['visitors'] = $visitors; $args['visitors'] = $visitors;
} }
/**
* A handler for {@link \Mibew\EventDispatcher\Events::THREAD_UPDATE} event.
*
* When the thread is added to the awaiting queue the method sends
* notification about ban if it's needed.
*
* @param array $args Event arguments.
*/
public function handleThreadUpdate($args)
{
$thread = $args['thread'];
$orig_thread = $args['original_thread'];
if ($thread->state != $orig_thread->state && $thread->state == Thread::STATE_QUEUE) {
// State is change and the thread is in the awaiting queue now.
$ban = Ban::loadByAddress($thread->remote);
if ($ban && !$ban->isExpired()) {
// Operators could not see the user, because he is banned. A
// notification should be sent to let user know that he is
// banned.
$thread->postMessage(
Thread::KIND_INFO,
getlocal('Sorry, but your IP address is banned by some reasons. Try to use another way to contact the support.')
);
}
}
}
/** /**
* Specify version of the plugin. * Specify version of the plugin.
* *
@ -152,6 +116,6 @@ class Plugin extends AbstractPlugin implements PluginInterface
*/ */
public static function getVersion() public static function getVersion()
{ {
return '1.1.0'; return '1.0.0';
} }
} }

View File

@ -5,7 +5,7 @@ It hides banned threads and visitors on the awaiting page.
## Installation ## Installation
1. Get the archive with the plugin sources. You can download it from the [official site](https://mibew.org/plugins#mibew-real-ban) or build the plugin from sources. 1. Get the archive with the plugin sources. At the moment the only option is to build the plugin from sources.
2. Untar/unzip the plugin's archive. 2. Untar/unzip the plugin's archive.
3. Put files of the plugins to the `<Mibew root>/plugins` folder. 3. Put files of the plugins to the `<Mibew root>/plugins` folder.
4. Navigate to "`<Mibew Base URL>`/operator/plugin" page and enable the plugin. 4. Navigate to "`<Mibew Base URL>`/operator/plugin" page and enable the plugin.

View File

@ -21,7 +21,9 @@ gulp.task('prepare-release', function() {
}); });
// Builds and packs plugins sources // Builds and packs plugins sources
gulp.task('default', gulp.series('prepare-release')); gulp.task('default', ['prepare-release'], function() {
// The "default" task is just an alias for "prepare-release" task.
});
/** /**
* Returns files stream with the plugin sources. * Returns files stream with the plugin sources.

View File

@ -1,12 +1,12 @@
{ {
"version": "1.1.0", "version": "1.0.0",
"devDependencies": { "devDependencies": {
"gulp": "~4.0.0", "gulp": "~3.8.10",
"event-stream": "~3.1.7", "event-stream": "~3.1.7",
"gulp-zip": "~2.0.2", "gulp-zip": "~2.0.2",
"gulp-tar": "~3.1.0", "gulp-tar": "~1.3.1",
"gulp-gzip": "~0.0.8", "gulp-gzip": "~0.0.8",
"gulp-chmod": "~3.0.0", "gulp-chmod": "~1.2.0",
"gulp-rename": "~1.2.0" "gulp-rename": "~1.2.0"
} }
} }