Compare commits

...

8 Commits

Author SHA1 Message Date
88990aa760 Switch go Gulp 4 for builds 2021-01-30 00:00:27 +03:00
446a513f7a Disable versioning for package-lock.json 2021-01-29 23:57:26 +03:00
8ca0285646 Fix invalid bitmask for release archives 2018-08-07 20:34:44 +03:00
26ce7982f2 Fix versions mismatch 2015-03-24 23:24:41 +03:00
Dmitriy Simushev
c2c9d475a2 Bump version 2015-03-18 12:17:56 +00:00
Dmitriy Simushev
fe3eda94c5 Add info about where to download the plugin 2015-03-18 12:16:01 +00:00
Dmitriy Simushev
46ea203894 Let the user know that he is banned 2015-03-18 12:14:22 +00:00
Dmitriy Simushev
e0e41200ea Do not hide banned clients when bans are disabled 2015-03-18 11:37:52 +00:00
5 changed files with 45 additions and 10 deletions

1
.gitignore vendored
View File

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

View File

@ -28,6 +28,8 @@ use Mibew\EventDispatcher\EventDispatcher;
use Mibew\EventDispatcher\Events;
use Mibew\Plugin\AbstractPlugin;
use Mibew\Plugin\PluginInterface;
use Mibew\Settings;
use Mibew\Thread;
/**
* The main plugin's file definition.
@ -52,9 +54,15 @@ class Plugin extends AbstractPlugin implements PluginInterface
*/
public function run()
{
if (!Settings::get('enableban')) {
// Bans are disabled. The plugin should do nothing in this case.
return;
}
$dispatcher = EventDispatcher::getInstance();
$dispatcher->attachListener(Events::USERS_UPDATE_THREADS_ALTER, $this, 'alterThreads');
$dispatcher->attachListener(Events::USERS_UPDATE_VISITORS_ALTER, $this, 'alterVisitors');
$dispatcher->attachListener(Events::THREAD_UPDATE, $this, 'handleThreadUpdate');
}
/**
@ -109,6 +117,34 @@ class Plugin extends AbstractPlugin implements PluginInterface
$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.
*
@ -116,6 +152,6 @@ class Plugin extends AbstractPlugin implements PluginInterface
*/
public static function getVersion()
{
return '1.0.0';
return '1.1.0';
}
}

View File

@ -5,7 +5,7 @@ It hides banned threads and visitors on the awaiting page.
## Installation
1. Get the archive with the plugin sources. At the moment the only option is to build the plugin from sources.
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.
2. Untar/unzip the plugin's archive.
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.

View File

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

View File

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