Skip to content

Commit

Permalink
Merge branch 'main' into shift-80567
Browse files Browse the repository at this point in the history
  • Loading branch information
joedixon committed Sep 5, 2023
2 parents cb9b786 + a096716 commit 935b754
Show file tree
Hide file tree
Showing 63 changed files with 2,090 additions and 1,664 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Coding Standards

on: [push]

permissions:
contents: write

jobs:
lint:
uses: laravel/.github/.github/workflows/coding-standards.yml@main
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ jobs:
run: vendor/bin/pest

- name: Deploy
if: github.ref_name == 'main'
if: github.repository == 'laravelio/laravel.io' && github.ref_name == 'main'
run: curl ${{ secrets.ENVOYER_HOOK }}?sha=${{ github.sha }}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ This is the repository for the [Laravel.io](http://laravel.io) community portal.

We'd like to thank these **amazing companies** for sponsoring us. If you are interested in becoming a sponsor, please visit <a href="https://github.com/sponsors/laravelio">the Laravel.io Github Sponsors page</a>.

- **[LaraJobs](https://larajobs.com)**
- **[JetBrains](https://www.jetbrains.com/phpstorm/laravel/?utm_source=github.com&utm_medium=cpc&utm_campaign=phpstorm&utm_content=laravel.io)**
- **[LoadForge](https://loadforge.com/)**
- [Forge](https://forge.laravel.com)
- [Envoyer](https://envoyer.io)
- [Fathom](https://usefathom.com)
- [Tinkerwell](https://tinkerwell.app)
- [Akaunting](https://akaunting.com/developers?utm_source=Laravelio&utm_medium=Banner&utm_campaign=Developers)
- [Scout APM](https://ter.li/o1adaj)
- [Skynet Technologies](https://www.skynettechnologies.com/hire-laravel-developer)
- [Lightflows](https://www.lightflows.co.uk/laravel-development-agency/)
- [Backpack for Laravel](https://backpackforlaravel.com/?ref=laravelio)
- [Localazy](https://localazy.com/laravel?utm_source=laravel.io&utm_medium=sponsorships&utm_campaign=brand_awareness&utm_content=logo)
- [Steadfast Collective](https://steadfastcollective.com/uk-laravel-agency)

## Requirements

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected function schedule(Schedule $schedule): void
$schedule->command('schedule-monitor:sync')->dailyAt('04:56');
$schedule->command('model:prune', ['--model' => MonitoredScheduledTaskLogItem::class])->daily();
$schedule->command('horizon:snapshot')->everyFiveMinutes();
$schedule->command('lio:post-article-to-twitter')->twiceDaily(14, 18);
//$schedule->command('lio:post-article-to-twitter')->twiceDaily(14, 18);
$schedule->command('lio:generate-sitemap')->daily()->graceTimeInMinutes(25);
$schedule->command('lio:update-article-view-counts')->twiceDaily();
}
Expand Down
4 changes: 2 additions & 2 deletions app/Exceptions/CannotCreateUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ final class CannotCreateUser extends Exception
{
public static function duplicateEmailAddress(string $emailAddress): self
{
return new static("The email address [$emailAddress] already exists.");
return new self("The email address [$emailAddress] already exists.");
}

public static function duplicateUsername(string $username): self
{
return new static("The username [$username] already exists.");
return new self("The username [$username] already exists.");
}
}
7 changes: 6 additions & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Session\TokenMismatchException;
use Illuminate\Validation\ValidationException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Throwable;

class Handler extends ExceptionHandler
{
Expand Down Expand Up @@ -42,6 +43,10 @@ class Handler extends ExceptionHandler
*/
public function register(): void
{
//
$this->reportable(function (Throwable $e) {
if (app()->bound('sentry')) {
app('sentry')->captureException($e);
}
});
}
}
3 changes: 2 additions & 1 deletion app/Http/Requests/CreateReplyRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
use App\Models\Thread;
use App\Models\User;
use App\Rules\HttpImageRule;
use App\Rules\InvalidMentionRule;

class CreateReplyRequest extends Request
{
public function rules(): array
{
return [
'body' => ['required', new HttpImageRule()],
'body' => ['required', new HttpImageRule(), new InvalidMentionRule()],
'replyable_id' => 'required',
'replyable_type' => 'required|in:'.Thread::TABLE,
];
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Requests/ThreadRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

use App\Rules\DoesNotContainUrlRule;
use App\Rules\HttpImageRule;
use App\Rules\InvalidMentionRule;

class ThreadRequest extends Request
{
public function rules(): array
{
return [
'subject' => ['required', 'max:60', new DoesNotContainUrlRule()],
'body' => ['required', new HttpImageRule()],
'body' => ['required', new HttpImageRule(), new InvalidMentionRule()],
'tags' => 'array',
'tags.*' => 'exists:tags,id',
];
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Requests/UpdateReplyRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
namespace App\Http\Requests;

use App\Rules\HttpImageRule;
use App\Rules\InvalidMentionRule;

class UpdateReplyRequest extends Request
{
public function rules(): array
{
return [
'body' => ['required', new HttpImageRule()],
'body' => ['required', new HttpImageRule(), new InvalidMentionRule()],
];
}

Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/CreateArticle.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(

public static function fromRequest(ArticleRequest $request, UuidInterface $uuid): self
{
return new static(
return new self(
$uuid,
$request->title(),
$request->body(),
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/CreateReply.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(

public static function fromRequest(CreateReplyRequest $request, UuidInterface $uuid): self
{
return new static(
return new self(
$uuid,
$request->body(),
$request->author(),
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/CreateThread.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(

public static function fromRequest(ThreadRequest $request, UuidInterface $uuid): self
{
return new static(
return new self(
$uuid,
$request->subject(),
$request->body(),
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/UpdateArticle.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(

public static function fromRequest(Article $article, ArticleRequest $request): self
{
return new static(
return new self(
$article,
$request->title(),
$request->body(),
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/UpdateProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(

public static function fromRequest(User $user, UpdateProfileRequest $request): self
{
return new static($user, [
return new self($user, [
'name' => $request->name(),
'email' => $request->email(),
'username' => strtolower($request->username()),
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/UpdateThread.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct(private Thread $thread, private User $updatedBy, arr

public static function fromRequest(Thread $thread, ThreadRequest $request): self
{
return new static($thread, $request->user(), [
return new self($thread, $request->user(), [
'subject' => $request->subject(),
'body' => $request->body(),
'slug' => $request->subject(),
Expand Down
2 changes: 1 addition & 1 deletion app/Listeners/NotifyUsersMentionedInReply.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class NotifyUsersMentionedInReply
public function handle(ReplyWasCreated $event): void
{
$event->reply->mentionedUsers()->each(function ($user) use ($event) {
if (! $user->hasBlocked($event->reply->author())) {
if (! $user->hasBlocked($event->reply->author()) && ! $event->reply->replyAble()->participants()->contains($user)) {
$user->notify(new MentionNotification($event->reply));
}
});
Expand Down
6 changes: 3 additions & 3 deletions app/Models/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@

final class Article extends Model implements Feedable
{
use HasFactory;
use HasAuthor;
use HasSlug;
use HasFactory;
use HasLikes;
use HasTimestamps;
use HasSlug;
use HasTags;
use HasTimestamps;
use HasUuid;
use PreparesSearch;
use Searchable;
Expand Down
5 changes: 0 additions & 5 deletions app/Models/Reply.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,6 @@ public function spamReportersRelation(): MorphToMany
)->withTimestamps();
}

public function thread(): BelongsTo
{
return $this->belongsTo(Thread::class);
}

public function scopeIsSolution(Builder $builder): Builder
{
return $builder->has('solutionTo');
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
use Spatie\Feed\Feedable;
use Spatie\Feed\FeedItem;

final class Thread extends Model implements Feedable, ReplyAble, SubscriptionAble, MentionAble, Spam
final class Thread extends Model implements Feedable, MentionAble, ReplyAble, Spam, SubscriptionAble
{
use HasAuthor;
use HasFactory;
Expand Down
6 changes: 3 additions & 3 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,17 +236,17 @@ public function countArticles(): int

public static function findByUsername(string $username): self
{
return static::where('username', $username)->firstOrFail();
return self::where('username', $username)->firstOrFail();
}

public static function findByEmailAddress(string $emailAddress): self
{
return static::where('email', $emailAddress)->firstOrFail();
return self::where('email', $emailAddress)->firstOrFail();
}

public static function findByGithubId(string $githubId): self
{
return static::where('github_id', $githubId)->firstOrFail();
return self::where('github_id', $githubId)->firstOrFail();
}

public function delete()
Expand Down
2 changes: 1 addition & 1 deletion app/Notifications/SlowQueryLogged.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SlowQueryLogged extends Notification implements ShouldQueue
{
use Queueable;

public function __construct(private string $query, private float|null $duration, private string $url)
public function __construct(private string $query, private ?float $duration, private string $url)
{
}

Expand Down
21 changes: 21 additions & 0 deletions app/Rules/InvalidMentionRule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Rules;

use Illuminate\Contracts\Validation\Rule;

/**
* This rule validates links are not diguised as mentions.
*/
final class InvalidMentionRule implements Rule
{
public function passes($attribute, $value): bool
{
return ! preg_match('/\[@.*\]\(http.*\)/', $value);
}

public function message(): string
{
return 'The :attribute field contains an invalid mention.';
}
}
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"ohdearapp/ohdear-php-sdk": "^3.4",
"predis/predis": "^2.0",
"ramsey/uuid": "^4.3",
"sentry/sentry-laravel": "^3.4",
"spatie/laravel-feed": "^4.2",
"spatie/laravel-ignition": "^2.0",
"spatie/laravel-robots-middleware": "^1.3",
Expand Down Expand Up @@ -98,7 +99,8 @@
"optimize-autoloader": true,
"allow-plugins": {
"composer/package-versions-deprecated": true,
"pestphp/pest-plugin": true
"pestphp/pest-plugin": true,
"php-http/discovery": true
}
},
"minimum-stability": "stable",
Expand Down
Loading

0 comments on commit 935b754

Please sign in to comment.