Upgrade to Laravel 10

This commit is contained in:
Jonny Barnes 2023-02-18 09:34:57 +00:00
parent c4d7dc31d5
commit 16b120bc73
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8
142 changed files with 1676 additions and 2019 deletions

View file

@ -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,10 +27,8 @@ class ActivityStreamsService
/**
* Return the relevant data to an AS2.0 request for a particular 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',

View file

@ -19,8 +19,6 @@ class BookmarkService extends Service
{
/**
* Create a new Bookmark.
*
* @param array $request Data from request()->all()
*/
public function create(array $request, ?string $client = null): Bookmark
{
@ -74,7 +72,6 @@ class BookmarkService extends Service
/**
* Given a URL, attempt to save it to the Internet Archive.
*
*
* @throws InternetArchiveException
*/
public function getArchiveLink(string $url): string

View file

@ -12,8 +12,6 @@ class LikeService extends Service
{
/**
* Create a new Like.
*
* @return Like $like
*/
public function create(array $request, ?string $client = null): Like
{

View file

@ -11,8 +11,6 @@ class HCardService
{
/**
* Create a Place from h-card data, return the URL.
*
* @param array $request Data from request()->all()
*/
public function process(array $request): string
{
@ -28,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;
}
}

View file

@ -13,10 +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
* Create the relevant model from some h-entry data.
*/
public function process(array $request, ?string $client = null): ?string
{

View file

@ -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();

View file

@ -18,8 +18,6 @@ class NoteService extends Service
{
/**
* Create a new note.
*
* @param array $request Data from request()->all()
*/
public function create(array $request, ?string $client = null): Note
{
@ -66,8 +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()
*/
private function getPublished(array $request): ?string
{
@ -84,13 +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()
*/
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,
@ -105,8 +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()
*/
private function getCheckin(array $request): ?Place
{
@ -150,12 +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()
*/
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');
}
@ -164,8 +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()
*/
private function getSyndicationTargets(array $request): array
{
@ -187,8 +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()
*/
private function getMedia(array $request): array
{
@ -216,8 +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()
*/
private function getInstagramUrl(array $request): ?string
{

View file

@ -37,8 +37,6 @@ class PlaceService
/**
* Create a place from a h-card checkin, for example from OwnYourSwarm.
*
* @param array
*/
public function createPlaceFromCheckin(array $checkin): Place
{

View file

@ -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
{