25 - Fix code style issues across codebase with Pint
This commit is contained in:
parent
0b2fc5004b
commit
56db303b15
50 changed files with 125 additions and 134 deletions
|
|
@ -15,7 +15,7 @@ public function execute(string $name, string $provider, int $languageId, ?string
|
|||
|
||||
$url = config("feed.providers.{$provider}.languages.{$langCode}.url");
|
||||
|
||||
if (!$url) {
|
||||
if (! $url) {
|
||||
throw new InvalidArgumentException("Invalid provider and language combination: {$provider}/{$langCode}");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public function __construct(
|
|||
*/
|
||||
public function execute(string $instanceDomain, string $username, string $password, string $platform = 'lemmy'): PlatformAccount
|
||||
{
|
||||
$fullInstanceUrl = 'https://' . $instanceDomain;
|
||||
$fullInstanceUrl = 'https://'.$instanceDomain;
|
||||
|
||||
// Authenticate first — if this fails, no records are created
|
||||
$authResponse = $this->lemmyAuthService->authenticate($fullInstanceUrl, $username, $password);
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ class FetchNewArticlesCommand extends Command
|
|||
|
||||
public function handle(): int
|
||||
{
|
||||
if (!Setting::isArticleProcessingEnabled()) {
|
||||
if (! Setting::isArticleProcessingEnabled()) {
|
||||
$this->info('Article processing is disabled. Article discovery skipped.');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
if (!Feed::where('is_active', true)->exists()) {
|
||||
if (! Feed::where('is_active', true)->exists()) {
|
||||
$this->info('No active feeds found. Article discovery skipped.');
|
||||
|
||||
return self::SUCCESS;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ public function canParse(string $url): bool;
|
|||
|
||||
/**
|
||||
* Extract article data from HTML
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function extractData(string $html): array;
|
||||
|
|
@ -19,4 +20,4 @@ public function extractData(string $html): array;
|
|||
* Get the source name for this parser
|
||||
*/
|
||||
public function getSourceName(): string;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ public function canParse(string $url): bool;
|
|||
|
||||
/**
|
||||
* Extract article URLs from homepage HTML
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function extractArticleUrls(string $html): array;
|
||||
|
|
@ -24,4 +25,4 @@ public function getHomepageUrl(): string;
|
|||
* Get the source name for this parser
|
||||
*/
|
||||
public function getSourceName(): string;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@
|
|||
enum PlatformEnum: string
|
||||
{
|
||||
case LEMMY = 'lemmy';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,5 @@ class ExceptionLogged
|
|||
|
||||
public function __construct(
|
||||
public Log $log
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,5 @@ public function __construct(
|
|||
public string $message,
|
||||
/** @var array<string, mixed> */
|
||||
public array $context = []
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,5 @@ class NewArticleFetched
|
|||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public function __construct(public Article $article)
|
||||
{
|
||||
}
|
||||
public function __construct(public Article $article) {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,4 @@
|
|||
|
||||
use Exception;
|
||||
|
||||
class ChannelException extends Exception
|
||||
{
|
||||
}
|
||||
class ChannelException extends Exception {}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class PublishException extends Exception
|
|||
{
|
||||
public function __construct(
|
||||
private readonly Article $article,
|
||||
private readonly PlatformEnum|null $platform,
|
||||
private readonly ?PlatformEnum $platform,
|
||||
?Throwable $previous = null
|
||||
) {
|
||||
$message = "Failed to publish article #$article->id";
|
||||
|
|
|
|||
|
|
@ -4,6 +4,4 @@
|
|||
|
||||
use Exception;
|
||||
|
||||
class RoutingException extends Exception
|
||||
{
|
||||
}
|
||||
class RoutingException extends Exception {}
|
||||
|
|
|
|||
|
|
@ -10,4 +10,4 @@ protected static function getFacadeAccessor()
|
|||
{
|
||||
return \App\Services\Log\LogSaver::class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,13 +3,12 @@
|
|||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Http\Resources\ArticleResource;
|
||||
use App\Jobs\ArticleDiscoveryJob;
|
||||
use App\Models\Article;
|
||||
use App\Models\Setting;
|
||||
use App\Jobs\ArticleDiscoveryJob;
|
||||
use Exception;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class ArticlesController extends BaseController
|
||||
{
|
||||
|
|
@ -54,7 +53,7 @@ public function approve(Article $article): JsonResponse
|
|||
'Article approved and queued for publishing.'
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
return $this->sendError('Failed to approve article: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Failed to approve article: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +70,7 @@ public function reject(Article $article): JsonResponse
|
|||
'Article rejected.'
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
return $this->sendError('Failed to reject article: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Failed to reject article: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -88,7 +87,7 @@ public function refresh(): JsonResponse
|
|||
'Article refresh started. New articles will appear shortly.'
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
return $this->sendError('Failed to start article refresh: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Failed to start article refresh: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
use App\Models\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
|
|
@ -24,7 +23,7 @@ public function login(Request $request): JsonResponse
|
|||
|
||||
$user = User::where('email', $request->email)->first();
|
||||
|
||||
if (!$user || !Hash::check($request->password, $user->password)) {
|
||||
if (! $user || ! Hash::check($request->password, $user->password)) {
|
||||
return $this->sendError('Invalid credentials', [], 401);
|
||||
}
|
||||
|
||||
|
|
@ -42,7 +41,7 @@ public function login(Request $request): JsonResponse
|
|||
} catch (ValidationException $e) {
|
||||
return $this->sendValidationError($e->errors());
|
||||
} catch (\Exception $e) {
|
||||
return $this->sendError('Login failed: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Login failed: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +77,7 @@ public function register(Request $request): JsonResponse
|
|||
} catch (ValidationException $e) {
|
||||
return $this->sendValidationError($e->errors());
|
||||
} catch (\Exception $e) {
|
||||
return $this->sendError('Registration failed: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Registration failed: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +91,7 @@ public function logout(Request $request): JsonResponse
|
|||
|
||||
return $this->sendResponse(null, 'Logged out successfully');
|
||||
} catch (\Exception $e) {
|
||||
return $this->sendError('Logout failed: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Logout failed: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -109,4 +108,4 @@ public function me(Request $request): JsonResponse
|
|||
],
|
||||
], 'User retrieved successfully');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
use Exception;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use InvalidArgumentException;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use InvalidArgumentException;
|
||||
|
||||
class FeedsController extends BaseController
|
||||
{
|
||||
|
|
@ -21,7 +21,7 @@ class FeedsController extends BaseController
|
|||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$perPage = min($request->get('per_page', 15), 100);
|
||||
|
||||
|
||||
$feeds = Feed::with(['language'])
|
||||
->withCount('articles')
|
||||
->orderBy('is_active', 'desc')
|
||||
|
|
@ -37,7 +37,7 @@ public function index(Request $request): JsonResponse
|
|||
'total' => $feeds->total(),
|
||||
'from' => $feeds->firstItem(),
|
||||
'to' => $feeds->lastItem(),
|
||||
]
|
||||
],
|
||||
], 'Feeds retrieved successfully.');
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ public function store(StoreFeedRequest $request, CreateFeedAction $createFeedAct
|
|||
} catch (InvalidArgumentException $e) {
|
||||
return $this->sendError($e->getMessage(), [], 422);
|
||||
} catch (Exception $e) {
|
||||
return $this->sendError('Failed to create feed: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Failed to create feed: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ public function update(UpdateFeedRequest $request, Feed $feed): JsonResponse
|
|||
} catch (ValidationException $e) {
|
||||
return $this->sendValidationError($e->errors());
|
||||
} catch (Exception $e) {
|
||||
return $this->sendError('Failed to update feed: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Failed to update feed: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ public function destroy(Feed $feed): JsonResponse
|
|||
'Feed deleted successfully!'
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
return $this->sendError('Failed to delete feed: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Failed to delete feed: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ public function destroy(Feed $feed): JsonResponse
|
|||
public function toggle(Feed $feed): JsonResponse
|
||||
{
|
||||
try {
|
||||
$newStatus = !$feed->is_active;
|
||||
$newStatus = ! $feed->is_active;
|
||||
$feed->update(['is_active' => $newStatus]);
|
||||
|
||||
$status = $newStatus ? 'activated' : 'deactivated';
|
||||
|
|
@ -134,7 +134,7 @@ public function toggle(Feed $feed): JsonResponse
|
|||
"Feed {$status} successfully!"
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
return $this->sendError('Failed to toggle feed status: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Failed to toggle feed status: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public function store(Request $request, Feed $feed, PlatformChannel $channel): J
|
|||
} catch (ValidationException $e) {
|
||||
return $this->sendValidationError($e->errors());
|
||||
} catch (\Exception $e) {
|
||||
return $this->sendError('Failed to create keyword: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Failed to create keyword: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ public function update(Request $request, Feed $feed, PlatformChannel $channel, K
|
|||
} catch (ValidationException $e) {
|
||||
return $this->sendValidationError($e->errors());
|
||||
} catch (\Exception $e) {
|
||||
return $this->sendError('Failed to update keyword: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Failed to update keyword: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ public function destroy(Feed $feed, PlatformChannel $channel, Keyword $keyword):
|
|||
'Keyword deleted successfully!'
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
return $this->sendError('Failed to delete keyword: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Failed to delete keyword: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -127,7 +127,7 @@ public function toggle(Feed $feed, PlatformChannel $channel, Keyword $keyword):
|
|||
return $this->sendNotFound('Keyword not found for this route.');
|
||||
}
|
||||
|
||||
$newStatus = !$keyword->is_active;
|
||||
$newStatus = ! $keyword->is_active;
|
||||
$keyword->update(['is_active' => $newStatus]);
|
||||
|
||||
$status = $newStatus ? 'activated' : 'deactivated';
|
||||
|
|
@ -137,7 +137,7 @@ public function toggle(Feed $feed, PlatformChannel $channel, Keyword $keyword):
|
|||
"Keyword {$status} successfully!"
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
return $this->sendError('Failed to toggle keyword status: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Failed to toggle keyword status: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public function index(Request $request): JsonResponse
|
|||
],
|
||||
], 'Logs retrieved successfully.');
|
||||
} catch (\Exception $e) {
|
||||
return $this->sendError('Failed to retrieve logs: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Failed to retrieve logs: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ public function store(StorePlatformAccountRequest $request, CreatePlatformAccoun
|
|||
if (str_contains($e->getMessage(), 'Rate limited by')) {
|
||||
return $this->sendError($e->getMessage(), [], 429);
|
||||
}
|
||||
|
||||
return $this->sendError('Invalid username or password. Please check your credentials and try again.', [], 422);
|
||||
} catch (Exception $e) {
|
||||
return $this->sendError('Unable to connect to the Lemmy instance. Please check the URL and try again.', [], 422);
|
||||
|
|
@ -97,7 +98,7 @@ public function update(Request $request, PlatformAccount $platformAccount): Json
|
|||
} catch (ValidationException $e) {
|
||||
return $this->sendValidationError($e->errors());
|
||||
} catch (Exception $e) {
|
||||
return $this->sendError('Failed to update platform account: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Failed to update platform account: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -114,7 +115,7 @@ public function destroy(PlatformAccount $platformAccount): JsonResponse
|
|||
'Platform account deleted successfully!'
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
return $this->sendError('Failed to delete platform account: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Failed to delete platform account: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -131,7 +132,7 @@ public function setActive(PlatformAccount $platformAccount): JsonResponse
|
|||
"Set {$platformAccount->username}@{$platformAccount->instance_url} as active for {$platformAccount->platform->value}!"
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
return $this->sendError('Failed to set platform account as active: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Failed to set platform account as active: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public function store(StoreRouteRequest $request, CreateRouteAction $createRoute
|
|||
201
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
return $this->sendError('Failed to create routing configuration: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Failed to create routing configuration: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -62,11 +62,11 @@ public function store(StoreRouteRequest $request, CreateRouteAction $createRoute
|
|||
public function show(Feed $feed, PlatformChannel $channel): JsonResponse
|
||||
{
|
||||
$route = $this->findRoute($feed, $channel);
|
||||
|
||||
if (!$route) {
|
||||
|
||||
if (! $route) {
|
||||
return $this->sendNotFound('Routing configuration not found.');
|
||||
}
|
||||
|
||||
|
||||
$route->load(['feed', 'platformChannel', 'keywords']);
|
||||
|
||||
return $this->sendResponse(
|
||||
|
|
@ -83,7 +83,7 @@ public function update(Request $request, Feed $feed, PlatformChannel $channel):
|
|||
try {
|
||||
$route = $this->findRoute($feed, $channel);
|
||||
|
||||
if (!$route) {
|
||||
if (! $route) {
|
||||
return $this->sendNotFound('Routing configuration not found.');
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ public function update(Request $request, Feed $feed, PlatformChannel $channel):
|
|||
} catch (ValidationException $e) {
|
||||
return $this->sendValidationError($e->errors());
|
||||
} catch (Exception $e) {
|
||||
return $this->sendError('Failed to update routing configuration: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Failed to update routing configuration: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ public function destroy(Feed $feed, PlatformChannel $channel): JsonResponse
|
|||
try {
|
||||
$route = $this->findRoute($feed, $channel);
|
||||
|
||||
if (!$route) {
|
||||
if (! $route) {
|
||||
return $this->sendNotFound('Routing configuration not found.');
|
||||
}
|
||||
|
||||
|
|
@ -128,7 +128,7 @@ public function destroy(Feed $feed, PlatformChannel $channel): JsonResponse
|
|||
'Routing configuration deleted successfully!'
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
return $this->sendError('Failed to delete routing configuration: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Failed to delete routing configuration: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -140,11 +140,11 @@ public function toggle(Feed $feed, PlatformChannel $channel): JsonResponse
|
|||
try {
|
||||
$route = $this->findRoute($feed, $channel);
|
||||
|
||||
if (!$route) {
|
||||
if (! $route) {
|
||||
return $this->sendNotFound('Routing configuration not found.');
|
||||
}
|
||||
|
||||
$newStatus = !$route->is_active;
|
||||
$newStatus = ! $route->is_active;
|
||||
Route::where('feed_id', $feed->id)
|
||||
->where('platform_channel_id', $channel->id)
|
||||
->update(['is_active' => $newStatus]);
|
||||
|
|
@ -156,7 +156,7 @@ public function toggle(Feed $feed, PlatformChannel $channel): JsonResponse
|
|||
"Routing configuration {$status} successfully!"
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
return $this->sendError('Failed to toggle routing configuration status: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Failed to toggle routing configuration status: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -169,4 +169,4 @@ private function findRoute(Feed $feed, PlatformChannel $channel): ?Route
|
|||
->where('platform_channel_id', $channel->id)
|
||||
->first();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public function index(): JsonResponse
|
|||
|
||||
return $this->sendResponse($settings, 'Settings retrieved successfully.');
|
||||
} catch (\Exception $e) {
|
||||
return $this->sendError('Failed to retrieve settings: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Failed to retrieve settings: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ public function update(Request $request): JsonResponse
|
|||
} catch (ValidationException $e) {
|
||||
return $this->sendValidationError($e->errors());
|
||||
} catch (\Exception $e) {
|
||||
return $this->sendError('Failed to update settings: ' . $e->getMessage(), [], 500);
|
||||
return $this->sendError('Failed to update settings: '.$e->getMessage(), [], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,4 +26,4 @@ public function handle(Request $request, Closure $next): Response
|
|||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,4 +39,4 @@ public function share(Request $request): array
|
|||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ public function __construct(
|
|||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if (!$this->onboardingService->needsOnboarding()) {
|
||||
if (! $this->onboardingService->needsOnboarding()) {
|
||||
return redirect()->route('dashboard');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public function rules(): array
|
|||
'provider' => "required|in:{$providers}",
|
||||
'language_id' => 'required|exists:languages,id',
|
||||
'description' => 'nullable|string',
|
||||
'is_active' => 'boolean'
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ public function rules(): array
|
|||
{
|
||||
return [
|
||||
'name' => 'required|string|max:255',
|
||||
'url' => 'required|url|unique:feeds,url,' . ($this->route('feed') instanceof Feed ? (string)$this->route('feed')->id : (string)$this->route('feed')),
|
||||
'url' => 'required|url|unique:feeds,url,'.($this->route('feed') instanceof Feed ? (string) $this->route('feed')->id : (string) $this->route('feed')),
|
||||
'type' => 'required|in:website,rss',
|
||||
'language_id' => 'required|exists:languages,id',
|
||||
'description' => 'nullable|string',
|
||||
'is_active' => 'boolean'
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public function handle(LogSaver $logSaver, ArticleFetcher $articleFetcher): void
|
|||
$logSaver->info('Starting feed article fetch', null, [
|
||||
'feed_id' => $this->feed->id,
|
||||
'feed_name' => $this->feed->name,
|
||||
'feed_url' => $this->feed->url
|
||||
'feed_url' => $this->feed->url,
|
||||
]);
|
||||
|
||||
$articles = $articleFetcher->getArticlesFromFeed($this->feed);
|
||||
|
|
@ -33,7 +33,7 @@ public function handle(LogSaver $logSaver, ArticleFetcher $articleFetcher): void
|
|||
$logSaver->info('Feed article fetch completed', null, [
|
||||
'feed_id' => $this->feed->id,
|
||||
'feed_name' => $this->feed->name,
|
||||
'articles_count' => $articles->count()
|
||||
'articles_count' => $articles->count(),
|
||||
]);
|
||||
|
||||
$this->feed->update(['last_fetched_at' => now()]);
|
||||
|
|
@ -42,7 +42,7 @@ public function handle(LogSaver $logSaver, ArticleFetcher $articleFetcher): void
|
|||
public static function dispatchForAllActiveFeeds(): void
|
||||
{
|
||||
$logSaver = app(LogSaver::class);
|
||||
|
||||
|
||||
Feed::where('is_active', true)
|
||||
->get()
|
||||
->each(function (Feed $feed, $index) use ($logSaver) {
|
||||
|
|
@ -56,7 +56,7 @@ public static function dispatchForAllActiveFeeds(): void
|
|||
$logSaver->info('Dispatched feed discovery job', null, [
|
||||
'feed_id' => $feed->id,
|
||||
'feed_name' => $feed->name,
|
||||
'delay_minutes' => $delayMinutes
|
||||
'delay_minutes' => $delayMinutes,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public function __construct()
|
|||
|
||||
public function handle(LogSaver $logSaver): void
|
||||
{
|
||||
if (!Setting::isArticleProcessingEnabled()) {
|
||||
if (! Setting::isArticleProcessingEnabled()) {
|
||||
$logSaver->info('Article processing is disabled. Article discovery skipped.');
|
||||
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
|
||||
class PublishNextArticleJob implements ShouldQueue, ShouldBeUnique
|
||||
class PublishNextArticleJob implements ShouldBeUnique, ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
|
|
@ -28,6 +28,7 @@ public function __construct()
|
|||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @throws PublishException
|
||||
*/
|
||||
public function handle(ArticleFetcher $articleFetcher, ArticlePublishingService $publishingService): void
|
||||
|
|
@ -56,7 +57,7 @@ public function handle(ArticleFetcher $articleFetcher, ArticlePublishingService
|
|||
'article_id' => $article->id,
|
||||
'title' => $article->title,
|
||||
'url' => $article->url,
|
||||
'created_at' => $article->created_at
|
||||
'created_at' => $article->created_at,
|
||||
]);
|
||||
|
||||
// Fetch article data
|
||||
|
|
@ -64,18 +65,18 @@ public function handle(ArticleFetcher $articleFetcher, ArticlePublishingService
|
|||
|
||||
try {
|
||||
$publishingService->publishToRoutedChannels($article, $extractedData);
|
||||
|
||||
|
||||
logger()->info('Successfully published article', [
|
||||
'article_id' => $article->id,
|
||||
'title' => $article->title
|
||||
'title' => $article->title,
|
||||
]);
|
||||
} catch (PublishException $e) {
|
||||
logger()->error('Failed to publish article', [
|
||||
'article_id' => $article->id,
|
||||
'error' => $e->getMessage()
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class SyncChannelPostsJob implements ShouldQueue, ShouldBeUnique
|
||||
class SyncChannelPostsJob implements ShouldBeUnique, ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ public function __construct(
|
|||
public static function dispatchForAllActiveChannels(): void
|
||||
{
|
||||
$logSaver = app(LogSaver::class);
|
||||
|
||||
|
||||
PlatformChannel::with(['platformInstance', 'platformAccounts'])
|
||||
->whereHas('platformInstance', fn ($query) => $query->where('platform', PlatformEnum::LEMMY))
|
||||
->whereHas('platformAccounts', fn ($query) => $query->where('platform_accounts.is_active', true))
|
||||
|
|
@ -78,7 +78,7 @@ private function syncLemmyChannelPosts(LogSaver $logSaver): void
|
|||
|
||||
} catch (Exception $e) {
|
||||
$logSaver->error('Failed to sync channel posts', $this->channel, [
|
||||
'error' => $e->getMessage()
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
throw $e;
|
||||
|
|
@ -97,13 +97,13 @@ private function getAuthToken(LemmyApiService $api, PlatformAccount $account): s
|
|||
return $cachedToken;
|
||||
}
|
||||
|
||||
if (!$account->username || !$account->password) {
|
||||
if (! $account->username || ! $account->password) {
|
||||
throw new PlatformAuthException(PlatformEnum::LEMMY, 'Missing credentials for account');
|
||||
}
|
||||
|
||||
$token = $api->login($account->username, $account->password);
|
||||
|
||||
if (!$token) {
|
||||
if (! $token) {
|
||||
throw new PlatformAuthException(PlatformEnum::LEMMY, 'Login failed for account');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@
|
|||
use App\Events\ExceptionLogged;
|
||||
use App\Events\ExceptionOccurred;
|
||||
use App\Models\Log;
|
||||
|
||||
class LogExceptionToDatabase
|
||||
{
|
||||
|
||||
public function handle(ExceptionOccurred $event): void
|
||||
{
|
||||
// Truncate the message to prevent database errors
|
||||
$message = strlen($event->message) > 255
|
||||
? substr($event->message, 0, 252) . '...'
|
||||
$message = strlen($event->message) > 255
|
||||
? substr($event->message, 0, 252).'...'
|
||||
: $event->message;
|
||||
|
||||
try {
|
||||
|
|
@ -24,15 +24,15 @@ public function handle(ExceptionOccurred $event): void
|
|||
'file' => $event->exception->getFile(),
|
||||
'line' => $event->exception->getLine(),
|
||||
'trace' => $event->exception->getTraceAsString(),
|
||||
...$event->context
|
||||
]
|
||||
...$event->context,
|
||||
],
|
||||
]);
|
||||
|
||||
ExceptionLogged::dispatch($log);
|
||||
} catch (\Exception $e) {
|
||||
// Prevent infinite recursion by not logging this exception
|
||||
// Optionally log to file or other non-database destination
|
||||
error_log("Failed to log exception to database: " . $e->getMessage());
|
||||
error_log('Failed to log exception to database: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ public function handle(NewArticleFetched $event): void
|
|||
'article_id' => $article->id,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,9 +14,7 @@
|
|||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register(): void
|
||||
{
|
||||
}
|
||||
public function register(): void {}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
|
|
|
|||
|
|
@ -74,4 +74,4 @@
|
|||
'max_articles_per_fetch' => 50,
|
||||
'article_retention_days' => 30,
|
||||
],
|
||||
];
|
||||
];
|
||||
|
|
|
|||
|
|
@ -61,4 +61,4 @@
|
|||
*/
|
||||
|
||||
'default' => 'en',
|
||||
];
|
||||
];
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\ArticlePublication;
|
||||
use App\Models\Article;
|
||||
use App\Models\ArticlePublication;
|
||||
use App\Models\PlatformChannel;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
|
|
@ -32,4 +32,4 @@ public function recentlyPublished(): static
|
|||
'published_at' => $this->faker->dateTimeBetween('-1 day', 'now'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,4 +78,4 @@ public function belga(): static
|
|||
'url' => 'https://www.belganewsagency.eu/',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,4 +48,4 @@ public function inactive(): static
|
|||
'is_active' => false,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,4 +37,4 @@ public function english(): static
|
|||
'native_name' => 'English',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public function definition(): array
|
|||
{
|
||||
return [
|
||||
'platform' => PlatformEnum::LEMMY,
|
||||
'instance_url' => 'https://lemmy.' . $this->faker->domainName(),
|
||||
'instance_url' => 'https://lemmy.'.$this->faker->domainName(),
|
||||
'username' => $this->faker->userName(),
|
||||
'password' => 'test-password',
|
||||
'settings' => [],
|
||||
|
|
@ -49,4 +49,4 @@ public function failed(): static
|
|||
'status' => 'failed',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,14 +34,14 @@ public function inactive(): static
|
|||
]);
|
||||
}
|
||||
|
||||
public function community(string $name = null): static
|
||||
public function community(?string $name = null): static
|
||||
{
|
||||
$communityName = $name ?: $this->faker->word();
|
||||
|
||||
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'channel_id' => strtolower($communityName),
|
||||
'name' => $communityName,
|
||||
'display_name' => ucfirst($communityName),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ public function lemmy(): static
|
|||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'platform' => 'lemmy',
|
||||
'name' => 'Lemmy ' . $this->faker->word(),
|
||||
'url' => 'https://lemmy.' . $this->faker->domainName(),
|
||||
'name' => 'Lemmy '.$this->faker->word(),
|
||||
'url' => 'https://lemmy.'.$this->faker->domainName(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Route;
|
||||
use App\Models\Feed;
|
||||
use App\Models\PlatformChannel;
|
||||
use App\Models\Route;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class RouteFactory extends Factory
|
||||
|
|
@ -36,4 +36,4 @@ public function inactive(): static
|
|||
'is_active' => false,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,4 +32,4 @@ public function withValue(string $value): static
|
|||
'value' => $value,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,4 +23,4 @@ public function down(): void
|
|||
{
|
||||
Schema::dropIfExists('languages');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -60,4 +60,4 @@ public function down(): void
|
|||
Schema::dropIfExists('routes');
|
||||
Schema::dropIfExists('feeds');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -21,4 +21,4 @@ public function run(): void
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,14 +17,13 @@ public function run(): void
|
|||
'name' => 'Belgae Social',
|
||||
'description' => 'A Belgian Lemmy instance on the fediverse',
|
||||
],
|
||||
])->each (fn ($instanceData) =>
|
||||
PlatformInstance::updateOrCreate(
|
||||
[
|
||||
'platform' => $instanceData['platform'],
|
||||
'url' => $instanceData['url'],
|
||||
],
|
||||
$instanceData
|
||||
)
|
||||
])->each(fn ($instanceData) => PlatformInstance::updateOrCreate(
|
||||
[
|
||||
'platform' => $instanceData['platform'],
|
||||
'url' => $instanceData['url'],
|
||||
],
|
||||
$instanceData
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class SettingsSeeder extends Seeder
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@
|
|||
use App\Http\Controllers\Api\V1\AuthController;
|
||||
use App\Http\Controllers\Api\V1\DashboardController;
|
||||
use App\Http\Controllers\Api\V1\FeedsController;
|
||||
use App\Http\Controllers\Api\V1\KeywordsController;
|
||||
use App\Http\Controllers\Api\V1\LogsController;
|
||||
use App\Http\Controllers\Api\V1\OnboardingController;
|
||||
use App\Http\Controllers\Api\V1\PlatformAccountsController;
|
||||
use App\Http\Controllers\Api\V1\PlatformChannelsController;
|
||||
use App\Http\Controllers\Api\V1\RoutingController;
|
||||
use App\Http\Controllers\Api\V1\KeywordsController;
|
||||
use App\Http\Controllers\Api\V1\SettingsController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue