mirror of
https://github.com/flarum/framework.git
synced 2025-03-28 10:15:15 +08:00
Apply fixes from StyleCI
This commit is contained in:
parent
178f91aff9
commit
e5ba4f4320
@ -38,7 +38,7 @@ class Akismet
|
|||||||
|
|
||||||
public function isConfigured(): bool
|
public function isConfigured(): bool
|
||||||
{
|
{
|
||||||
return !empty($this->apiKey);
|
return ! empty($this->apiKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,6 +48,7 @@ class Akismet
|
|||||||
protected function sendRequest(string $type): ResponseInterface
|
protected function sendRequest(string $type): ResponseInterface
|
||||||
{
|
{
|
||||||
$client = new Client();
|
$client = new Client();
|
||||||
|
|
||||||
return $client->request('POST', "$this->apiUrl/$type", [
|
return $client->request('POST', "$this->apiUrl/$type", [
|
||||||
'headers' => [
|
'headers' => [
|
||||||
'User-Agent' => "Flarum/$this->flarumVersion | Akismet/$this->extensionVersion",
|
'User-Agent' => "Flarum/$this->flarumVersion | Akismet/$this->extensionVersion",
|
||||||
@ -147,7 +148,7 @@ class Akismet
|
|||||||
* contact-form: A contact form or feedback form submission.
|
* contact-form: A contact form or feedback form submission.
|
||||||
* signup: A new user account.
|
* signup: A new user account.
|
||||||
* message: A message sent between just a few users.
|
* message: A message sent between just a few users.
|
||||||
* You may send a value not listed above if none of them accurately describe your content. This is further explained here: https://blog.akismet.com/2012/06/19/pro-tip-tell-us-your-comment_type/
|
* You may send a value not listed above if none of them accurately describe your content. This is further explained here: https://blog.akismet.com/2012/06/19/pro-tip-tell-us-your-comment_type/.
|
||||||
*/
|
*/
|
||||||
public function withType(string $type): Akismet
|
public function withType(string $type): Akismet
|
||||||
{
|
{
|
||||||
@ -226,4 +227,3 @@ class Akismet
|
|||||||
return $this->withParam('recheck_reason', $reason);
|
return $this->withParam('recheck_reason', $reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class SubmitHam
|
|||||||
|
|
||||||
public function handle(PostWasApproved $event)
|
public function handle(PostWasApproved $event)
|
||||||
{
|
{
|
||||||
if (!$this->akismet->isConfigured()) {
|
if (! $this->akismet->isConfigured()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class SubmitSpam
|
|||||||
|
|
||||||
public function handle(Hidden $event)
|
public function handle(Hidden $event)
|
||||||
{
|
{
|
||||||
if (!$this->akismet->isConfigured()) {
|
if (! $this->akismet->isConfigured()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,14 +35,14 @@ class ValidatePost
|
|||||||
|
|
||||||
public function handle(Saving $event)
|
public function handle(Saving $event)
|
||||||
{
|
{
|
||||||
if (!$this->akismet->isConfigured()) {
|
if (! $this->akismet->isConfigured()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$post = $event->post;
|
$post = $event->post;
|
||||||
|
|
||||||
//TODO Sometimes someone posts spam when editing a post. In this case 'recheck_reason=edit' can be used when sending a request to Akismet
|
//TODO Sometimes someone posts spam when editing a post. In this case 'recheck_reason=edit' can be used when sending a request to Akismet
|
||||||
if ($post->exists || !($post instanceof CommentPost) || $post->user->hasPermission('bypassAkismet')) {
|
if ($post->exists || ! ($post instanceof CommentPost) || $post->user->hasPermission('bypassAkismet')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +55,6 @@ class ValidatePost
|
|||||||
->withUserAgent($_SERVER['HTTP_USER_AGENT'])
|
->withUserAgent($_SERVER['HTTP_USER_AGENT'])
|
||||||
->checkSpam();
|
->checkSpam();
|
||||||
|
|
||||||
|
|
||||||
if ($result['isSpam']) {
|
if ($result['isSpam']) {
|
||||||
$post->is_spam = true;
|
$post->is_spam = true;
|
||||||
|
|
||||||
|
@ -9,13 +9,13 @@
|
|||||||
|
|
||||||
namespace Flarum\Akismet\Provider;
|
namespace Flarum\Akismet\Provider;
|
||||||
|
|
||||||
|
use Flarum\Akismet\Akismet;
|
||||||
use Flarum\Extension\ExtensionManager;
|
use Flarum\Extension\ExtensionManager;
|
||||||
use Flarum\Foundation\AbstractServiceProvider;
|
use Flarum\Foundation\AbstractServiceProvider;
|
||||||
use Flarum\Foundation\Application;
|
use Flarum\Foundation\Application;
|
||||||
use Flarum\Foundation\Config;
|
use Flarum\Foundation\Config;
|
||||||
use Flarum\Http\UrlGenerator;
|
use Flarum\Http\UrlGenerator;
|
||||||
use Flarum\Settings\SettingsRepositoryInterface;
|
use Flarum\Settings\SettingsRepositoryInterface;
|
||||||
use Flarum\Akismet\Akismet;
|
|
||||||
use Illuminate\Container\Container;
|
use Illuminate\Container\Container;
|
||||||
|
|
||||||
class AkismetProvider extends AbstractServiceProvider
|
class AkismetProvider extends AbstractServiceProvider
|
||||||
|
Loading…
x
Reference in New Issue
Block a user