commit
fcf0b4a778
163 changed files with 2959 additions and 3146 deletions
|
@ -5,17 +5,23 @@ root = true
|
|||
|
||||
# Unix-style newlines with a newline ending every file
|
||||
[*]
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
# Tab indentation
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
tab_width = 4
|
||||
|
||||
[yml]
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[docker-compose.yml]
|
||||
indent_size = 4
|
||||
|
|
|
@ -25,22 +25,10 @@ class MigratePlaceDataFromPostgis extends Command
|
|||
*/
|
||||
protected $description = 'Copy Postgis data to normal latitude longitude fields';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): int
|
||||
{
|
||||
$locationColumn = DB::selectOne(DB::raw("
|
||||
SELECT EXISTS (
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace App\Console\Commands;
|
|||
|
||||
use App\Models\WebMention;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||
use Illuminate\FileSystem\FileSystem;
|
||||
|
||||
class ParseCachedWebMentions extends Command
|
||||
|
@ -27,9 +28,9 @@ class ParseCachedWebMentions extends Command
|
|||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public function handle(FileSystem $filesystem)
|
||||
public function handle(FileSystem $filesystem): void
|
||||
{
|
||||
$htmlFiles = $filesystem->allFiles(storage_path() . '/HTML');
|
||||
foreach ($htmlFiles as $file) {
|
||||
|
@ -49,9 +50,6 @@ class ParseCachedWebMentions extends Command
|
|||
|
||||
/**
|
||||
* Determine the source URL from a filename.
|
||||
*
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
private function urlFromFilename(string $filepath): string
|
||||
{
|
||||
|
|
|
@ -24,22 +24,10 @@ class ReDownloadWebMentions extends Command
|
|||
*/
|
||||
protected $description = 'Redownload the HTML content of webmentions';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): void
|
||||
{
|
||||
$webmentions = WebMention::all();
|
||||
foreach ($webmentions as $webmention) {
|
||||
|
|
|
@ -10,7 +10,7 @@ class Kernel extends ConsoleKernel
|
|||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $commands = [
|
||||
Commands\ParseCachedWebMentions::class,
|
||||
|
@ -20,22 +20,18 @@ class Kernel extends ConsoleKernel
|
|||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
protected function schedule(Schedule $schedule): void
|
||||
{
|
||||
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
||||
$schedule->command('cache:prune-stale-tags')->hourly();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
protected function commands(): void
|
||||
{
|
||||
$this->load(__DIR__ . '/Commands');
|
||||
|
||||
|
|
|
@ -21,47 +21,34 @@ class Handler extends ExceptionHandler
|
|||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, class-string<\Throwable>>
|
||||
*/
|
||||
protected $dontReport = [
|
||||
NotFoundHttpException::class,
|
||||
ModelNotFoundException::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed for validation exceptions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||
*
|
||||
* @param Throwable $throwable
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function report(Throwable $throwable)
|
||||
public function report(Throwable $e): void
|
||||
{
|
||||
parent::report($throwable);
|
||||
parent::report($e);
|
||||
|
||||
if (config('logging.slack') && $this->shouldReport($throwable)) {
|
||||
if (config('logging.slack') && $this->shouldReport($e)) {
|
||||
$guzzle = new Client([
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
],
|
||||
]);
|
||||
|
||||
$exceptionName = get_class($throwable) ?? 'Unknown Exception';
|
||||
$title = $exceptionName . ': ' . $throwable->getMessage();
|
||||
$exceptionName = get_class($e) ?? 'Unknown Exception';
|
||||
$title = $exceptionName . ': ' . $e->getMessage();
|
||||
|
||||
$guzzle->post(
|
||||
config('logging.slack'),
|
||||
|
@ -89,7 +76,6 @@ class Handler extends ExceptionHandler
|
|||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Throwable $throwable
|
||||
* @return Response
|
||||
*
|
||||
* @throws Throwable
|
||||
|
|
|
@ -14,8 +14,6 @@ class ClientsController extends Controller
|
|||
{
|
||||
/**
|
||||
* Show a list of known clients.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
|
@ -26,8 +24,6 @@ class ClientsController extends Controller
|
|||
|
||||
/**
|
||||
* Show form to add a client name.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
|
@ -36,8 +32,6 @@ class ClientsController extends Controller
|
|||
|
||||
/**
|
||||
* Process the request to adda new client name.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(): RedirectResponse
|
||||
{
|
||||
|
@ -51,9 +45,6 @@ class ClientsController extends Controller
|
|||
|
||||
/**
|
||||
* Show a form to edit a client name.
|
||||
*
|
||||
* @param int $clientId
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function edit(int $clientId): View
|
||||
{
|
||||
|
@ -68,9 +59,6 @@ class ClientsController extends Controller
|
|||
|
||||
/**
|
||||
* Process the request to edit a client name.
|
||||
*
|
||||
* @param int $clientId
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(int $clientId): RedirectResponse
|
||||
{
|
||||
|
@ -84,9 +72,6 @@ class ClientsController extends Controller
|
|||
|
||||
/**
|
||||
* Process a request to delete a client.
|
||||
*
|
||||
* @param int $clientId
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(int $clientId): RedirectResponse
|
||||
{
|
||||
|
|
|
@ -17,8 +17,6 @@ class ContactsController extends Controller
|
|||
{
|
||||
/**
|
||||
* List the currect contacts that can be edited.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
|
@ -29,8 +27,6 @@ class ContactsController extends Controller
|
|||
|
||||
/**
|
||||
* Display the form to add a new contact.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
|
@ -39,8 +35,6 @@ class ContactsController extends Controller
|
|||
|
||||
/**
|
||||
* Process the request to add a new contact.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(): RedirectResponse
|
||||
{
|
||||
|
@ -57,9 +51,6 @@ class ContactsController extends Controller
|
|||
|
||||
/**
|
||||
* Show the form to edit an existing contact.
|
||||
*
|
||||
* @param int $contactId
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function edit(int $contactId): View
|
||||
{
|
||||
|
@ -72,9 +63,6 @@ class ContactsController extends Controller
|
|||
* Process the request to edit a contact.
|
||||
*
|
||||
* @todo Allow saving profile pictures for people without homepages
|
||||
*
|
||||
* @param int $contactId
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(int $contactId): RedirectResponse
|
||||
{
|
||||
|
@ -101,9 +89,6 @@ class ContactsController extends Controller
|
|||
|
||||
/**
|
||||
* Process the request to delete a contact.
|
||||
*
|
||||
* @param int $contactId
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(int $contactId): RedirectResponse
|
||||
{
|
||||
|
@ -119,7 +104,6 @@ class ContactsController extends Controller
|
|||
* This method attempts to find the microformat marked-up profile image
|
||||
* from a given homepage and save it accordingly
|
||||
*
|
||||
* @param int $contactId
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
||||
*/
|
||||
public function getAvatar(int $contactId)
|
||||
|
|
|
@ -11,8 +11,6 @@ class HomeController extends Controller
|
|||
{
|
||||
/**
|
||||
* Show the homepage of the admin CP.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function welcome(): View
|
||||
{
|
||||
|
|
|
@ -14,8 +14,6 @@ class LikesController extends Controller
|
|||
{
|
||||
/**
|
||||
* List the likes that can be edited.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
|
@ -26,8 +24,6 @@ class LikesController extends Controller
|
|||
|
||||
/**
|
||||
* Show the form to make a new like.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
|
@ -36,8 +32,6 @@ class LikesController extends Controller
|
|||
|
||||
/**
|
||||
* Process a request to make a new like.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(): RedirectResponse
|
||||
{
|
||||
|
@ -51,9 +45,6 @@ class LikesController extends Controller
|
|||
|
||||
/**
|
||||
* Display the form to edit a specific like.
|
||||
*
|
||||
* @param int $likeId
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function edit(int $likeId): View
|
||||
{
|
||||
|
@ -67,9 +58,6 @@ class LikesController extends Controller
|
|||
|
||||
/**
|
||||
* Process a request to edit a like.
|
||||
*
|
||||
* @param int $likeId
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(int $likeId): RedirectResponse
|
||||
{
|
||||
|
@ -83,9 +71,6 @@ class LikesController extends Controller
|
|||
|
||||
/**
|
||||
* Process the request to delete a like.
|
||||
*
|
||||
* @param int $likeId
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(int $likeId): RedirectResponse
|
||||
{
|
||||
|
|
|
@ -15,8 +15,6 @@ class NotesController extends Controller
|
|||
{
|
||||
/**
|
||||
* List the notes that can be edited.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
|
@ -30,8 +28,6 @@ class NotesController extends Controller
|
|||
|
||||
/**
|
||||
* Show the form to make a new note.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
|
@ -40,9 +36,6 @@ class NotesController extends Controller
|
|||
|
||||
/**
|
||||
* Process a request to make a new note.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
|
@ -56,9 +49,6 @@ class NotesController extends Controller
|
|||
|
||||
/**
|
||||
* Display the form to edit a specific note.
|
||||
*
|
||||
* @param int $noteId
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function edit(int $noteId): View
|
||||
{
|
||||
|
@ -71,9 +61,6 @@ class NotesController extends Controller
|
|||
/**
|
||||
* Process a request to edit a note. Easy since this can only be done
|
||||
* from the admin CP.
|
||||
*
|
||||
* @param int $noteId
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(int $noteId): RedirectResponse
|
||||
{
|
||||
|
@ -92,9 +79,6 @@ class NotesController extends Controller
|
|||
|
||||
/**
|
||||
* Delete the note.
|
||||
*
|
||||
* @param int $noteId
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(int $noteId): RedirectResponse
|
||||
{
|
||||
|
|
|
@ -21,8 +21,6 @@ class PlacesController extends Controller
|
|||
|
||||
/**
|
||||
* List the places that can be edited.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
|
@ -33,8 +31,6 @@ class PlacesController extends Controller
|
|||
|
||||
/**
|
||||
* Show the form to make a new place.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
|
@ -43,8 +39,6 @@ class PlacesController extends Controller
|
|||
|
||||
/**
|
||||
* Process a request to make a new place.
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function store(): RedirectResponse
|
||||
{
|
||||
|
@ -62,9 +56,6 @@ class PlacesController extends Controller
|
|||
|
||||
/**
|
||||
* Display the form to edit a specific place.
|
||||
*
|
||||
* @param int $placeId
|
||||
* @return View
|
||||
*/
|
||||
public function edit(int $placeId): View
|
||||
{
|
||||
|
@ -75,9 +66,6 @@ class PlacesController extends Controller
|
|||
|
||||
/**
|
||||
* Process a request to edit a place.
|
||||
*
|
||||
* @param int $placeId
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function update(int $placeId): RedirectResponse
|
||||
{
|
||||
|
@ -94,9 +82,6 @@ class PlacesController extends Controller
|
|||
|
||||
/**
|
||||
* List the places we can merge with the current place.
|
||||
*
|
||||
* @param int $placeId
|
||||
* @return View
|
||||
*/
|
||||
public function mergeIndex(int $placeId): View
|
||||
{
|
||||
|
@ -114,10 +99,6 @@ class PlacesController extends Controller
|
|||
|
||||
/**
|
||||
* Show a form for merging two specific places.
|
||||
*
|
||||
* @param int $placeId1
|
||||
* @param int $placeId2
|
||||
* @return View
|
||||
*/
|
||||
public function mergeEdit(int $placeId1, int $placeId2): View
|
||||
{
|
||||
|
@ -129,8 +110,6 @@ class PlacesController extends Controller
|
|||
|
||||
/**
|
||||
* Process the request to merge two places.
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function mergeStore(): RedirectResponse
|
||||
{
|
||||
|
|
|
@ -14,8 +14,6 @@ class SyndicationTargetsController extends Controller
|
|||
{
|
||||
/**
|
||||
* Show a list of known syndication targets.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
|
@ -26,8 +24,6 @@ class SyndicationTargetsController extends Controller
|
|||
|
||||
/**
|
||||
* Show form to add a syndication target.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
|
@ -36,9 +32,6 @@ class SyndicationTargetsController extends Controller
|
|||
|
||||
/**
|
||||
* Process the request to adda new syndication target.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
|
@ -60,9 +53,6 @@ class SyndicationTargetsController extends Controller
|
|||
|
||||
/**
|
||||
* Show a form to edit a syndication target.
|
||||
*
|
||||
* @param SyndicationTarget $syndicationTarget
|
||||
* @return View
|
||||
*/
|
||||
public function edit(SyndicationTarget $syndicationTarget): View
|
||||
{
|
||||
|
@ -73,10 +63,6 @@ class SyndicationTargetsController extends Controller
|
|||
|
||||
/**
|
||||
* Process the request to edit a client name.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param SyndicationTarget $syndicationTarget
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function update(Request $request, SyndicationTarget $syndicationTarget): RedirectResponse
|
||||
{
|
||||
|
@ -98,9 +84,6 @@ class SyndicationTargetsController extends Controller
|
|||
|
||||
/**
|
||||
* Process a request to delete a client.
|
||||
*
|
||||
* @param SyndicationTarget $syndicationTarget
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function destroy(SyndicationTarget $syndicationTarget): RedirectResponse
|
||||
{
|
||||
|
|
|
@ -14,10 +14,6 @@ class ArticlesController extends Controller
|
|||
{
|
||||
/**
|
||||
* Show all articles (with pagination).
|
||||
*
|
||||
* @param int|null $year
|
||||
* @param int|null $month
|
||||
* @return View
|
||||
*/
|
||||
public function index(int $year = null, int $month = null): View
|
||||
{
|
||||
|
@ -31,13 +27,8 @@ class ArticlesController extends Controller
|
|||
|
||||
/**
|
||||
* Show a single article.
|
||||
*
|
||||
* @param int $year
|
||||
* @param int $month
|
||||
* @param string $slug
|
||||
* @return RedirectResponse|View
|
||||
*/
|
||||
public function show(int $year, int $month, string $slug)
|
||||
public function show(int $year, int $month, string $slug): RedirectResponse|View
|
||||
{
|
||||
try {
|
||||
$article = Article::where('titleurl', $slug)->firstOrFail();
|
||||
|
@ -56,11 +47,7 @@ class ArticlesController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* We only have the ID, work out post title, year and month
|
||||
* and redirect to it.
|
||||
*
|
||||
* @param string $idFromUrl
|
||||
* @return RedirectResponse
|
||||
* We only have the ID, work out post title, year and month and redirect to it.
|
||||
*/
|
||||
public function onlyIdInUrl(string $idFromUrl): RedirectResponse
|
||||
{
|
||||
|
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\View\View;
|
||||
|
||||
|
@ -12,10 +13,8 @@ class AuthController extends Controller
|
|||
{
|
||||
/**
|
||||
* Show the login form.
|
||||
*
|
||||
* @return View|RedirectResponse
|
||||
*/
|
||||
public function showLogin()
|
||||
public function showLogin(): View|RedirectResponse
|
||||
{
|
||||
if (Auth::check()) {
|
||||
return redirect('/');
|
||||
|
@ -25,14 +24,11 @@ class AuthController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Log in a user, set a session variable, check credentials against
|
||||
* the .env file.
|
||||
*
|
||||
* @return RedirectResponse
|
||||
* Log in a user, set a session variable, check credentials against the `.env` file.
|
||||
*/
|
||||
public function login(): RedirectResponse
|
||||
public function login(Request $request): RedirectResponse
|
||||
{
|
||||
$credentials = request()->only('name', 'password');
|
||||
$credentials = $request->only('name', 'password');
|
||||
|
||||
if (Auth::attempt($credentials, true)) {
|
||||
return redirect()->intended('/');
|
||||
|
@ -42,11 +38,9 @@ class AuthController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Show the form to logout a user.
|
||||
*
|
||||
* @return View|RedirectResponse
|
||||
* Show the form to allow a user to log-out.
|
||||
*/
|
||||
public function showLogout()
|
||||
public function showLogout(): View|RedirectResponse
|
||||
{
|
||||
if (Auth::check() === false) {
|
||||
// The user is not logged in, just redirect them home
|
||||
|
@ -58,8 +52,6 @@ class AuthController extends Controller
|
|||
|
||||
/**
|
||||
* Log the user out from their current session.
|
||||
*
|
||||
* @return RedirectResponse;
|
||||
*/
|
||||
public function logout(): RedirectResponse
|
||||
{
|
||||
|
|
|
@ -11,8 +11,6 @@ class BookmarksController extends Controller
|
|||
{
|
||||
/**
|
||||
* Show the most recent bookmarks.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
|
@ -23,9 +21,6 @@ class BookmarksController extends Controller
|
|||
|
||||
/**
|
||||
* Show a single bookmark.
|
||||
*
|
||||
* @param Bookmark $bookmark
|
||||
* @return View
|
||||
*/
|
||||
public function show(Bookmark $bookmark): View
|
||||
{
|
||||
|
@ -36,9 +31,6 @@ class BookmarksController extends Controller
|
|||
|
||||
/**
|
||||
* Show bookmarks tagged with a specific tag.
|
||||
*
|
||||
* @param string $tag
|
||||
* @return View
|
||||
*/
|
||||
public function tagged(string $tag): View
|
||||
{
|
||||
|
|
|
@ -12,8 +12,6 @@ class ContactsController extends Controller
|
|||
{
|
||||
/**
|
||||
* Show all the contacts.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
|
@ -33,9 +31,6 @@ class ContactsController extends Controller
|
|||
|
||||
/**
|
||||
* Show a single contact.
|
||||
*
|
||||
* @param Contact $contact
|
||||
* @return View
|
||||
*/
|
||||
public function show(Contact $contact): View
|
||||
{
|
||||
|
|
|
@ -13,8 +13,6 @@ class FeedsController extends Controller
|
|||
{
|
||||
/**
|
||||
* Returns the blog RSS feed.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function blogRss(): Response
|
||||
{
|
||||
|
@ -28,8 +26,6 @@ class FeedsController extends Controller
|
|||
|
||||
/**
|
||||
* Returns the blog Atom feed.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function blogAtom(): Response
|
||||
{
|
||||
|
@ -42,8 +38,6 @@ class FeedsController extends Controller
|
|||
|
||||
/**
|
||||
* Returns the notes RSS feed.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function notesRss(): Response
|
||||
{
|
||||
|
@ -57,8 +51,6 @@ class FeedsController extends Controller
|
|||
|
||||
/**
|
||||
* Returns the notes Atom feed.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function notesAtom(): Response
|
||||
{
|
||||
|
@ -73,8 +65,6 @@ class FeedsController extends Controller
|
|||
|
||||
/**
|
||||
* Returns the blog JSON feed.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function blogJson(): array
|
||||
{
|
||||
|
@ -106,10 +96,8 @@ class FeedsController extends Controller
|
|||
|
||||
/**
|
||||
* Returns the notes JSON feed.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function notesJson()
|
||||
public function notesJson(): array
|
||||
{
|
||||
$notes = Note::latest()->with('media')->take(20)->get();
|
||||
$data = [
|
||||
|
@ -138,8 +126,6 @@ class FeedsController extends Controller
|
|||
|
||||
/**
|
||||
* Returns the blog JF2 feed.
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function blogJf2(): JsonResponse
|
||||
{
|
||||
|
@ -176,8 +162,6 @@ class FeedsController extends Controller
|
|||
|
||||
/**
|
||||
* Returns the notes JF2 feed.
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function notesJf2(): JsonResponse
|
||||
{
|
||||
|
|
|
@ -7,6 +7,7 @@ use App\Models\Bookmark;
|
|||
use App\Models\Like;
|
||||
use App\Models\Note;
|
||||
use App\Services\ActivityStreamsService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\View\View;
|
||||
|
||||
|
@ -14,12 +15,10 @@ class FrontPageController extends Controller
|
|||
{
|
||||
/**
|
||||
* Show all the recent activity.
|
||||
*
|
||||
* @return Response|View
|
||||
*/
|
||||
public function index()
|
||||
public function index(Request $request): Response|View
|
||||
{
|
||||
if (request()->wantsActivityStream()) {
|
||||
if ($request->wantsActivityStream()) {
|
||||
return (new ActivityStreamsService())->siteOwnerResponse();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,6 @@ class LikesController extends Controller
|
|||
{
|
||||
/**
|
||||
* Show the latest likes.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
|
@ -23,9 +21,6 @@ class LikesController extends Controller
|
|||
|
||||
/**
|
||||
* Show a single like.
|
||||
*
|
||||
* @param Like $like
|
||||
* @return View
|
||||
*/
|
||||
public function show(Like $like): View
|
||||
{
|
||||
|
|
|
@ -44,9 +44,6 @@ class MicropubController extends Controller
|
|||
/**
|
||||
* This function receives an API request, verifies the authenticity
|
||||
* then passes over the info to the relevant Service class.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function post(Request $request): JsonResponse
|
||||
{
|
||||
|
@ -117,37 +114,35 @@ class MicropubController extends Controller
|
|||
* token, here we check whether the token is valid and respond
|
||||
* appropriately. Further if the request has the query parameter
|
||||
* syndicate-to we respond with the known syndication endpoints.
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function get(): JsonResponse
|
||||
public function get(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$tokenData = $this->tokenService->validateToken(request()->input('access_token'));
|
||||
$tokenData = $this->tokenService->validateToken($request->input('access_token'));
|
||||
} catch (RequiredConstraintsViolated|InvalidTokenStructure) {
|
||||
return (new MicropubResponses())->invalidTokenResponse();
|
||||
}
|
||||
|
||||
if (request()->input('q') === 'syndicate-to') {
|
||||
if ($request->input('q') === 'syndicate-to') {
|
||||
return response()->json([
|
||||
'syndicate-to' => SyndicationTarget::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
if (request()->input('q') === 'config') {
|
||||
if ($request->input('q') === 'config') {
|
||||
return response()->json([
|
||||
'syndicate-to' => SyndicationTarget::all(),
|
||||
'media-endpoint' => route('media-endpoint'),
|
||||
]);
|
||||
}
|
||||
|
||||
if (request()->has('q') && substr(request()->input('q'), 0, 4) === 'geo:') {
|
||||
if ($request->has('q') && str_starts_with($request->input('q'), 'geo:')) {
|
||||
preg_match_all(
|
||||
'/([0-9.\-]+)/',
|
||||
request()->input('q'),
|
||||
$request->input('q'),
|
||||
$matches
|
||||
);
|
||||
$distance = (count($matches[0]) == 3) ? 100 * $matches[0][2] : 1000;
|
||||
$distance = (count($matches[0]) === 3) ? 100 * $matches[0][2] : 1000;
|
||||
$places = Place::near(
|
||||
(object) ['latitude' => $matches[0][0], 'longitude' => $matches[0][1]],
|
||||
$distance
|
||||
|
@ -173,23 +168,19 @@ class MicropubController extends Controller
|
|||
/**
|
||||
* Determine the client id from the access token sent with the request.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws RequiredConstraintsViolated
|
||||
*/
|
||||
private function getClientId(): string
|
||||
{
|
||||
return resolve(TokenService::class)
|
||||
->validateToken(request()->input('access_token'))
|
||||
->validateToken(app('request')->input('access_token'))
|
||||
->claims()->get('client_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the details of the micropub request to a log file.
|
||||
*
|
||||
* @param array $request This is the info from request()->all()
|
||||
*/
|
||||
private function logMicropubRequest(array $request)
|
||||
private function logMicropubRequest(array $request): void
|
||||
{
|
||||
$logger = new Logger('micropub');
|
||||
$logger->pushHandler(new StreamHandler(storage_path('logs/micropub.log')));
|
||||
|
|
|
@ -98,15 +98,13 @@ class MicropubMediaController extends Controller
|
|||
/**
|
||||
* Process a media item posted to the media endpoint.
|
||||
*
|
||||
* @return JsonResponse
|
||||
*
|
||||
* @throws BindingResolutionException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function media(): JsonResponse
|
||||
public function media(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$tokenData = $this->tokenService->validateToken(request()->input('access_token'));
|
||||
$tokenData = $this->tokenService->validateToken($request->input('access_token'));
|
||||
} catch (RequiredConstraintsViolated|InvalidTokenStructure $exception) {
|
||||
$micropubResponses = new MicropubResponses();
|
||||
|
||||
|
@ -125,7 +123,7 @@ class MicropubMediaController extends Controller
|
|||
return $micropubResponses->insufficientScopeResponse();
|
||||
}
|
||||
|
||||
if (request()->hasFile('file') === false) {
|
||||
if ($request->hasFile('file') === false) {
|
||||
return response()->json([
|
||||
'response' => 'error',
|
||||
'error' => 'invalid_request',
|
||||
|
@ -133,7 +131,7 @@ class MicropubMediaController extends Controller
|
|||
], 400);
|
||||
}
|
||||
|
||||
if (request()->file('file')->isValid() === false) {
|
||||
if ($request->file('file')->isValid() === false) {
|
||||
return response()->json([
|
||||
'response' => 'error',
|
||||
'error' => 'invalid_request',
|
||||
|
@ -141,11 +139,11 @@ class MicropubMediaController extends Controller
|
|||
], 400);
|
||||
}
|
||||
|
||||
$filename = $this->saveFile(request()->file('file'));
|
||||
$filename = $this->saveFile($request->file('file'));
|
||||
|
||||
$manager = resolve(ImageManager::class);
|
||||
try {
|
||||
$image = $manager->make(request()->file('file'));
|
||||
$image = $manager->make($request->file('file'));
|
||||
$width = $image->width();
|
||||
} catch (NotReadableException $exception) {
|
||||
// not an image
|
||||
|
@ -153,9 +151,9 @@ class MicropubMediaController extends Controller
|
|||
}
|
||||
|
||||
$media = Media::create([
|
||||
'token' => request()->bearerToken(),
|
||||
'token' => $request->bearerToken(),
|
||||
'path' => 'media/' . $filename,
|
||||
'type' => $this->getFileTypeFromMimeType(request()->file('file')->getMimeType()),
|
||||
'type' => $this->getFileTypeFromMimeType($request->file('file')->getMimeType()),
|
||||
'image_widths' => $width,
|
||||
]);
|
||||
|
||||
|
@ -176,8 +174,6 @@ class MicropubMediaController extends Controller
|
|||
|
||||
/**
|
||||
* Return the relevant CORS headers to a pre-flight OPTIONS request.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function mediaOptionsResponse(): Response
|
||||
{
|
||||
|
@ -186,9 +182,6 @@ class MicropubMediaController extends Controller
|
|||
|
||||
/**
|
||||
* Get the file type from the mime-type of the uploaded file.
|
||||
*
|
||||
* @param string $mimeType
|
||||
* @return string
|
||||
*/
|
||||
private function getFileTypeFromMimeType(string $mimeType): string
|
||||
{
|
||||
|
@ -232,9 +225,6 @@ class MicropubMediaController extends Controller
|
|||
/**
|
||||
* Save an uploaded file to the local disk.
|
||||
*
|
||||
* @param UploadedFile $file
|
||||
* @return string
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function saveFile(UploadedFile $file): string
|
||||
|
|
|
@ -9,6 +9,7 @@ use App\Services\ActivityStreamsService;
|
|||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\View\View;
|
||||
use Jonnybarnes\IndieWeb\Numbers;
|
||||
|
@ -19,12 +20,10 @@ class NotesController extends Controller
|
|||
{
|
||||
/**
|
||||
* Show all the notes. This is also the homepage.
|
||||
*
|
||||
* @return View|Response
|
||||
*/
|
||||
public function index()
|
||||
public function index(Request $request): View|Response
|
||||
{
|
||||
if (request()->wantsActivityStream()) {
|
||||
if ($request->wantsActivityStream()) {
|
||||
return (new ActivityStreamsService())->siteOwnerResponse();
|
||||
}
|
||||
|
||||
|
@ -39,11 +38,8 @@ class NotesController extends Controller
|
|||
|
||||
/**
|
||||
* Show a single note.
|
||||
*
|
||||
* @param string $urlId The id of the note
|
||||
* @return View|JsonResponse|Response
|
||||
*/
|
||||
public function show(string $urlId)
|
||||
public function show(string $urlId): View|JsonResponse|Response
|
||||
{
|
||||
try {
|
||||
$note = Note::nb60($urlId)->with('webmentions')->firstOrFail();
|
||||
|
@ -60,9 +56,6 @@ class NotesController extends Controller
|
|||
|
||||
/**
|
||||
* Redirect /note/{decID} to /notes/{nb60id}.
|
||||
*
|
||||
* @param int $decId The decimal id of the note
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function redirect(int $decId): RedirectResponse
|
||||
{
|
||||
|
@ -71,9 +64,6 @@ class NotesController extends Controller
|
|||
|
||||
/**
|
||||
* Show all notes tagged with {tag}.
|
||||
*
|
||||
* @param string $tag
|
||||
* @return View
|
||||
*/
|
||||
public function tagged(string $tag): View
|
||||
{
|
||||
|
@ -88,8 +78,6 @@ class NotesController extends Controller
|
|||
* Page to create a new note.
|
||||
*
|
||||
* Dummy page for now.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
|
|
|
@ -11,8 +11,6 @@ class PlacesController extends Controller
|
|||
{
|
||||
/**
|
||||
* Show all the places.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
|
@ -23,9 +21,6 @@ class PlacesController extends Controller
|
|||
|
||||
/**
|
||||
* Show a specific place.
|
||||
*
|
||||
* @param Place $place
|
||||
* @return View
|
||||
*/
|
||||
public function show(Place $place): View
|
||||
{
|
||||
|
|
|
@ -19,8 +19,6 @@ class ShortURLsController extends Controller
|
|||
|
||||
/**
|
||||
* Redirect from '/' to the long url.
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function baseURL(): RedirectResponse
|
||||
{
|
||||
|
@ -29,8 +27,6 @@ class ShortURLsController extends Controller
|
|||
|
||||
/**
|
||||
* Redirect from '/@' to a twitter profile.
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function twitter(): RedirectResponse
|
||||
{
|
||||
|
@ -39,18 +35,15 @@ class ShortURLsController extends Controller
|
|||
|
||||
/**
|
||||
* Redirect a short url of this site out to a long one based on post type.
|
||||
* Further redirects may happen.
|
||||
*
|
||||
* @param string Post type
|
||||
* @param string Post ID
|
||||
* @return RedirectResponse
|
||||
* Further redirects may happen.
|
||||
*/
|
||||
public function expandType(string $type, string $postId): RedirectResponse
|
||||
{
|
||||
if ($type == 't') {
|
||||
if ($type === 't') {
|
||||
$type = 'notes';
|
||||
}
|
||||
if ($type == 'b') {
|
||||
if ($type === 'b') {
|
||||
$type = 'blog/s';
|
||||
}
|
||||
|
||||
|
|
|
@ -24,17 +24,10 @@ class TokenEndpointController extends Controller
|
|||
*/
|
||||
protected GuzzleClient $guzzle;
|
||||
|
||||
/**
|
||||
* @var TokenService The Token handling service.
|
||||
*/
|
||||
protected TokenService $tokenService;
|
||||
|
||||
/**
|
||||
* Inject the dependencies.
|
||||
*
|
||||
* @param Client $client
|
||||
* @param GuzzleClient $guzzle
|
||||
* @param TokenService $tokenService
|
||||
*/
|
||||
public function __construct(
|
||||
Client $client,
|
||||
|
@ -48,9 +41,6 @@ class TokenEndpointController extends Controller
|
|||
|
||||
/**
|
||||
* If the user has auth’d via the IndieAuth protocol, issue a valid token.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function create(Request $request): JsonResponse
|
||||
{
|
||||
|
|
|
@ -7,6 +7,7 @@ namespace App\Http\Controllers;
|
|||
use App\Jobs\ProcessWebMention;
|
||||
use App\Models\Note;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\View\View;
|
||||
use Jonnybarnes\IndieWeb\Numbers;
|
||||
|
@ -18,8 +19,6 @@ class WebMentionsController extends Controller
|
|||
*
|
||||
* This is probably someone looking for information about what
|
||||
* webmentions are, or about my particular implementation.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function get(): View
|
||||
{
|
||||
|
@ -28,13 +27,11 @@ class WebMentionsController extends Controller
|
|||
|
||||
/**
|
||||
* Receive and process a webmention.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function receive(): Response
|
||||
public function receive(Request $request): Response
|
||||
{
|
||||
//first we trivially reject requests that lack all required inputs
|
||||
if ((request()->has('target') !== true) || (request()->has('source') !== true)) {
|
||||
if (($request->has('target') !== true) || ($request->has('source') !== true)) {
|
||||
return response(
|
||||
'You need both the target and source parameters',
|
||||
400
|
||||
|
@ -42,15 +39,15 @@ class WebMentionsController extends Controller
|
|||
}
|
||||
|
||||
//next check the $target is valid
|
||||
$path = parse_url(request()->input('target'), PHP_URL_PATH);
|
||||
$path = parse_url($request->input('target'), PHP_URL_PATH);
|
||||
$pathParts = explode('/', $path);
|
||||
|
||||
if ($pathParts[1] == 'notes') {
|
||||
if ($pathParts[1] === 'notes') {
|
||||
//we have a note
|
||||
$noteId = $pathParts[2];
|
||||
try {
|
||||
$note = Note::findOrFail(resolve(Numbers::class)->b60tonum($noteId));
|
||||
dispatch(new ProcessWebMention($note, request()->input('source')));
|
||||
dispatch(new ProcessWebMention($note, $request->input('source')));
|
||||
} catch (ModelNotFoundException $e) {
|
||||
return response('This note doesn’t exist.', 400);
|
||||
}
|
||||
|
@ -60,7 +57,7 @@ class WebMentionsController extends Controller
|
|||
202
|
||||
);
|
||||
}
|
||||
if ($pathParts[1] == 'blog') {
|
||||
if ($pathParts[1] === 'blog') {
|
||||
return response(
|
||||
'I don’t accept webmentions for blog posts yet.',
|
||||
501
|
||||
|
|
|
@ -11,7 +11,7 @@ class Kernel extends HttpKernel
|
|||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, class-string|string>
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
|
@ -26,7 +26,7 @@ class Kernel extends HttpKernel
|
|||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array
|
||||
* @var array<string, array<int, class-string|string>>
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
|
@ -44,21 +44,23 @@ class Kernel extends HttpKernel
|
|||
],
|
||||
|
||||
'api' => [
|
||||
'throttle:api',
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
* The application's middleware aliases.
|
||||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
* Aliases may be used to conveniently assign middleware to routes and groups.
|
||||
*
|
||||
* @var array
|
||||
* @var array<string, class-string|string>
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
protected $middlewareAliases = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
|
|
|
@ -6,17 +6,14 @@ namespace App\Http\Middleware;
|
|||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class ActivityStreamLinks
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$response = $next($request);
|
||||
if ($request->path() === '/') {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
|
@ -11,14 +12,9 @@ class Authenticate extends Middleware
|
|||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return string
|
||||
*/
|
||||
protected function redirectTo($request)
|
||||
protected function redirectTo(Request $request): ?string
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
return route('login');
|
||||
}
|
||||
return $request->expectsJson() ? null : route('login');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,17 +5,14 @@ namespace App\Http\Middleware;
|
|||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class CSPHeader
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if (App::environment('local', 'development')) {
|
||||
return $next($request);
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
|
||||
|
||||
class CheckForMaintenanceMode extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
|
@ -3,17 +3,15 @@
|
|||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class CorsHeaders
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$response = $next($request);
|
||||
if ($request->path() === 'api/media') {
|
||||
|
|
|
@ -9,7 +9,7 @@ class EncryptCookies extends Middleware
|
|||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
|
|
|
@ -3,17 +3,15 @@
|
|||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class LinkHeadersMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$response = $next($request);
|
||||
$response->header('Link', '<https://indieauth.com/auth>; rel="authorization_endpoint"', false);
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace App\Http\Middleware;
|
|||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class LocalhostSessionMiddleware
|
||||
{
|
||||
|
@ -13,12 +14,8 @@ class LocalhostSessionMiddleware
|
|||
* Whilst we are developing locally, automatically log in as
|
||||
* `['me' => config('app.url')]` as I can’t manually log in as
|
||||
* a .localhost domain.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if (config('app.env') !== 'production') {
|
||||
session(['me' => config('app.url')]);
|
||||
|
|
|
@ -7,19 +7,16 @@ namespace App\Http\Middleware;
|
|||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class MyAuthMiddleware
|
||||
{
|
||||
/**
|
||||
* Check the user is logged in.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if (Auth::check($request->user()) == false) {
|
||||
if (Auth::check() === false) {
|
||||
// they’re not logged in, so send them to login form
|
||||
return redirect()->route('login');
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ class PreventRequestsDuringMaintenance extends Middleware
|
|||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
|
|
|
@ -6,6 +6,7 @@ use App\Providers\RouteServiceProvider;
|
|||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
|
@ -15,12 +16,9 @@ class RedirectIfAuthenticated
|
|||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null ...$guards
|
||||
* @return mixed
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, ...$guards)
|
||||
public function handle(Request $request, Closure $next, string ...$guards): Response
|
||||
{
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
|
|
|
@ -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',
|
||||
];
|
||||
|
|
|
@ -12,9 +12,9 @@ class TrustHosts extends Middleware
|
|||
/**
|
||||
* Get the host patterns that should be trusted.
|
||||
*
|
||||
* @return array
|
||||
* @return array<int, string|null>
|
||||
*/
|
||||
public function hosts()
|
||||
public function hosts(): array
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
|
|
|
@ -10,7 +10,7 @@ class TrustProxies extends Middleware
|
|||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array|string
|
||||
* @var array<int, string>|string|null
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ class VerifyCsrfToken extends Middleware
|
|||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'api/media',
|
||||
|
|
|
@ -6,17 +6,14 @@ namespace App\Http\Middleware;
|
|||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class VerifyMicropubToken
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if ($request->input('access_token')) {
|
||||
return $next($request);
|
||||
|
|
|
@ -10,8 +10,6 @@ class MicropubResponses
|
|||
{
|
||||
/**
|
||||
* Generate a response to be returned when the token has insufficient scope.
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function insufficientScopeResponse(): JsonResponse
|
||||
{
|
||||
|
@ -24,8 +22,6 @@ class MicropubResponses
|
|||
|
||||
/**
|
||||
* Generate a response to be returned when the token is invalid.
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function invalidTokenResponse(): JsonResponse
|
||||
{
|
||||
|
@ -38,8 +34,6 @@ class MicropubResponses
|
|||
|
||||
/**
|
||||
* Generate a response to be returned when the token has no scope.
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function tokenHasNoScopeResponse(): JsonResponse
|
||||
{
|
||||
|
|
|
@ -18,26 +18,22 @@ class AddClientToDatabase implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
protected $client_id;
|
||||
protected string $client_id;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param string $client_id
|
||||
*/
|
||||
public function __construct(string $client_id)
|
||||
public function __construct(string $clientId)
|
||||
{
|
||||
$this->client_id = $client_id;
|
||||
$this->client_id = $clientId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): void
|
||||
{
|
||||
if (MicropubClient::where('client_url', $this->client_id)->count() == 0) {
|
||||
if (MicropubClient::where('client_url', $this->client_id)->count() === 0) {
|
||||
MicropubClient::create([
|
||||
'client_url' => $this->client_id,
|
||||
'client_name' => $this->client_id, // default client name is the URL
|
||||
|
|
|
@ -19,37 +19,26 @@ class DownloadWebMention implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The webmention source URL.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $source;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param string $source
|
||||
*/
|
||||
public function __construct(string $source)
|
||||
{
|
||||
$this->source = $source;
|
||||
public function __construct(
|
||||
protected string $source
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @param Client $guzzle
|
||||
*
|
||||
* @throws GuzzleException
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public function handle(Client $guzzle)
|
||||
public function handle(Client $guzzle): void
|
||||
{
|
||||
$response = $guzzle->request('GET', $this->source);
|
||||
//4XX and 5XX responses should get Guzzle to throw an exception,
|
||||
//Laravel should catch and retry these automatically.
|
||||
if ($response->getStatusCode() == '200') {
|
||||
if ($response->getStatusCode() === 200) {
|
||||
$filesystem = new FileSystem();
|
||||
$filename = storage_path('HTML') . '/' . $this->createFilenameFromURL($this->source);
|
||||
//backup file first
|
||||
|
@ -72,7 +61,7 @@ class DownloadWebMention implements ShouldQueue
|
|||
);
|
||||
//remove backup if the same
|
||||
if ($filesystem->exists($filenameBackup)) {
|
||||
if ($filesystem->get($filename) == $filesystem->get($filenameBackup)) {
|
||||
if ($filesystem->get($filename) === $filesystem->get($filenameBackup)) {
|
||||
$filesystem->delete($filenameBackup);
|
||||
}
|
||||
}
|
||||
|
@ -81,14 +70,11 @@ class DownloadWebMention implements ShouldQueue
|
|||
|
||||
/**
|
||||
* Create a file path from a URL. This is used when caching the HTML response.
|
||||
*
|
||||
* @param string $url
|
||||
* @return string The path name
|
||||
*/
|
||||
private function createFilenameFromURL(string $url)
|
||||
private function createFilenameFromURL(string $url): string
|
||||
{
|
||||
$filepath = str_replace(['https://', 'http://'], ['https/', 'http/'], $url);
|
||||
if (substr($filepath, -1) == '/') {
|
||||
if (str_ends_with($filepath, '/')) {
|
||||
$filepath .= 'index.html';
|
||||
}
|
||||
|
||||
|
|
|
@ -20,22 +20,16 @@ class ProcessBookmark implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
protected Bookmark $bookmark;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param Bookmark $bookmark
|
||||
*/
|
||||
public function __construct(Bookmark $bookmark)
|
||||
{
|
||||
$this->bookmark = $bookmark;
|
||||
public function __construct(
|
||||
protected Bookmark $bookmark
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
|
|
|
@ -25,26 +25,17 @@ class ProcessLike implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/** @var Like */
|
||||
protected $like;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param Like $like
|
||||
*/
|
||||
public function __construct(Like $like)
|
||||
{
|
||||
$this->like = $like;
|
||||
public function __construct(
|
||||
protected Like $like
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @param Client $client
|
||||
* @param Authorship $authorship
|
||||
* @return int
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function handle(Client $client, Authorship $authorship): int
|
||||
|
@ -104,9 +95,6 @@ class ProcessLike implements ShouldQueue
|
|||
|
||||
/**
|
||||
* Determine if a given URL is that of a Tweet.
|
||||
*
|
||||
* @param string $url
|
||||
* @return bool
|
||||
*/
|
||||
private function isTweet(string $url): bool
|
||||
{
|
||||
|
|
|
@ -20,25 +20,18 @@ class ProcessMedia implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/** @var string */
|
||||
protected $filename;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param string $filename
|
||||
*/
|
||||
public function __construct(string $filename)
|
||||
{
|
||||
$this->filename = $filename;
|
||||
public function __construct(
|
||||
protected string $filename
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @param ImageManager $manager
|
||||
*/
|
||||
public function handle(ImageManager $manager)
|
||||
public function handle(ImageManager $manager): void
|
||||
{
|
||||
//open file
|
||||
try {
|
||||
|
|
|
@ -24,35 +24,23 @@ class ProcessWebMention implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/** @var Note */
|
||||
protected $note;
|
||||
|
||||
/** @var string */
|
||||
protected $source;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param Note $note
|
||||
* @param string $source
|
||||
*/
|
||||
public function __construct(Note $note, string $source)
|
||||
{
|
||||
$this->note = $note;
|
||||
$this->source = $source;
|
||||
public function __construct(
|
||||
protected Note $note,
|
||||
protected string $source
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @param Parser $parser
|
||||
* @param Client $guzzle
|
||||
*
|
||||
* @throws RemoteContentNotFoundException
|
||||
* @throws GuzzleException
|
||||
* @throws InvalidMentionException
|
||||
*/
|
||||
public function handle(Parser $parser, Client $guzzle)
|
||||
public function handle(Parser $parser, Client $guzzle): void
|
||||
{
|
||||
try {
|
||||
$response = $guzzle->request('GET', $this->source);
|
||||
|
@ -65,8 +53,8 @@ class ProcessWebMention implements ShouldQueue
|
|||
foreach ($webmentions as $webmention) {
|
||||
// check webmention still references target
|
||||
// we try each type of mention (reply/like/repost)
|
||||
if ($webmention->type == 'in-reply-to') {
|
||||
if ($parser->checkInReplyTo($microformats, $this->note->longurl) == false) {
|
||||
if ($webmention->type === 'in-reply-to') {
|
||||
if ($parser->checkInReplyTo($microformats, $this->note->longurl) === false) {
|
||||
// it doesn’t so delete
|
||||
$webmention->delete();
|
||||
|
||||
|
@ -79,16 +67,16 @@ class ProcessWebMention implements ShouldQueue
|
|||
|
||||
return;
|
||||
}
|
||||
if ($webmention->type == 'like-of') {
|
||||
if ($parser->checkLikeOf($microformats, $this->note->longurl) == false) {
|
||||
if ($webmention->type === 'like-of') {
|
||||
if ($parser->checkLikeOf($microformats, $this->note->longurl) === false) {
|
||||
// it doesn’t so delete
|
||||
$webmention->delete();
|
||||
|
||||
return;
|
||||
} // note we don’t need to do anything if it still is a like
|
||||
}
|
||||
if ($webmention->type == 'repost-of') {
|
||||
if ($parser->checkRepostOf($microformats, $this->note->longurl) == false) {
|
||||
if ($webmention->type === 'repost-of') {
|
||||
if ($parser->checkRepostOf($microformats, $this->note->longurl) === false) {
|
||||
// it doesn’t so delete
|
||||
$webmention->delete();
|
||||
|
||||
|
@ -112,26 +100,23 @@ class ProcessWebMention implements ShouldQueue
|
|||
|
||||
/**
|
||||
* Save the HTML of a webmention for future use.
|
||||
*
|
||||
* @param string $html
|
||||
* @param string $url
|
||||
*/
|
||||
private function saveRemoteContent($html, $url)
|
||||
private function saveRemoteContent(string $html, string $url): void
|
||||
{
|
||||
$filenameFromURL = str_replace(
|
||||
['https://', 'http://'],
|
||||
['https/', 'http/'],
|
||||
$url
|
||||
);
|
||||
if (substr($url, -1) == '/') {
|
||||
if (str_ends_with($url, '/')) {
|
||||
$filenameFromURL .= 'index.html';
|
||||
}
|
||||
$path = storage_path() . '/HTML/' . $filenameFromURL;
|
||||
$parts = explode('/', $path);
|
||||
$name = array_pop($parts);
|
||||
$dir = implode('/', $parts);
|
||||
if (! is_dir($dir)) {
|
||||
mkdir($dir, 0755, true);
|
||||
if (! is_dir($dir) && ! mkdir($dir, 0755, true) && ! is_dir($dir)) {
|
||||
throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir));
|
||||
}
|
||||
file_put_contents("$dir/$name", $html);
|
||||
}
|
||||
|
|
|
@ -20,29 +20,23 @@ class SaveProfileImage implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
protected array $microformats;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param array $microformats
|
||||
*/
|
||||
public function __construct(array $microformats)
|
||||
{
|
||||
$this->microformats = $microformats;
|
||||
public function __construct(
|
||||
protected array $microformats
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @param Authorship $authorship
|
||||
*/
|
||||
public function handle(Authorship $authorship)
|
||||
public function handle(Authorship $authorship): void
|
||||
{
|
||||
try {
|
||||
$author = $authorship->findAuthor($this->microformats);
|
||||
} catch (AuthorshipParserException) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
$photo = Arr::get($author, 'properties.photo.0');
|
||||
|
@ -51,8 +45,8 @@ class SaveProfileImage implements ShouldQueue
|
|||
//dont save pbs.twimg.com links
|
||||
if (
|
||||
$photo
|
||||
&& parse_url($photo, PHP_URL_HOST) != 'pbs.twimg.com'
|
||||
&& parse_url($photo, PHP_URL_HOST) != 'twitter.com'
|
||||
&& parse_url($photo, PHP_URL_HOST) !== 'pbs.twimg.com'
|
||||
&& parse_url($photo, PHP_URL_HOST) !== 'twitter.com'
|
||||
) {
|
||||
$client = resolve(Client::class);
|
||||
|
||||
|
@ -71,8 +65,8 @@ class SaveProfileImage implements ShouldQueue
|
|||
$parts = explode('/', $path);
|
||||
$name = array_pop($parts);
|
||||
$dir = implode('/', $parts);
|
||||
if (! is_dir($dir)) {
|
||||
mkdir($dir, 0755, true);
|
||||
if (! is_dir($dir) && ! mkdir($dir, 0755, true) && ! is_dir($dir)) {
|
||||
throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir));
|
||||
}
|
||||
file_put_contents("$dir/$name", $image);
|
||||
}
|
||||
|
|
|
@ -18,22 +18,17 @@ class SaveScreenshot implements ShouldQueue
|
|||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
private Bookmark $bookmark;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Bookmark $bookmark)
|
||||
{
|
||||
$this->bookmark = $bookmark;
|
||||
public function __construct(
|
||||
protected Bookmark $bookmark
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws JsonException
|
||||
*/
|
||||
|
|
|
@ -22,23 +22,17 @@ class SendWebMentions implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
protected Note $note;
|
||||
|
||||
/**
|
||||
* Create the job instance, inject dependencies.
|
||||
*
|
||||
* @param Note $note
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct(Note $note)
|
||||
{
|
||||
$this->note = $note;
|
||||
public function __construct(
|
||||
protected Note $note
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function handle(): void
|
||||
|
@ -63,9 +57,6 @@ class SendWebMentions implements ShouldQueue
|
|||
/**
|
||||
* Discover if a URL has a webmention endpoint.
|
||||
*
|
||||
* @param string $url
|
||||
* @return string|null
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function discoverWebmentionEndpoint(string $url): ?string
|
||||
|
@ -111,9 +102,6 @@ class SendWebMentions implements ShouldQueue
|
|||
|
||||
/**
|
||||
* Get the URLs from a note.
|
||||
*
|
||||
* @param string|null $html
|
||||
* @return array
|
||||
*/
|
||||
public function getLinks(?string $html): array
|
||||
{
|
||||
|
@ -134,10 +122,6 @@ class SendWebMentions implements ShouldQueue
|
|||
|
||||
/**
|
||||
* Resolve a URI if necessary.
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $base The base of the URL
|
||||
* @return string
|
||||
*/
|
||||
public function resolveUri(string $url, string $base): string
|
||||
{
|
||||
|
|
|
@ -20,27 +20,20 @@ class SyndicateBookmarkToTwitter implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/** @var Bookmark */
|
||||
protected $bookmark;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param Bookmark $bookmark
|
||||
*/
|
||||
public function __construct(Bookmark $bookmark)
|
||||
{
|
||||
$this->bookmark = $bookmark;
|
||||
public function __construct(
|
||||
protected Bookmark $bookmark
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @param Client $guzzle
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function handle(Client $guzzle)
|
||||
public function handle(Client $guzzle): void
|
||||
{
|
||||
//send webmention
|
||||
$response = $guzzle->request(
|
||||
|
@ -55,7 +48,7 @@ class SyndicateBookmarkToTwitter implements ShouldQueue
|
|||
]
|
||||
);
|
||||
//parse for syndication URL
|
||||
if ($response->getStatusCode() == 201) {
|
||||
if ($response->getStatusCode() === 201) {
|
||||
$json = json_decode((string) $response->getBody());
|
||||
$syndicates = $this->bookmark->syndicates;
|
||||
$syndicates['twitter'] = $json->url;
|
||||
|
|
|
@ -19,9 +19,6 @@ class SyndicateNoteToMastodon implements ShouldQueue
|
|||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param Note $note
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
protected Note $note
|
||||
|
@ -31,9 +28,6 @@ class SyndicateNoteToMastodon implements ShouldQueue
|
|||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @param Client $guzzle
|
||||
* @return void
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function handle(Client $guzzle): void
|
||||
|
|
|
@ -18,23 +18,17 @@ class SyndicateNoteToTwitter implements ShouldQueue
|
|||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/** @var Note */
|
||||
protected $note;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param Note $note
|
||||
*/
|
||||
public function __construct(Note $note)
|
||||
{
|
||||
$this->note = $note;
|
||||
public function __construct(
|
||||
protected Note $note
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @param Client $guzzle
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
|
|
|
@ -24,24 +24,26 @@ class Article extends Model
|
|||
use Sluggable;
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
|
||||
/**
|
||||
* The database table used by the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
protected $table = 'articles';
|
||||
|
||||
/** @var array<int, string> */
|
||||
protected $fillable = [
|
||||
'url',
|
||||
'title',
|
||||
'main',
|
||||
'published',
|
||||
];
|
||||
|
||||
/** @var array<string, string> */
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* Return the sluggable configuration array for this model.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function sluggable(): array
|
||||
{
|
||||
|
@ -52,18 +54,6 @@ class Article extends Model
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'url',
|
||||
'title',
|
||||
'main',
|
||||
'published',
|
||||
];
|
||||
|
||||
protected function html(): Attribute
|
||||
{
|
||||
return Attribute::get(
|
||||
|
@ -116,11 +106,6 @@ class Article extends Model
|
|||
|
||||
/**
|
||||
* Scope a query to only include articles from a particular year/month.
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param int|null $year
|
||||
* @param int|null $month
|
||||
* @return Builder
|
||||
*/
|
||||
public function scopeDate(Builder $query, int $year = null, int $month = null): Builder
|
||||
{
|
||||
|
|
|
@ -13,28 +13,15 @@ class Bookmark extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<int, string> */
|
||||
protected $fillable = ['url', 'name', 'content'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<string, string> */
|
||||
protected $casts = [
|
||||
'syndicates' => 'array',
|
||||
];
|
||||
|
||||
/**
|
||||
* The tags that belong to the bookmark.
|
||||
*
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function tags()
|
||||
public function tags(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany('App\Models\Tag');
|
||||
}
|
||||
|
|
|
@ -12,18 +12,10 @@ class Contact extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The database table used by the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
protected $table = 'contacts';
|
||||
|
||||
/**
|
||||
* We shall guard against mass-migration.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<int, string> */
|
||||
protected $fillable = ['nick', 'name', 'homepage', 'twitter', 'facebook'];
|
||||
|
||||
protected function photo(): Attribute
|
||||
|
|
|
@ -16,6 +16,7 @@ class Like extends Model
|
|||
use FilterHtml;
|
||||
use HasFactory;
|
||||
|
||||
/** @var array<int, string> */
|
||||
protected $fillable = ['url'];
|
||||
|
||||
protected function url(): Attribute
|
||||
|
|
|
@ -14,25 +14,12 @@ class Media extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
protected $table = 'media_endpoint';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<int, string> */
|
||||
protected $fillable = ['token', 'path', 'type', 'image_widths'];
|
||||
|
||||
/**
|
||||
* Get the note that owns this media.
|
||||
*
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function note(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Note::class);
|
||||
|
|
|
@ -12,25 +12,12 @@ class MicropubClient extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
protected $table = 'clients';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<int, string> */
|
||||
protected $fillable = ['client_url', 'client_name'];
|
||||
|
||||
/**
|
||||
* Define the relationship with notes.
|
||||
*
|
||||
* @return HasMany
|
||||
*/
|
||||
public function notes(): HasMany
|
||||
{
|
||||
return $this->hasMany('App\Models\Note', 'client_id', 'client_url');
|
||||
|
|
|
@ -6,7 +6,6 @@ namespace App\Models;
|
|||
|
||||
use App\CommonMark\Generators\ContactMentionGenerator;
|
||||
use App\CommonMark\Renderers\ContactMentionRenderer;
|
||||
use App\Exceptions\TwitterContentException;
|
||||
use Codebird\Codebird;
|
||||
use Exception;
|
||||
use GuzzleHttp\Client;
|
||||
|
@ -51,8 +50,6 @@ class Note extends Model
|
|||
|
||||
/**
|
||||
* Set our contacts variable to null.
|
||||
*
|
||||
* @param array $attributes
|
||||
*/
|
||||
public function __construct(array $attributes = [])
|
||||
{
|
||||
|
@ -60,85 +57,46 @@ class Note extends Model
|
|||
$this->contacts = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The database table used by the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
protected $table = 'notes';
|
||||
|
||||
/**
|
||||
* Mass-assignment.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<int, string> */
|
||||
protected $fillable = [
|
||||
'note',
|
||||
'in_reply_to',
|
||||
'client_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* Hide the column used with Laravel Scout.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<int, string> */
|
||||
protected $hidden = ['searchable'];
|
||||
|
||||
/**
|
||||
* Define the relationship with tags.
|
||||
*
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function tags(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Tag::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the relationship with clients.
|
||||
*
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function client(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(MicropubClient::class, 'client_id', 'client_url');
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the relationship with webmentions.
|
||||
*
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function webmentions(): MorphMany
|
||||
{
|
||||
return $this->morphMany(WebMention::class, 'commentable');
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the relationship with places.
|
||||
*
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function place(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Place::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the relationship with media.
|
||||
*
|
||||
* @return HasMany
|
||||
*/
|
||||
public function media(): HasMany
|
||||
{
|
||||
return $this->hasMany(Media::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the attributes to be indexed for searching with Scout.
|
||||
*
|
||||
* @return array
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function toSearchableArray(): array
|
||||
{
|
||||
|
@ -147,11 +105,6 @@ class Note extends Model
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize the note to Unicode FORM C.
|
||||
*
|
||||
* @param string|null $value
|
||||
*/
|
||||
public function setNoteAttribute(?string $value): void
|
||||
{
|
||||
if ($value !== null) {
|
||||
|
@ -165,9 +118,6 @@ class Note extends Model
|
|||
|
||||
/**
|
||||
* Pre-process notes for web-view.
|
||||
*
|
||||
* @param string|null $value
|
||||
* @return string|null
|
||||
*/
|
||||
public function getNoteAttribute(?string $value): ?string
|
||||
{
|
||||
|
@ -189,8 +139,6 @@ class Note extends Model
|
|||
* Provide the content_html for JSON feed.
|
||||
*
|
||||
* In particular, we want to include media links such as images.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContentAttribute(): string
|
||||
{
|
||||
|
@ -216,72 +164,37 @@ class Note extends Model
|
|||
return $note;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the NewBase60 ID from primary ID.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNb60idAttribute(): string
|
||||
{
|
||||
// we cast to string because sometimes the nb60id is an “int”
|
||||
return (string) resolve(Numbers::class)->numto60($this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* The Long URL for a note.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLongurlAttribute(): string
|
||||
{
|
||||
return config('app.url') . '/notes/' . $this->nb60id;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Short URL for a note.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getShorturlAttribute(): string
|
||||
{
|
||||
return config('app.shorturl') . '/notes/' . $this->nb60id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ISO8601 value for mf2.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIso8601Attribute(): string
|
||||
{
|
||||
return $this->updated_at->toISO8601String();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ISO8601 value for mf2.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHumandiffAttribute(): string
|
||||
{
|
||||
return $this->updated_at->diffForHumans();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the publish date value for RSS feeds.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPubdateAttribute(): string
|
||||
{
|
||||
return $this->updated_at->toRSSString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latitude value.
|
||||
*
|
||||
* @return float|null
|
||||
*/
|
||||
public function getLatitudeAttribute(): ?float
|
||||
{
|
||||
if ($this->place !== null) {
|
||||
|
@ -297,11 +210,6 @@ class Note extends Model
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the longitude value.
|
||||
*
|
||||
* @return float|null
|
||||
*/
|
||||
public function getLongitudeAttribute(): ?float
|
||||
{
|
||||
if ($this->place !== null) {
|
||||
|
@ -318,10 +226,9 @@ class Note extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the address for a note. This is either a reverse geo-code from the
|
||||
* location, or is derived from the associated place.
|
||||
* Get the address for a note.
|
||||
*
|
||||
* @return string|null
|
||||
* This is either a reverse geo-code from the location, or is derived from the associated place.
|
||||
*/
|
||||
public function getAddressAttribute(): ?string
|
||||
{
|
||||
|
@ -337,8 +244,6 @@ class Note extends Model
|
|||
|
||||
/**
|
||||
* Get the OEmbed html for a tweet the note is a reply to.
|
||||
*
|
||||
* @return object|null
|
||||
*/
|
||||
public function getTwitterAttribute(): ?object
|
||||
{
|
||||
|
@ -378,10 +283,6 @@ class Note extends Model
|
|||
* Show a specific form of the note for twitter.
|
||||
*
|
||||
* That is we swap the contacts names for their known Twitter handles.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws TwitterContentException
|
||||
*/
|
||||
public function getTwitterContentAttribute(): string
|
||||
{
|
||||
|
@ -424,10 +325,6 @@ class Note extends Model
|
|||
|
||||
/**
|
||||
* Scope a query to select a note via a NewBase60 id.
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $nb60id
|
||||
* @return Builder
|
||||
*/
|
||||
public function scopeNb60(Builder $query, string $nb60id): Builder
|
||||
{
|
||||
|
@ -441,9 +338,6 @@ class Note extends Model
|
|||
* we try to create a fancy hcard from our contact info. If this is not possible
|
||||
* due to lack of contact info, we assume @username is a twitter handle and link it
|
||||
* as such.
|
||||
*
|
||||
* @param string $text
|
||||
* @return string
|
||||
*/
|
||||
private function makeHCards(string $text): string
|
||||
{
|
||||
|
@ -475,8 +369,6 @@ class Note extends Model
|
|||
|
||||
/**
|
||||
* Get the value of the `contacts` property.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getContacts(): array
|
||||
{
|
||||
|
@ -489,8 +381,6 @@ class Note extends Model
|
|||
|
||||
/**
|
||||
* Process the note and save the contacts to the `contacts` property.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setContacts(): void
|
||||
{
|
||||
|
@ -512,9 +402,6 @@ class Note extends Model
|
|||
* Given a string and section, finds all hashtags matching
|
||||
* `#[\-_a-zA-Z0-9]+` and wraps them in an `a` element with
|
||||
* `rel=tag` set and a `href` of 'section/tagged/' + tagname without the #.
|
||||
*
|
||||
* @param string $note
|
||||
* @return string
|
||||
*/
|
||||
public function autoLinkHashtag(string $note): string
|
||||
{
|
||||
|
@ -529,12 +416,6 @@ class Note extends Model
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass a note through the commonmark library.
|
||||
*
|
||||
* @param string $note
|
||||
* @return string
|
||||
*/
|
||||
private function convertMarkdown(string $note): string
|
||||
{
|
||||
$config = [
|
||||
|
@ -559,13 +440,6 @@ class Note extends Model
|
|||
return $markdownConverter->convert($note)->getContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Do a reverse geocode lookup of a `lat,lng` value.
|
||||
*
|
||||
* @param float $latitude
|
||||
* @param float $longitude
|
||||
* @return string
|
||||
*/
|
||||
public function reverseGeoCode(float $latitude, float $longitude): string
|
||||
{
|
||||
$latLng = $latitude . ',' . $longitude;
|
||||
|
|
|
@ -17,38 +17,20 @@ class Place extends Model
|
|||
use HasFactory;
|
||||
use Sluggable;
|
||||
|
||||
/**
|
||||
* Get the route key for the model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRouteKeyName()
|
||||
public function getRouteKeyName(): string
|
||||
{
|
||||
return 'slug';
|
||||
}
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<int, string> */
|
||||
protected $fillable = ['name', 'slug'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<string, string> */
|
||||
protected $casts = [
|
||||
'latitude' => 'float',
|
||||
'longitude' => 'float',
|
||||
];
|
||||
|
||||
/**
|
||||
* Return the sluggable configuration array for this model.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function sluggable(): array
|
||||
{
|
||||
return [
|
||||
|
@ -59,23 +41,13 @@ class Place extends Model
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the relationship with Notes.
|
||||
*
|
||||
* @return HasMany
|
||||
*/
|
||||
public function notes()
|
||||
public function notes(): HasMany
|
||||
{
|
||||
return $this->hasMany('App\Models\Note');
|
||||
}
|
||||
|
||||
/**
|
||||
* Select places near a given location.
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param object $location
|
||||
* @param int $distance
|
||||
* @return Builder
|
||||
*/
|
||||
public function scopeNear(Builder $query, object $location, int $distance = 1000): Builder
|
||||
{
|
||||
|
@ -94,10 +66,6 @@ class Place extends Model
|
|||
|
||||
/**
|
||||
* Select places based on a URL.
|
||||
*
|
||||
* @param Builder $query
|
||||
* @param string $url
|
||||
* @return Builder
|
||||
*/
|
||||
public function scopeWhereExternalURL(Builder $query, string $url): Builder
|
||||
{
|
||||
|
@ -150,9 +118,6 @@ class Place extends Model
|
|||
|
||||
/**
|
||||
* Given a URL, see if it is one of our known types.
|
||||
*
|
||||
* @param string $url
|
||||
* @return string
|
||||
*/
|
||||
private function getType(string $url): string
|
||||
{
|
||||
|
|
|
@ -12,11 +12,7 @@ class SyndicationTarget extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<int, string> */
|
||||
protected $fillable = [
|
||||
'uid',
|
||||
'name',
|
||||
|
@ -28,11 +24,7 @@ class SyndicationTarget extends Model
|
|||
'user_photo',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that are visible when serializing the model.
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
/** @var array<int, string> */
|
||||
protected $visible = [
|
||||
'uid',
|
||||
'name',
|
||||
|
@ -40,21 +32,12 @@ class SyndicationTarget extends Model
|
|||
'user',
|
||||
];
|
||||
|
||||
/**
|
||||
* The accessors to append to the model's array form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<int, string> */
|
||||
protected $appends = [
|
||||
'service',
|
||||
'user',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the service data as a single attribute.
|
||||
*
|
||||
* @vreturn Attribute
|
||||
*/
|
||||
protected function service(): Attribute
|
||||
{
|
||||
return Attribute::get(
|
||||
|
@ -66,11 +49,6 @@ class SyndicationTarget extends Model
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user data as a single attribute.
|
||||
*
|
||||
* @vreturn Attribute
|
||||
*/
|
||||
protected function user(): Attribute
|
||||
{
|
||||
return Attribute::get(
|
||||
|
|
|
@ -14,29 +14,15 @@ class Tag extends Model
|
|||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* We shall set a blacklist of non-modifiable model attributes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<int, string> */
|
||||
protected $guarded = ['id'];
|
||||
|
||||
/**
|
||||
* Define the relationship with notes.
|
||||
*
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function notes()
|
||||
public function notes(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Note::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* The bookmarks that belong to the tag.
|
||||
*
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function bookmarks()
|
||||
public function bookmarks(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany('App\Models\Bookmark');
|
||||
}
|
||||
|
@ -49,11 +35,9 @@ class Tag extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* This method actually normalizes a tag. That means lowercase-ing and
|
||||
* removing fancy diatric characters.
|
||||
* Normalizes a tag.
|
||||
*
|
||||
* @param string $tag
|
||||
* @return string
|
||||
* That means convert to lowercase and removing fancy diatric characters.
|
||||
*/
|
||||
public static function normalize(string $tag): string
|
||||
{
|
||||
|
|
|
@ -13,21 +13,15 @@ class User extends Authenticatable
|
|||
use HasFactory;
|
||||
use Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<int, string> */
|
||||
protected $fillable = [
|
||||
'name', 'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<int, string> */
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
'current_password',
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
}
|
||||
|
|
|
@ -20,26 +20,13 @@ class WebMention extends Model
|
|||
use FilterHtml;
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The database table used by the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
/** @var string */
|
||||
protected $table = 'webmentions';
|
||||
|
||||
/**
|
||||
* We shall set a blacklist of non-modifiable model attributes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
/** @var array<int, string> */
|
||||
protected $guarded = ['id'];
|
||||
|
||||
/**
|
||||
* Define the relationship.
|
||||
*
|
||||
* @return MorphTo
|
||||
*/
|
||||
public function commentable()
|
||||
public function commentable(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
@ -121,9 +108,6 @@ class WebMention extends Model
|
|||
|
||||
/**
|
||||
* Create the photo link.
|
||||
*
|
||||
* @param string $url
|
||||
* @return string
|
||||
*/
|
||||
public function createPhotoLink(string $url): string
|
||||
{
|
||||
|
|
|
@ -13,10 +13,8 @@ class NoteObserver
|
|||
{
|
||||
/**
|
||||
* Listen to the Note created event.
|
||||
*
|
||||
* @param Note $note
|
||||
*/
|
||||
public function created(Note $note)
|
||||
public function created(Note $note): void
|
||||
{
|
||||
$text = Arr::get($note->getAttributes(), 'note');
|
||||
if ($text === null) {
|
||||
|
@ -37,10 +35,8 @@ class NoteObserver
|
|||
|
||||
/**
|
||||
* Listen to the Note updated event.
|
||||
*
|
||||
* @param Note $note
|
||||
*/
|
||||
public function updated(Note $note)
|
||||
public function updated(Note $note): void
|
||||
{
|
||||
$text = Arr::get($note->getAttributes(), 'note');
|
||||
if ($text === null) {
|
||||
|
@ -63,19 +59,14 @@ class NoteObserver
|
|||
|
||||
/**
|
||||
* Listen to the Note deleting event.
|
||||
*
|
||||
* @param Note $note
|
||||
*/
|
||||
public function deleting(Note $note)
|
||||
public function deleting(Note $note): void
|
||||
{
|
||||
$note->tags()->detach();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the tags from a note’s text, tag for form #tag.
|
||||
*
|
||||
* @param string $note
|
||||
* @return Collection
|
||||
*/
|
||||
private function getTagsFromNote(string $note): Collection
|
||||
{
|
||||
|
|
|
@ -25,10 +25,8 @@ class AppServiceProvider extends ServiceProvider
|
|||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
public function boot(): void
|
||||
{
|
||||
Note::observe(NoteObserver::class);
|
||||
|
||||
|
@ -144,10 +142,8 @@ class AppServiceProvider extends ServiceProvider
|
|||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
public function register(): void
|
||||
{
|
||||
if ($this->app->environment('local', 'testing')) {
|
||||
$this->app->register(DuskServiceProvider::class);
|
||||
|
|
|
@ -7,23 +7,19 @@ use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvid
|
|||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The policy mappings for the application.
|
||||
* The model to policy mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
* @var array<class-string, class-string>
|
||||
*/
|
||||
protected $policies = [
|
||||
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any application authentication / authorization services.
|
||||
*
|
||||
* @return void
|
||||
* Register any authentication / authorization services.
|
||||
*/
|
||||
public function boot()
|
||||
public function boot(): void
|
||||
{
|
||||
$this->registerPolicies();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,10 +12,8 @@ class BroadcastServiceProvider extends ServiceProvider
|
|||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
public function boot(): void
|
||||
{
|
||||
Broadcast::routes();
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@ use Illuminate\Support\Facades\Event;
|
|||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event listener mappings for the application.
|
||||
* The event to listener mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
* @var array<class-string, array<int, class-string>>
|
||||
*/
|
||||
protected $listen = [
|
||||
Registered::class => [
|
||||
|
@ -22,13 +22,9 @@ class EventServiceProvider extends ServiceProvider
|
|||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
public function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,10 +10,8 @@ class HorizonServiceProvider extends HorizonApplicationServiceProvider
|
|||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
public function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
|
@ -28,10 +26,8 @@ class HorizonServiceProvider extends HorizonApplicationServiceProvider
|
|||
* Register the Horizon gate.
|
||||
*
|
||||
* This gate determines who can access Horizon in non-local environments.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function gate()
|
||||
protected function gate(): void
|
||||
{
|
||||
Gate::define('viewHorizon', function ($user) {
|
||||
return $user->name === 'jonny';
|
||||
|
|
|
@ -11,46 +11,38 @@ use Illuminate\Support\Facades\Route;
|
|||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* This namespace is applied to your controller routes.
|
||||
* The path to the "home" route for your application.
|
||||
*
|
||||
* In addition, it is set as the URL generator's root namespace.
|
||||
* Typically, users are redirected here after authentication.
|
||||
*
|
||||
* @var string|null
|
||||
* @var string
|
||||
*/
|
||||
// protected $namespace = 'App\Http\Controllers';
|
||||
public const HOME = '/admin';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @return void
|
||||
* Define your route model bindings, pattern filters, and other route configuration.
|
||||
*/
|
||||
public function boot()
|
||||
public function boot(): void
|
||||
{
|
||||
$this->configureRateLimiting();
|
||||
|
||||
$this->routes(function () {
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->namespace($this->namespace)
|
||||
Route::middleware('api')
|
||||
->prefix('api')
|
||||
->group(base_path('routes/api.php'));
|
||||
|
||||
Route::middleware('web')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/web.php'));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the rate limiters for the application.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
protected function configureRateLimiting()
|
||||
protected function configureRateLimiting(): void
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60);
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,15 +5,14 @@ declare(strict_types=1);
|
|||
namespace App\Services;
|
||||
|
||||
use App\Models\Note;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class ActivityStreamsService
|
||||
{
|
||||
/**
|
||||
* Return the relevant data to an AS2.0 request to the root path.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function siteOwnerResponse()
|
||||
public function siteOwnerResponse(): Response
|
||||
{
|
||||
$data = json_encode([
|
||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||
|
@ -28,11 +27,8 @@ class ActivityStreamsService
|
|||
|
||||
/**
|
||||
* Return the relevant data to an AS2.0 request for a particular note.
|
||||
*
|
||||
* @param \App\Models\Note $note
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function singleNoteResponse(Note $note)
|
||||
public function singleNoteResponse(Note $note): Response
|
||||
{
|
||||
$data = json_encode([
|
||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||
|
|
|
@ -19,10 +19,6 @@ class BookmarkService extends Service
|
|||
{
|
||||
/**
|
||||
* Create a new Bookmark.
|
||||
*
|
||||
* @param array $request Data from request()->all()
|
||||
* @param string|null $client
|
||||
* @return Bookmark
|
||||
*/
|
||||
public function create(array $request, ?string $client = null): Bookmark
|
||||
{
|
||||
|
@ -76,9 +72,6 @@ class BookmarkService extends Service
|
|||
/**
|
||||
* Given a URL, attempt to save it to the Internet Archive.
|
||||
*
|
||||
* @param string $url
|
||||
* @return string
|
||||
*
|
||||
* @throws InternetArchiveException
|
||||
*/
|
||||
public function getArchiveLink(string $url): string
|
||||
|
|
|
@ -12,9 +12,6 @@ class LikeService extends Service
|
|||
{
|
||||
/**
|
||||
* Create a new Like.
|
||||
*
|
||||
* @param array $request
|
||||
* @return Like $like
|
||||
*/
|
||||
public function create(array $request, ?string $client = null): Like
|
||||
{
|
||||
|
|
|
@ -11,9 +11,6 @@ class HCardService
|
|||
{
|
||||
/**
|
||||
* Create a Place from h-card data, return the URL.
|
||||
*
|
||||
* @param array $request Data from request()->all()
|
||||
* @return string
|
||||
*/
|
||||
public function process(array $request): string
|
||||
{
|
||||
|
@ -29,8 +26,7 @@ class HCardService
|
|||
$data['latitude'] = Arr::get($request, 'latitude');
|
||||
$data['longitude'] = Arr::get($request, 'longitude');
|
||||
}
|
||||
$place = resolve(PlaceService::class)->createPlace($data);
|
||||
|
||||
return $place->longurl;
|
||||
return resolve(PlaceService::class)->createPlace($data)->longurl;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,11 +13,7 @@ use Illuminate\Support\Arr;
|
|||
class HEntryService
|
||||
{
|
||||
/**
|
||||
* Create the relavent model from some h-entry data.
|
||||
*
|
||||
* @param array $request Data from request()->all()
|
||||
* @param string|null $client The micropub client that made the request
|
||||
* @return string|null
|
||||
* Create the relevant model from some h-entry data.
|
||||
*/
|
||||
public function process(array $request, ?string $client = null): ?string
|
||||
{
|
||||
|
|
|
@ -7,6 +7,7 @@ namespace App\Services\Micropub;
|
|||
use App\Models\Media;
|
||||
use App\Models\Note;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
|
@ -14,11 +15,8 @@ class UpdateService
|
|||
{
|
||||
/**
|
||||
* Process a micropub request to update an entry.
|
||||
*
|
||||
* @param array $request Data from request()->all()
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function process(array $request)
|
||||
public function process(array $request): JsonResponse
|
||||
{
|
||||
$urlPath = parse_url(Arr::get($request, 'url'), PHP_URL_PATH);
|
||||
|
||||
|
@ -42,10 +40,10 @@ class UpdateService
|
|||
//got the note, are we dealing with a “replace” request?
|
||||
if (Arr::get($request, 'replace')) {
|
||||
foreach (Arr::get($request, 'replace') as $property => $value) {
|
||||
if ($property == 'content') {
|
||||
if ($property === 'content') {
|
||||
$note->note = $value[0];
|
||||
}
|
||||
if ($property == 'syndication') {
|
||||
if ($property === 'syndication') {
|
||||
foreach ($value as $syndicationURL) {
|
||||
if (Str::startsWith($syndicationURL, 'https://www.facebook.com')) {
|
||||
$note->facebook_url = $syndicationURL;
|
||||
|
@ -69,7 +67,7 @@ class UpdateService
|
|||
//how about “add”
|
||||
if (Arr::get($request, 'add')) {
|
||||
foreach (Arr::get($request, 'add') as $property => $value) {
|
||||
if ($property == 'syndication') {
|
||||
if ($property === 'syndication') {
|
||||
foreach ($value as $syndicationURL) {
|
||||
if (Str::startsWith($syndicationURL, 'https://www.facebook.com')) {
|
||||
$note->facebook_url = $syndicationURL;
|
||||
|
@ -82,7 +80,7 @@ class UpdateService
|
|||
}
|
||||
}
|
||||
}
|
||||
if ($property == 'photo') {
|
||||
if ($property === 'photo') {
|
||||
foreach ($value as $photoURL) {
|
||||
if (Str::startsWith($photoURL, 'https://')) {
|
||||
$media = new Media();
|
||||
|
|
|
@ -18,10 +18,6 @@ class NoteService extends Service
|
|||
{
|
||||
/**
|
||||
* Create a new note.
|
||||
*
|
||||
* @param array $request Data from request()->all()
|
||||
* @param string|null $client
|
||||
* @return Note
|
||||
*/
|
||||
public function create(array $request, ?string $client = null): Note
|
||||
{
|
||||
|
@ -68,9 +64,6 @@ class NoteService extends Service
|
|||
|
||||
/**
|
||||
* Get the published time from the request to create a new note.
|
||||
*
|
||||
* @param array $request Data from request()->all()
|
||||
* @return string|null
|
||||
*/
|
||||
private function getPublished(array $request): ?string
|
||||
{
|
||||
|
@ -87,14 +80,11 @@ class NoteService extends Service
|
|||
|
||||
/**
|
||||
* Get the location data from the request to create a new note.
|
||||
*
|
||||
* @param array $request Data from request()->all()
|
||||
* @return string|null
|
||||
*/
|
||||
private function getLocation(array $request): ?string
|
||||
{
|
||||
$location = Arr::get($request, 'properties.location.0') ?? Arr::get($request, 'location');
|
||||
if (is_string($location) && substr($location, 0, 4) == 'geo:') {
|
||||
if (is_string($location) && str_starts_with($location, 'geo:')) {
|
||||
preg_match_all(
|
||||
'/([0-9\.\-]+)/',
|
||||
$location,
|
||||
|
@ -109,9 +99,6 @@ class NoteService extends Service
|
|||
|
||||
/**
|
||||
* Get the checkin data from the request to create a new note. This will be a Place.
|
||||
*
|
||||
* @param array $request Data from request()->all()
|
||||
* @return Place|null
|
||||
*/
|
||||
private function getCheckin(array $request): ?Place
|
||||
{
|
||||
|
@ -155,13 +142,10 @@ class NoteService extends Service
|
|||
|
||||
/**
|
||||
* Get the Swarm URL from the syndication data in the request to create a new note.
|
||||
*
|
||||
* @param array $request Data from request()->all()
|
||||
* @return string|null
|
||||
*/
|
||||
private function getSwarmUrl(array $request): ?string
|
||||
{
|
||||
if (stristr(Arr::get($request, 'properties.syndication.0', ''), 'swarmapp')) {
|
||||
if (str_contains(Arr::get($request, 'properties.syndication.0', ''), 'swarmapp')) {
|
||||
return Arr::get($request, 'properties.syndication.0');
|
||||
}
|
||||
|
||||
|
@ -170,9 +154,6 @@ class NoteService extends Service
|
|||
|
||||
/**
|
||||
* Get the syndication targets from the request to create a new note.
|
||||
*
|
||||
* @param array $request Data from request()->all()
|
||||
* @return array
|
||||
*/
|
||||
private function getSyndicationTargets(array $request): array
|
||||
{
|
||||
|
@ -194,9 +175,6 @@ class NoteService extends Service
|
|||
|
||||
/**
|
||||
* Get the media URLs from the request to create a new note.
|
||||
*
|
||||
* @param array $request Data from request()->all()
|
||||
* @return array
|
||||
*/
|
||||
private function getMedia(array $request): array
|
||||
{
|
||||
|
@ -224,9 +202,6 @@ class NoteService extends Service
|
|||
|
||||
/**
|
||||
* Get the Instagram photo URL from the request to create a new note.
|
||||
*
|
||||
* @param array $request Data from request()->all()
|
||||
* @return string|null
|
||||
*/
|
||||
private function getInstagramUrl(array $request): ?string
|
||||
{
|
||||
|
|
|
@ -11,9 +11,6 @@ class PlaceService
|
|||
{
|
||||
/**
|
||||
* Create a place.
|
||||
*
|
||||
* @param array $data
|
||||
* @return Place
|
||||
*/
|
||||
public function createPlace(array $data): Place
|
||||
{
|
||||
|
@ -40,9 +37,6 @@ class PlaceService
|
|||
|
||||
/**
|
||||
* Create a place from a h-card checkin, for example from OwnYourSwarm.
|
||||
*
|
||||
* @param array
|
||||
* @return Place
|
||||
*/
|
||||
public function createPlaceFromCheckin(array $checkin): Place
|
||||
{
|
||||
|
|
|
@ -13,9 +13,6 @@ class TokenService
|
|||
{
|
||||
/**
|
||||
* Generate a JWT token.
|
||||
*
|
||||
* @param array The data to be encoded
|
||||
* @return string The signed token
|
||||
*/
|
||||
public function getNewToken(array $data): string
|
||||
{
|
||||
|
@ -36,9 +33,6 @@ class TokenService
|
|||
|
||||
/**
|
||||
* Check the token signature is valid.
|
||||
*
|
||||
* @param string The token
|
||||
* @return mixed
|
||||
*/
|
||||
public function validateToken(string $bearerToken): Token
|
||||
{
|
||||
|
|
2
artisan
2
artisan
|
@ -11,7 +11,7 @@ define('LARAVEL_START', microtime(true));
|
|||
| Composer provides a convenient, automatically generated class loader
|
||||
| for our application. We just need to utilize it! We'll require it
|
||||
| into the script here so that we do not have to worry about the
|
||||
| loading of any our classes "manually". Feels great to relax.
|
||||
| loading of any of our classes manually. It's great to relax.
|
||||
|
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,14 +13,14 @@
|
|||
"ext-dom": "*",
|
||||
"ext-intl": "*",
|
||||
"ext-json": "*",
|
||||
"cviebrock/eloquent-sluggable": "^9.0",
|
||||
"cviebrock/eloquent-sluggable": "^10.0",
|
||||
"guzzlehttp/guzzle": "^7.0.1",
|
||||
"indieauth/client": "^1.1",
|
||||
"intervention/image": "^2.4",
|
||||
"jonnybarnes/indieweb": "~0.2",
|
||||
"jonnybarnes/webmentions-parser": "~0.5",
|
||||
"jublonet/codebird-php": "4.0.0-beta.1",
|
||||
"laravel/framework": "^9.0",
|
||||
"laravel/framework": "^10.0",
|
||||
"laravel/horizon": "^5.0",
|
||||
"laravel/sanctum": "^3.0",
|
||||
"laravel/tinker": "^2.0",
|
||||
|
@ -40,10 +40,10 @@
|
|||
"laravel/pint": "^1.0.0",
|
||||
"laravel/sail": "^1.15",
|
||||
"mockery/mockery": "^1.0",
|
||||
"nunomaduro/collision": "^6.1",
|
||||
"phpunit/php-code-coverage": "^9.2",
|
||||
"phpunit/phpunit": "^9.0",
|
||||
"spatie/laravel-ignition": "^1.0",
|
||||
"nunomaduro/collision": "^7.0",
|
||||
"phpunit/php-code-coverage": "^10.0",
|
||||
"phpunit/phpunit": "^10.0",
|
||||
"spatie/laravel-ignition": "^2.0",
|
||||
"spatie/laravel-ray": "^1.12",
|
||||
"vimeo/psalm": "^5.0"
|
||||
},
|
||||
|
@ -76,7 +76,7 @@
|
|||
"Tests\\": "tests"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"minimum-stability": "stable",
|
||||
"prefer-stable": true,
|
||||
"scripts": {
|
||||
"post-autoload-dump": [
|
||||
|
|
1339
composer.lock
generated
1339
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -63,7 +63,7 @@ return [
|
|||
| Application Long URL
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The short URL for the application
|
||||
| The long URL for the application
|
||||
|
|
||||
*/
|
||||
|
||||
|
@ -191,7 +191,9 @@ return [
|
|||
|--------------------------------------------------------------------------
|
||||
| Font Link
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Which URL should the app load custom fonts from
|
||||
|
|
||||
*/
|
||||
|
||||
'font_link' => env('FONT_LINK'),
|
||||
|
|
|
@ -84,12 +84,16 @@ return [
|
|||
| considered valid. This security feature keeps tokens short-lived so
|
||||
| they have less time to be guessed. You may change this as needed.
|
||||
|
|
||||
| The throttle setting is the number of seconds a user must wait before
|
||||
| generating more password reset tokens. This prevents the user from
|
||||
| quickly generating a very large amount of password reset tokens.
|
||||
|
|
||||
*/
|
||||
|
||||
'passwords' => [
|
||||
'users' => [
|
||||
'provider' => 'users',
|
||||
'table' => 'password_resets',
|
||||
'table' => 'password_reset_tokens',
|
||||
'expire' => 60,
|
||||
'throttle' => 60,
|
||||
],
|
||||
|
|
|
@ -28,7 +28,7 @@ return [
|
|||
| sending an e-mail. You will specify which one you are using for your
|
||||
| mailers below. You are free to add additional mailers as required.
|
||||
|
|
||||
| Supported: "smtp", "sendmail", "mailgun", "ses",
|
||||
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
|
||||
| "postmark", "log", "array", "failover"
|
||||
|
|
||||
*/
|
||||
|
@ -51,10 +51,16 @@ return [
|
|||
|
||||
'mailgun' => [
|
||||
'transport' => 'mailgun',
|
||||
// 'client' => [
|
||||
// 'timeout' => 5,
|
||||
// ],
|
||||
],
|
||||
|
||||
'postmark' => [
|
||||
'transport' => 'postmark',
|
||||
// 'client' => [
|
||||
// 'timeout' => 5,
|
||||
// ],
|
||||
],
|
||||
|
||||
'sendmail' => [
|
||||
|
|
|
@ -6,6 +6,9 @@ use App\Models\Article;
|
|||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Article>
|
||||
*/
|
||||
class ArticleFactory extends Factory
|
||||
{
|
||||
/**
|
||||
|
@ -18,9 +21,9 @@ class ArticleFactory extends Factory
|
|||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'titleurl' => $this->faker->slug(3),
|
||||
|
|
|
@ -6,6 +6,9 @@ use App\Models\Bookmark;
|
|||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Bookmark>
|
||||
*/
|
||||
class BookmarkFactory extends Factory
|
||||
{
|
||||
/**
|
||||
|
@ -18,9 +21,9 @@ class BookmarkFactory extends Factory
|
|||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
public function definition(): array
|
||||
{
|
||||
$now = Carbon::now()->subDays(rand(5, 15));
|
||||
|
||||
|
|
|
@ -6,6 +6,9 @@ use App\Models\Contact;
|
|||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Contact>
|
||||
*/
|
||||
class ContactFactory extends Factory
|
||||
{
|
||||
/**
|
||||
|
@ -18,9 +21,9 @@ class ContactFactory extends Factory
|
|||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'nick' => mb_strtolower($this->faker->firstName),
|
||||
|
|
|
@ -6,6 +6,9 @@ use App\Models\Like;
|
|||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Like>
|
||||
*/
|
||||
class LikeFactory extends Factory
|
||||
{
|
||||
/**
|
||||
|
@ -18,9 +21,9 @@ class LikeFactory extends Factory
|
|||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
public function definition(): array
|
||||
{
|
||||
$now = Carbon::now()->subDays(rand(5, 15));
|
||||
|
||||
|
|
|
@ -6,6 +6,9 @@ use App\Models\Media;
|
|||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Media>
|
||||
*/
|
||||
class MediaFactory extends Factory
|
||||
{
|
||||
/**
|
||||
|
@ -18,9 +21,9 @@ class MediaFactory extends Factory
|
|||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'path' => 'media/' . $this->faker->uuid . '.jpg',
|
||||
|
|
|
@ -5,6 +5,9 @@ namespace Database\Factories;
|
|||
use App\Models\MicropubClient;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\MicropubClient>
|
||||
*/
|
||||
class MicropubClientFactory extends Factory
|
||||
{
|
||||
/**
|
||||
|
@ -17,9 +20,9 @@ class MicropubClientFactory extends Factory
|
|||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'client_url' => $this->faker->url,
|
||||
|
|
|
@ -7,6 +7,9 @@ use Exception;
|
|||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Note>
|
||||
*/
|
||||
class NoteFactory extends Factory
|
||||
{
|
||||
/**
|
||||
|
@ -19,11 +22,11 @@ class NoteFactory extends Factory
|
|||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, mixed>
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function definition()
|
||||
public function definition(): array
|
||||
{
|
||||
$now = Carbon::now()->subDays(random_int(5, 15));
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@ namespace Database\Factories;
|
|||
use App\Models\Place;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Place>
|
||||
*/
|
||||
class PlaceFactory extends Factory
|
||||
{
|
||||
/**
|
||||
|
@ -17,9 +20,9 @@ class PlaceFactory extends Factory
|
|||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->company,
|
||||
|
|
|
@ -14,7 +14,7 @@ class SyndicationTargetFactory extends Factory
|
|||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'uid' => $this->faker->url,
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue