Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@

class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
];

/**
* Define the application's command schedule.
*/
Expand Down
1 change: 1 addition & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Handler extends ExceptionHandler
* @var array
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Kernel extends HttpKernel
*/
protected $middleware = [
// \App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
\Illuminate\Http\Middleware\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Middleware/TrimStrings.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ class TrimStrings extends Middleware
/**
* The names of the attributes that should not be trimmed.
*
* @var array
* @var array<int, string>
*/
protected $except = [
'current_password',
'password',
'password_confirmation',
];
Expand Down
13 changes: 9 additions & 4 deletions app/Http/Middleware/TrustProxies.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,27 @@

namespace App\Http\Middleware;

use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;

class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array
* @var array<int, string>|string|null
*/
protected $proxies;

/**
* The headers that should be used to detect proxies.
*
* @var string
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
protected $headers =
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO |
Request::HEADER_X_FORWARDED_AWS_ELB;
}
6 changes: 3 additions & 3 deletions app/Markdown/LeagueConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace App\Markdown;

use League\CommonMark\CommonMarkConverter;
use League\CommonMark\MarkdownConverter;

final class LeagueConverter implements Converter
{
public function __construct(
private CommonMarkConverter $converter
private MarkdownConverter $converter
) {
}

public function toHtml(string $markdown): string
{
return $this->converter->convertToHtml($markdown);
return $this->converter->convert($markdown)->getContent();
}
}
19 changes: 10 additions & 9 deletions app/Markdown/MarkdownServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@
namespace App\Markdown;

use Illuminate\Support\ServiceProvider;
use League\CommonMark\CommonMarkConverter;
use League\CommonMark\Environment;
use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
use League\CommonMark\Extension\Mention\MentionExtension;
use League\CommonMark\MarkdownConverter;

class MarkdownServiceProvider extends ServiceProvider
{
public function register()
{
$this->app->bind(Converter::class, function () {
$environment = Environment::createCommonMarkEnvironment();

$environment->addExtension(new MentionExtension);

$environment->mergeConfig([
$this->app->singleton(Converter::class, function () {
$environment = new Environment([
'html_input' => 'escape',
'mentions' => [
'username' => [
'prefix' => '@',
Expand All @@ -26,7 +24,10 @@ public function register()
],
]);

return new LeagueConverter(new CommonMarkConverter(['html_input' => 'escape'], $environment));
$environment->addExtension(new CommonMarkCoreExtension);
$environment->addExtension(new MentionExtension);

return new LeagueConverter(new MarkdownConverter($environment));
});
}
}
14 changes: 7 additions & 7 deletions app/Models/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class Article extends Model
const TABLE = 'articles';

/**
* {@inheritdoc}
* @inheritdoc
*/
protected $fillable = [
'title',
Expand All @@ -46,16 +46,16 @@ final class Article extends Model
];

/**
* {@inheritdoc}
* @inheritdoc
*/
protected $dates = [
'submitted_at',
'approved_at',
'shared_at',
protected $casts = [
'submitted_at' => 'datetime',
'approved_at' => 'datetime',
'shared_at' => 'datetime',
];

/**
* {@inheritdoc}
* @inheritdoc
*/
protected $with = [
'authorRelation',
Expand Down
6 changes: 3 additions & 3 deletions app/Models/Reply.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ final class Reply extends Model implements MentionAble
const TABLE = 'replies';

/**
* {@inheritdoc}
* @inheritdoc
*/
protected $table = self::TABLE;

/**
* {@inheritdoc}
* @inheritdoc
*/
protected $fillable = [
'body',
];

/**
* {@inheritdoc}
* @inheritdoc
*/
protected $with = [
'likesRelation',
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Series.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Series extends Model
use HasSlug;

/**
* {@inheritdoc}
* @inheritdoc
*/
protected $fillable = [
'title',
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class Subscription extends Model
use HasUuid;

/**
* {@inheritdoc}
* @inheritdoc
*/
protected $table = 'subscriptions';

Expand Down
4 changes: 2 additions & 2 deletions app/Models/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ final class Tag extends Model
use HasSlug;

/**
* {@inheritdoc}
* @inheritdoc
*/
protected $table = 'tags';

/**
* {@inheritdoc}
* @inheritdoc
*/
public $timestamps = false;

Expand Down
8 changes: 4 additions & 4 deletions app/Models/Thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ final class Thread extends Model implements Feedable, ReplyAble, SubscriptionAbl
const FEED_PAGE_SIZE = 20;

/**
* {@inheritdoc}
* @inheritdoc
*/
protected $table = self::TABLE;

/**
* {@inheritdoc}
* @inheritdoc
*/
protected $fillable = [
'body',
Expand All @@ -62,7 +62,7 @@ final class Thread extends Model implements Feedable, ReplyAble, SubscriptionAbl
];

/**
* {@inheritdoc}
* @inheritdoc
*/
protected $with = [
'authorRelation',
Expand All @@ -73,7 +73,7 @@ final class Thread extends Model implements Feedable, ReplyAble, SubscriptionAbl
];

/**
* {@inheritdoc}
* @inheritdoc
*/
protected $casts = [
'last_activity_at' => 'datetime',
Expand Down
8 changes: 5 additions & 3 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ final class User extends Authenticatable implements MustVerifyEmail
const TABLE = 'users';

const DEFAULT = 1;

const MODERATOR = 2;

const ADMIN = 3;

/**
* {@inheritdoc}
* @inheritdoc
*/
protected $table = 'users';

/**
* {@inheritdoc}
* @inheritdoc
*/
protected $fillable = [
'name',
Expand All @@ -48,7 +50,7 @@ final class User extends Authenticatable implements MustVerifyEmail
];

/**
* {@inheritdoc}
* @inheritdoc
*/
protected $hidden = ['password', 'remember_token'];

Expand Down
5 changes: 5 additions & 0 deletions app/Policies/ArticlePolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@
final class ArticlePolicy
{
const UPDATE = 'update';

const DELETE = 'delete';

const APPROVE = 'approve';

const DISAPPROVE = 'disapprove';

const DECLINE = 'decline';

const PINNED = 'togglePinnedStatus';

public function update(User $user, Article $article): bool
Expand Down
2 changes: 2 additions & 0 deletions app/Policies/ReplyPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
final class ReplyPolicy
{
const CREATE = 'create';

const UPDATE = 'update';

const DELETE = 'delete';

/**
Expand Down
4 changes: 4 additions & 0 deletions app/Policies/ThreadPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
final class ThreadPolicy
{
const UPDATE = 'update';

const DELETE = 'delete';

const SUBSCRIBE = 'subscribe';

const UNSUBSCRIBE = 'unsubscribe';

const LOCK = 'lock';

public function update(User $user, Thread $thread): bool
Expand Down
2 changes: 2 additions & 0 deletions app/Policies/UserPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
final class UserPolicy
{
const ADMIN = 'admin';

const BAN = 'ban';

const DELETE = 'delete';

public function admin(User $user): bool
Expand Down
10 changes: 10 additions & 0 deletions app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,14 @@ class EventServiceProvider extends ServiceProvider
StoreTweetIdentifier::class,
],
];

/**
* Determine if events and listeners should be automatically discovered.
*
* @return bool
*/
public function shouldDiscoverEvents()
{
return false;
}
}
2 changes: 0 additions & 2 deletions app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ public function boot()
$this->routes(function () {
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));

Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
});
}
Expand Down
Loading