Ooof, got the dependencies all up to date as well
Lots of tests needed fixing, but it seemed to be a whitespace parsing
error in the view files 🤔
This commit is contained in:
parent
ec01b3c6a2
commit
b2b6693aec
61 changed files with 2057 additions and 1441 deletions
|
@ -5,6 +5,12 @@ declare(strict_types=1);
|
|||
namespace App\Models;
|
||||
|
||||
use Cache;
|
||||
use Codebird\Codebird;
|
||||
use Exception;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Twitter;
|
||||
use Normalizer;
|
||||
use GuzzleHttp\Client;
|
||||
|
@ -29,7 +35,7 @@ class Note extends Model
|
|||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The reges for matching lone usernames.
|
||||
* The regex for matching lone usernames.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
@ -79,7 +85,7 @@ class Note extends Model
|
|||
/**
|
||||
* Define the relationship with tags.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function tags()
|
||||
{
|
||||
|
@ -89,7 +95,7 @@ class Note extends Model
|
|||
/**
|
||||
* Define the relationship with clients.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function client()
|
||||
{
|
||||
|
@ -99,7 +105,7 @@ class Note extends Model
|
|||
/**
|
||||
* Define the relationship with webmentions.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function webmentions()
|
||||
{
|
||||
|
@ -109,7 +115,7 @@ class Note extends Model
|
|||
/**
|
||||
* Define the relationship with places.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function place()
|
||||
{
|
||||
|
@ -119,7 +125,7 @@ class Note extends Model
|
|||
/**
|
||||
* Define the relationship with media.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
* @return HasMany
|
||||
*/
|
||||
public function media()
|
||||
{
|
||||
|
@ -346,13 +352,18 @@ class Note extends Model
|
|||
}
|
||||
|
||||
try {
|
||||
$oEmbed = Twitter::getOembed([
|
||||
$codebird = resolve(Codebird::class);
|
||||
$oEmbed = $codebird->statuses_oembed([
|
||||
'url' => $this->in_reply_to,
|
||||
'dnt' => true,
|
||||
'align' => 'center',
|
||||
'maxwidth' => 512,
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
if ($oEmbed->httpstatus >= 400) {
|
||||
throw new Exception();
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return null;
|
||||
}
|
||||
Cache::put($tweetId, $oEmbed, ($oEmbed->cache_age));
|
||||
|
|
|
@ -4,12 +4,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use Cache;
|
||||
use Twitter;
|
||||
use App\Traits\FilterHtml;
|
||||
use Codebird\Codebird;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Jonnybarnes\WebmentionsParser\Authorship;
|
||||
use Jonnybarnes\WebmentionsParser\Exceptions\AuthorshipParserException;
|
||||
|
||||
class WebMention extends Model
|
||||
{
|
||||
|
@ -32,7 +34,7 @@ class WebMention extends Model
|
|||
/**
|
||||
* Define the relationship.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
||||
* @return MorphTo
|
||||
*/
|
||||
public function commentable()
|
||||
{
|
||||
|
@ -43,12 +45,14 @@ class WebMention extends Model
|
|||
* Get the author of the webmention.
|
||||
*
|
||||
* @return array
|
||||
* @throws AuthorshipParserException
|
||||
*/
|
||||
public function getAuthorAttribute(): array
|
||||
{
|
||||
$authorship = new Authorship();
|
||||
$hCard = $authorship->findAuthor(json_decode($this->mf2, true));
|
||||
if (array_key_exists('properties', $hCard) &&
|
||||
if (
|
||||
array_key_exists('properties', $hCard) &&
|
||||
array_key_exists('photo', $hCard['properties'])
|
||||
) {
|
||||
$hCard['properties']['photo'][0] = $this->createPhotoLink($hCard['properties']['photo'][0]);
|
||||
|
@ -118,7 +122,8 @@ class WebMention extends Model
|
|||
return Cache::get($url);
|
||||
}
|
||||
$username = ltrim(parse_url($url, PHP_URL_PATH), '/');
|
||||
$info = Twitter::getUsers(['screen_name' => $username]);
|
||||
$codebird = resolve(Codebird::class);
|
||||
$info = $codebird->users_show(['screen_name' => $username]);
|
||||
$profile_image = $info->profile_image_url_https;
|
||||
Cache::put($url, $profile_image, 10080); //1 week
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue