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
|
@ -6,6 +6,7 @@ use App\Models\Like;
|
|||
use App\Models\Note;
|
||||
use App\Models\Article;
|
||||
use App\Models\Bookmark;
|
||||
use App\Services\ActivityStreamsService;
|
||||
|
||||
class FrontPageController extends Controller
|
||||
{
|
||||
|
@ -14,6 +15,10 @@ class FrontPageController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
if (request()->wantsActivityStream()) {
|
||||
return (new ActivityStreamsService())->siteOwnerResponse();
|
||||
}
|
||||
|
||||
$pageNumber = request()->query('page') ?? 1;
|
||||
|
||||
$notes = Note::latest()->get();
|
||||
|
|
|
@ -5,7 +5,9 @@ declare(strict_types=1);
|
|||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Like;
|
||||
use Codebird\Codebird;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Thujohn\Twitter\Facades\Twitter;
|
||||
|
@ -19,14 +21,18 @@ use Jonnybarnes\WebmentionsParser\Exceptions\AuthorshipParserException;
|
|||
|
||||
class ProcessLike implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
use Dispatchable;
|
||||
use InteractsWithQueue;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/** @var Like */
|
||||
protected $like;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param \App\Models\Like $like
|
||||
* @param Like $like
|
||||
*/
|
||||
public function __construct(Like $like)
|
||||
{
|
||||
|
@ -36,14 +42,18 @@ class ProcessLike implements ShouldQueue
|
|||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @param \GuzzleHttp\Client $client
|
||||
* @param \Jonnybarnes\WebmentionsParser\Authorship $authorship
|
||||
* @param Client $client
|
||||
* @param Authorship $authorship
|
||||
* @return int
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function handle(Client $client, Authorship $authorship): int
|
||||
{
|
||||
if ($this->isTweet($this->like->url)) {
|
||||
$tweet = Twitter::getOembed(['url' => $this->like->url]);
|
||||
$codebird = resolve(Codebird::class);
|
||||
|
||||
$tweet = $codebird->statuses_oembed(['url' => $this->like->url]);
|
||||
|
||||
$this->like->author_name = $tweet->author_name;
|
||||
$this->like->author_url = $tweet->author_url;
|
||||
$this->like->content = $tweet->html;
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -12,11 +12,11 @@ class NoteObserver
|
|||
/**
|
||||
* Listen to the Note created event.
|
||||
*
|
||||
* @param \App\Note $note
|
||||
* @param Note $note
|
||||
*/
|
||||
public function created(Note $note)
|
||||
{
|
||||
$text = array_get($note->getAttributes(), 'note');
|
||||
$text = Arr::get($note->getAttributes(), 'note');
|
||||
if ($text === null) {
|
||||
return;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class NoteObserver
|
|||
/**
|
||||
* Listen to the Note updated event.
|
||||
*
|
||||
* @param \App\Note $Note
|
||||
* @param Note $note
|
||||
*/
|
||||
public function updated(Note $note)
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ class NoteObserver
|
|||
/**
|
||||
* Listen to the Note deleting event.
|
||||
*
|
||||
* @param \App\Note $note
|
||||
* @param Note $note
|
||||
*/
|
||||
public function deleting(Note $note)
|
||||
{
|
||||
|
@ -72,8 +72,8 @@ class NoteObserver
|
|||
/**
|
||||
* Retrieve the tags from a note’s text, tag for form #tag.
|
||||
*
|
||||
* @param string $note
|
||||
* @return \Illuminate\Support\Collection
|
||||
* @param string $note
|
||||
* @return Collection
|
||||
*/
|
||||
private function getTagsFromNote(string $note): Collection
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Providers;
|
||||
|
||||
use App\Models\Note;
|
||||
use Codebird\Codebird;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Observers\NoteObserver;
|
||||
|
@ -29,6 +30,23 @@ class AppServiceProvider extends ServiceProvider
|
|||
$this->app->bind('Intervention\Image\ImageManager', function () {
|
||||
return new \Intervention\Image\ImageManager(['driver' => config('image.driver')]);
|
||||
});
|
||||
|
||||
// Bind the Codebird client
|
||||
$this->app->bind('Codebird\Codebird', function () {
|
||||
Codebird::setConsumerKey(
|
||||
env('TWITTER_CONSUMER_KEY'),
|
||||
env('TWITTER_CONSUMER_SECRET')
|
||||
);
|
||||
|
||||
$cb = Codebird::getInstance();
|
||||
|
||||
$cb->setToken(
|
||||
env('TWITTER_ACCESS_TOKEN'),
|
||||
env('TWITTER_ACCESS_TOKEN_SECRET')
|
||||
);
|
||||
|
||||
return $cb;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue