mirror of
https://github.com/flarum/core.git
synced 2025-08-16 21:34:08 +02:00
merged master
This commit is contained in:
@@ -119,22 +119,20 @@ class Application extends Container implements ApplicationContract
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isInstalled()
|
||||
public function isInstalled(): bool
|
||||
{
|
||||
return $this->bound('flarum.config');
|
||||
}
|
||||
|
||||
public function isUpToDate()
|
||||
public function isUpToDate(): bool
|
||||
{
|
||||
$settings = $this->make(SettingsRepositoryInterface::class);
|
||||
|
||||
try {
|
||||
$version = $settings->get('version');
|
||||
} finally {
|
||||
$isUpToDate = isset($version) && $version === $this->version();
|
||||
return isset($version) && $version === $this->version();
|
||||
}
|
||||
|
||||
return $isUpToDate;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -118,7 +118,7 @@ class Server
|
||||
// (Right now it tries to resolve a database connection because of the injected settings repo instance)
|
||||
// We could register a different settings repo when Flarum is not installed
|
||||
//$pipe->pipe($this->app->make(HandleErrors::class, ['debug' => true]));
|
||||
$pipe->pipe($this->app->make(StartSession::class));
|
||||
//$pipe->pipe($this->app->make(StartSession::class));
|
||||
$pipe->pipe($this->app->make(DispatchRoute::class, ['routes' => $this->app->make('flarum.install.routes')]));
|
||||
|
||||
return $pipe;
|
||||
|
@@ -288,10 +288,10 @@ class InstallCommand extends AbstractCommand
|
||||
Group::unguard();
|
||||
|
||||
$groups = [
|
||||
[Group::ADMINISTRATOR_ID, 'Admin', 'Admins', '#B72A2A', 'fa fa-wrench'],
|
||||
[Group::ADMINISTRATOR_ID, 'Admin', 'Admins', '#B72A2A', 'fas fa-wrench'],
|
||||
[Group::GUEST_ID, 'Guest', 'Guests', null, null],
|
||||
[Group::MEMBER_ID, 'Member', 'Members', null, null],
|
||||
[Group::MODERATOR_ID, 'Mod', 'Mods', '#80349E', 'fa fa-bolt']
|
||||
[Group::MODERATOR_ID, 'Mod', 'Mods', '#80349E', 'fas fa-bolt']
|
||||
];
|
||||
|
||||
foreach ($groups as $group) {
|
||||
|
30
src/Post/Event/CheckingForFlooding.php
Normal file
30
src/Post/Event/CheckingForFlooding.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Post\Event;
|
||||
|
||||
use Flarum\User\User;
|
||||
|
||||
class CheckingForFlooding
|
||||
{
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
public $actor;
|
||||
|
||||
/**
|
||||
* @param User|null $actor
|
||||
*/
|
||||
public function __construct(User $actor = null)
|
||||
{
|
||||
$this->actor = $actor;
|
||||
}
|
||||
}
|
@@ -12,14 +12,26 @@
|
||||
namespace Flarum\Post;
|
||||
|
||||
use DateTime;
|
||||
use Flarum\Post\Event\CheckingForFlooding;
|
||||
use Flarum\Post\Exception\FloodingException;
|
||||
use Flarum\User\User;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class Floodgate
|
||||
{
|
||||
/**
|
||||
* @var Dispatcher
|
||||
*/
|
||||
protected $events;
|
||||
|
||||
public function __construct(Dispatcher $events)
|
||||
{
|
||||
$this->events = $events;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $actor
|
||||
* @throws \Flarum\Post\Exception\FloodingException
|
||||
* @throws FloodingException
|
||||
*/
|
||||
public function assertNotFlooding(User $actor)
|
||||
{
|
||||
@@ -32,8 +44,12 @@ class Floodgate
|
||||
* @param User $actor
|
||||
* @return bool
|
||||
*/
|
||||
public function isFlooding(User $actor)
|
||||
public function isFlooding(User $actor): bool
|
||||
{
|
||||
return Post::where('user_id', $actor->id)->where('time', '>=', new DateTime('-10 seconds'))->exists();
|
||||
$isFlooding = $this->events->until(
|
||||
new CheckingForFlooding($actor)
|
||||
);
|
||||
|
||||
return $isFlooding ?? Post::where('user_id', $actor->id)->where('time', '>=', new DateTime('-10 seconds'))->exists();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user