Merge pull request #2621 from pixelfed/staging

Staging
This commit is contained in:
daniel 2021-02-05 21:12:12 -07:00 committed by GitHub
commit ec5646d098
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 96 additions and 34 deletions

View file

@ -27,6 +27,10 @@
- Updated AccountController, add mutes and blocks endpoint to pixelfed api. ([1fb7e2b2](https://github.com/pixelfed/pixelfed/commit/1fb7e2b2))
- Updated AccountService, cache object and observe changes. ([b299da93](https://github.com/pixelfed/pixelfed/commit/b299da93))
- Updated webfinger util, fail on invalid webfinger url. Fixes ([#2613](https://github.com/pixelfed/pixelfed/issues/2613)) ([2d11317c](https://github.com/pixelfed/pixelfed/commit/2d11317c))
- Updated MediaStorageService, dispatch deletes to MediaDeletePipeline. ([37dbb3de](https://github.com/pixelfed/pixelfed/commit/37dbb3de))
- Updated ComposeController, use MediaStorageService for media deletes. ([ab5469ff](https://github.com/pixelfed/pixelfed/commit/ab5469ff))
- Updated StatusDeletePipeline, use MediaStorageService for media deletes. ([9fd90e17](https://github.com/pixelfed/pixelfed/commit/9fd90e17))
- Updated Discover, allow public discover access. ([1404ac6e](https://github.com/pixelfed/pixelfed/commit/1404ac6e))
- ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.10.10 (2021-01-28)](https://github.com/pixelfed/pixelfed/compare/v0.10.9...v0.10.10)

View file

@ -38,6 +38,7 @@ use App\Jobs\VideoPipeline\{
use App\Services\NotificationService;
use App\Services\MediaPathService;
use App\Services\MediaBlocklistService;
use App\Services\MediaStorageService;
use App\Services\MediaTagService;
use App\Services\ServiceService;
use Illuminate\Support\Str;
@ -193,8 +194,7 @@ class ComposeController extends Controller
->whereUserId(Auth::id())
->findOrFail($request->input('id'));
Storage::delete($media->media_path);
Storage::delete($media->thumbnail_path);
MediaStorageService::delete($media, true);
$media->forceDelete();
@ -388,6 +388,7 @@ class ComposeController extends Controller
}
$status->caption = strip_tags($request->caption);
$status->rendered = Autolink::create()->autolink($status->caption);
$status->scope = 'draft';
$status->profile_id = $profile->id;
$status->save();

View file

@ -37,7 +37,7 @@ class DiscoverController extends Controller
public function home(Request $request)
{
abort_if(!Auth::check(), 403);
abort_if(!Auth::check() && config('instance.discover.public') == false, 403);
return view('discover.home');
}
@ -113,6 +113,8 @@ class DiscoverController extends Controller
public function trendingApi(Request $request)
{
abort_if(config('instance.discover.public') == false && !Auth::check(), 403);
$this->validate($request, [
'range' => 'nullable|string|in:daily,monthly'
]);

View file

@ -0,0 +1,67 @@
<?php
namespace App\Jobs\MediaPipeline;
use App\Media;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\Storage;
class MediaDeletePipeline implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $media;
public function __construct(Media $media)
{
$this->media = $media;
}
public function handle()
{
$media = $this->media;
$path = $media->media_path;
$thumb = $media->thumbnail_path;
if(!$path) {
return 1;
}
$e = explode('/', $path);
array_pop($e);
$i = implode('/', $e);
if(config('pixelfed.cloud_storage') == true) {
$disk = Storage::disk(config('filesystems.cloud'));
if($disk->exists($path)) {
$disk->delete($path);
}
if($disk->exists($thumb)) {
$disk->delete($thumb);
}
if(count($e) > 4 && count($disk->files($i)) == 0) {
$disk->deleteDirectory($i);
}
}
$disk = Storage::disk(config('filesystems.local'));
if($disk->exists($path)) {
$disk->delete($path);
}
if($disk->exists($thumb)) {
$disk->delete($thumb);
}
if(count($e) > 4 && count($disk->files($i)) == 0) {
$disk->deleteDirectory($i);
}
return 1;
}
}

View file

@ -26,6 +26,7 @@ use GuzzleHttp\Client;
use GuzzleHttp\Promise;
use App\Util\ActivityPub\HttpSignature;
use App\Services\StatusService;
use App\Services\MediaStorageService;
class StatusDelete implements ShouldQueue
{
@ -82,38 +83,9 @@ class StatusDelete implements ShouldQueue
public function unlinkRemoveMedia($status)
{
foreach ($status->media as $media) {
$thumbnail = storage_path("app/{$media->thumbnail_path}");
$photo = storage_path("app/{$media->media_path}");
try {
if (is_file($thumbnail)) {
unlink($thumbnail);
}
if (is_file($photo)) {
unlink($photo);
}
if( config('pixelfed.cloud_storage') == true) {
if( Str::of($media->media_path)
->startsWith('public/') &&
Storage::disk(config('filesystems.cloud'))
->exists($media->media_path)
) {
Storage::disk(config('filesystems.cloud'))
->delete($media->media_path);
}
if( Str::of($media->thumbnail_path)
->startsWith('public/') &&
Storage::disk(config('filesystems.cloud'))
->exists($media->thumbnail_path)
) {
Storage::disk(config('filesystems.cloud'))
->delete($media->thumbnail_path);
}
}
$media->delete();
} catch (Exception $e) {
}
MediaStorageService::delete($media, true);
}
if($status->in_reply_to_id) {
DB::transaction(function() use($status) {
$parent = Status::findOrFail($status->in_reply_to_id);

View file

@ -14,6 +14,7 @@ use App\User;
use GuzzleHttp\Client;
use App\Http\Controllers\AvatarController;
use GuzzleHttp\Exception\RequestException;
use App\Jobs\MediaPipeline\MediaDeletePipeline;
class MediaStorageService {
@ -227,4 +228,12 @@ class MediaStorageService {
unlink($tmpName);
}
public static function delete(Media $media, $confirm = false)
{
if(!$confirm) {
return;
}
MediaDeletePipeline::dispatch($media);
}
}

View file

@ -18,6 +18,12 @@ class Bouncer {
$exemptionKey = 'pf:bouncer_v0:exemption_by_pid:' . $status->profile_id;
$exemptionTtl = now()->addDays(12);
if( $status->in_reply_to_id != null &&
$status->in_reply_to_profile_id == $status->profile_id
) {
return;
}
$exemption = Cache::remember($exemptionKey, $exemptionTtl, function() use($status) {
$uid = $status->profile->user_id;
$ids = AccountInterstitial::whereUserId($uid)

View file

@ -10,6 +10,7 @@ return [
],
'discover' => [
'public' => env('INSTANCE_DISCOVER_PUBLIC', false),
'loops' => [
'enabled' => env('EXP_LOOPS', false),
],