Skip to content

fix(LAR-66): Laravel notification pending articles #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 15, 2024
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
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
custom: https://laravel.cm/sponsors
github: mckenziearts

28 changes: 28 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: CI Setup
description: "Sets up the environment for jobs during CI workflow"

runs:
using: composite
steps:
- name: 🐘 Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, bcmath, soap, intl, gd, exif, iconv, imagick
tools: composer:v2
coverage: none
- name: ℹ Setup Problem Matches
shell: sh
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: 🗂 Get composer cache directory
id: composer-cache
shell: sh
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
29 changes: 0 additions & 29 deletions .github/workflows/coding-standards.yml

This file was deleted.

35 changes: 0 additions & 35 deletions .github/workflows/phpstan.yml

This file was deleted.

49 changes: 49 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Quality

on:
push:
branches:
- main
- develop
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
pint:
runs-on: ubuntu-22.04
steps:
- name: 👀 Checkout
uses: actions/checkout@v3
- name: 🪄 Setup
uses: ./.github/actions/setup
- name: 🔮 Install Composer Dependencies
run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader
- name: 🕵️‍♂️ Run Laravel Pint
run: composer lint -- --test

phpstan:
runs-on: ubuntu-22.04
steps:
- name: 👀 Checkout
uses: actions/checkout@v3
- name: 🪄 Setup
uses: ./.github/actions/setup
- name: 🔮 Install Composer Dependencies
run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader
- name: 🕵️‍♂️ Run PHPStan
run: composer test:phpstan -- --ansi --no-interaction --no-progress --error-format=github

composer:
runs-on: ubuntu-22.04
steps:
- name: 👀 Checkout
uses: actions/checkout@v3
- name: 🪄 Setup
uses: ./.github/actions/setup
- name: 🕵️‍♂️ Run Composer Validate
run: composer validate
- name: 🕵️‍♂️ Run Composer Audit
run: composer audit
41 changes: 23 additions & 18 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
name: Tests

on: [push, pull_request]
on:
push:
branches:
- main
- develop
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
runs-on: ubuntu-latest
pest:
runs-on: ubuntu-22.04

steps:
- name: Checkout code
- name: 👀 Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
tools: composer:v2
coverage: none

- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction

- name: Execute tests
run: composer pest
- name: 🪄 Setup
uses: ./.github/actions/setup
- name: 🔮 Install Composer Dependencies
run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader
- name: 🧶 Install Node Dependencies
run: yarn install --frozen-lockfile --no-progress
- name: 🧱 Build JS Dependencies
run: yarn build
- name: 🕵️‍♂️ Run Pest Tests
run: composer test:pest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ composer.phar

# Laravel Exclude
#
.phpunit.cache
.phpunit.result.cache
/public/build
/public/**/filament
Expand Down
9 changes: 0 additions & 9 deletions Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion app/Actions/Fortify/UpdateUserPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function update(User $user, array $input): void
'current_password' => ['required', 'string'],
'password' => $this->passwordRules(),
])->after(function ($validator) use ($user, $input): void {
if ( ! isset($input['current_password']) || ! Hash::check($input['current_password'], $user->password)) {
if (! isset($input['current_password']) || ! Hash::check($input['current_password'], $user->password)) {
$validator->errors()->add('current_password', __('Le mot de passe fourni ne correspond pas à votre mot de passe actuel.'));
}
})->validateWithBag('updatePassword');
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/Cleanup/DeleteOldUnverifiedUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function handle(): void

if ($users->isNotEmpty()) {
foreach ($users as $user) {
$user->notify((new SendEMailToDeletedUser())->delay(now()->addMinutes(5)));
$user->notify((new SendEMailToDeletedUser)->delay(now()->addMinutes(5)));
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/CreateAdminUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
namespace App\Console\Commands;

use App\Models\User;
use Exception;
use Illuminate\Console\Command;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Hash;
use Exception;

final class CreateAdminUser extends Command
{
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/NotifyPendingArticles.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
namespace App\Console\Commands;

use App\Models\Article;
use App\Notifications\PendingArticlesNotification;
use Illuminate\Console\Command;
use Illuminate\Notifications\AnonymousNotifiable;
use App\Notifications\PendingArticlesNotification;

final class NotifyPendingArticles extends Command
{
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected function schedule(Schedule $schedule): void
$schedule->command('lcm:post-article-to-telegram')->everyFourHours();
$schedule->command('lcm:send-unverified-mails')->weeklyOn(1, '8:00');
$schedule->command('sitemap:generate')->daily();
$schedule->command('lcm:notify-pending-articles')->days(2);
$schedule->command('lcm:notify-pending-articles')->cron('8 0 */2 * *');
}
}

Expand Down
4 changes: 1 addition & 3 deletions app/Events/ApiRegistered.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ final class ApiRegistered
{
use SerializesModels;

public function __construct(public User $user)
{
}
public function __construct(public User $user) {}
}
4 changes: 1 addition & 3 deletions app/Events/ArticleWasSubmittedForApproval.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ final class ArticleWasSubmittedForApproval
{
use SerializesModels;

public function __construct(public Article $article)
{
}
public function __construct(public Article $article) {}
}
4 changes: 1 addition & 3 deletions app/Events/CommentWasAdded.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,5 @@
{
use SerializesModels;

public function __construct(public Reply $reply, public Discussion $discussion)
{
}
public function __construct(public Reply $reply, public Discussion $discussion) {}
}
4 changes: 1 addition & 3 deletions app/Events/EmailAddressWasChanged.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@ final class EmailAddressWasChanged
use Dispatchable;
use SerializesModels;

public function __construct(public User $user)
{
}
public function __construct(public User $user) {}
}
4 changes: 1 addition & 3 deletions app/Events/ReplyWasCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ final class ReplyWasCreated
{
use SerializesModels;

public function __construct(public Reply $reply)
{
}
public function __construct(public Reply $reply) {}
}
4 changes: 1 addition & 3 deletions app/Events/SponsoringPaymentInitialize.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ final class SponsoringPaymentInitialize
{
use SerializesModels;

public function __construct(public Transaction $transaction)
{
}
public function __construct(public Transaction $transaction) {}
}
4 changes: 1 addition & 3 deletions app/Events/ThreadWasCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ final class ThreadWasCreated
{
use SerializesModels;

public function __construct(public Thread $thread)
{
}
public function __construct(public Thread $thread) {}
}
6 changes: 2 additions & 4 deletions app/Filters/AbstractFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ abstract class AbstractFilters

protected array $filters = [];

public function __construct(public Request $request)
{
}
public function __construct(public Request $request) {}

public function filter(Builder $builder): Builder
{
Expand All @@ -35,7 +33,7 @@ public function add(array $filters): self

public function resolverFilter(string $filter): mixed
{
return new $this->filters[$filter]();
return new $this->filters[$filter];
}

public function getFilters(): array
Expand Down
1 change: 0 additions & 1 deletion app/Filters/Thread/SortByFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public function mappings(): array

/**
* @param Builder<Thread> $builder
* @param mixed $value
* @return Builder<Thread>
*/
public function filter(Builder $builder, mixed $value): Builder
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Api/Auth/ForgotPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __invoke(ForgotPasswordRequest $request): JsonResponse
$request->only('email')
);

return Password::RESET_LINK_SENT === $status
return $status === Password::RESET_LINK_SENT
? response()->json(['message' => __('L\'e-mail de réinitialisation du mot de passe a été envoyé avec succès !')])
: response()->json(['error' => __('Un courriel ne pourrait être envoyé à cette adresse électronique !')], 401);
}
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Api/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public function login(LoginRequest $request): JsonResponse
'password' => $request->input('password'),
];

if ( ! $user || ! Auth::attempt($sanitized)) {
if (! $user || ! Auth::attempt($sanitized)) {
throw ValidationException::withMessages([
'email' => __('Les informations d\'identification fournies sont incorrectes.'),
]);
}

if ( ! $user->tokens()) {
if (! $user->tokens()) {
$user->tokens()->delete();
}

Expand Down
Loading
Loading