Merge pull request #1551 from pixelfed/frontend-ui-refactor

Frontend ui refactor
This commit is contained in:
daniel 2019-07-26 20:20:21 -06:00 committed by GitHub
commit 54b3ab489b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 63 additions and 25 deletions

View File

@ -2,6 +2,7 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use DB;
use App\Jobs\ImageOptimizePipeline\ImageOptimize; use App\Jobs\ImageOptimizePipeline\ImageOptimize;
use App\Media; use App\Media;
use Illuminate\Console\Command; use Illuminate\Console\Command;
@ -39,9 +40,19 @@ class CatchUnoptimizedMedia extends Command
*/ */
public function handle() public function handle()
{ {
$medias = Media::whereNotNull('status_id')->whereNull('processed_at')->take(250)->get(); DB::transaction(function() {
foreach ($medias as $media) { Media::whereNull('processed_at')
ImageOptimize::dispatch($media); ->whereNotNull('status_id')
} ->whereNotNull('media_path')
->whereIn('mime', [
'image/jpeg',
'image/png',
])
->chunk(50, function($medias) {
foreach ($medias as $media) {
ImageOptimize::dispatch($media);
}
});
});
} }
} }

View File

@ -388,7 +388,10 @@ class Helpers {
if($local == true) { if($local == true) {
$id = last(explode('/', $url)); $id = last(explode('/', $url));
return Profile::whereUsername($id)->firstOrFail(); return Profile::whereNull('status')
->whereNull('domain')
->whereUsername($id)
->firstOrFail();
} }
$res = self::fetchProfileFromUrl($url); $res = self::fetchProfileFromUrl($url);
if(isset($res['id']) == false) { if(isset($res['id']) == false) {

View File

@ -15,6 +15,7 @@ use App\{
use Carbon\Carbon; use Carbon\Carbon;
use App\Util\ActivityPub\Helpers; use App\Util\ActivityPub\Helpers;
use App\Jobs\LikePipeline\LikePipeline; use App\Jobs\LikePipeline\LikePipeline;
use App\Jobs\FollowPipeline\FollowPipeline;
use App\Util\ActivityPub\Validator\{ use App\Util\ActivityPub\Validator\{
Accept, Accept,
@ -243,28 +244,40 @@ class Inbox
public function handleAcceptActivity() public function handleAcceptActivity()
{ {
$actor = $this->payload['actor'];
$obj = $this->payload['object'];
switch ($obj['type']) {
case 'Follow':
$accept = [
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => $target->permalink().'#accepts/follows/' . $follower->id,
'type' => 'Accept',
'actor' => $target->permalink(),
'object' => [
'id' => $actor->permalink('#follows/'.$target->id),
'type' => 'Follow',
'actor' => $actor->permalink(),
'object' => $target->permalink()
]
];
break;
default: $actor = $this->payload['actor'];
# code... $obj = $this->payload['object']['object'];
break; $type = $this->payload['object']['type'];
if($type !== 'Follow') {
return;
} }
$actor = Helpers::validateUrl($actor);
$target = Helpers::validateLocalUrl($obj);
if(!$actor || !$target) {
return;
}
$actor = Helpers::profileFetch($actor);
$target = Helpers::profileFetch($target);
$request = FollowRequest::whereFollowerId($actor->id)
->whereFollowingId($target->id)
->whereIsRejected(false)
->first();
if(!$request) {
return;
}
$follower = new Follower();
$follower->profile_id = $actor->id;
$follower->following_id = $target->id;
$follower->save();
FollowPipeline::dispatch($follower);
$request->delete();
} }
public function handleDeleteActivity() public function handleDeleteActivity()

View File

@ -8,6 +8,17 @@
<div class="text-center"> <div class="text-center">
<h1>Collection</h1> <h1>Collection</h1>
<h4 class="text-muted">{{$collection->title}}</h4> <h4 class="text-muted">{{$collection->title}}</h4>
@auth
@if($collection->profile_id == Auth::user()->profile_id)
<div class="text-right">
<form method="post" action="/api/local/collection/{{$collection->id}}">
@csrf
<input type="hidden" name="_method" value="DELETE">
<button type="submit" class="btn btn-outline-danger font-weight-bold btn-sm py-1">Delete</button>
</form>
</div>
@endif
@endauth
</div> </div>
</div> </div>
<div class="col-12"> <div class="col-12">