Merge pull request #4276 from pixelfed/staging

Staging
This commit is contained in:
daniel 2023-04-03 19:47:31 -06:00 committed by GitHub
commit 21685d0baf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 32 additions and 16 deletions

View file

@ -532,7 +532,7 @@ class AdminController extends Controller
$emoji->save(); $emoji->save();
$fileName = $emoji->id . '.' . $request->emoji->extension(); $fileName = $emoji->id . '.' . $request->emoji->extension();
$request->emoji->storeAs('public/emoji', $fileName); $request->emoji->storePubliclyAs('public/emoji', $fileName);
$emoji->media_path = 'emoji/' . $fileName; $emoji->media_path = 'emoji/' . $fileName;
$emoji->save(); $emoji->save();
Cache::forget('pf:custom_emoji'); Cache::forget('pf:custom_emoji');

View file

@ -260,7 +260,7 @@ class ApiV1Controller extends Controller
$file = $request->file('avatar'); $file = $request->file('avatar');
$path = "public/avatars/{$profile->id}"; $path = "public/avatars/{$profile->id}";
$name = strtolower(str_random(6)). '.' . $file->guessExtension(); $name = strtolower(str_random(6)). '.' . $file->guessExtension();
$request->file('avatar')->storeAs($path, $name); $request->file('avatar')->storePubliclyAs($path, $name);
$av->media_path = "{$path}/{$name}"; $av->media_path = "{$path}/{$name}";
$av->save(); $av->save();
Cache::forget("avatar:{$profile->id}"); Cache::forget("avatar:{$profile->id}");
@ -1610,7 +1610,7 @@ class ApiV1Controller extends Controller
} }
$storagePath = MediaPathService::get($user, 2); $storagePath = MediaPathService::get($user, 2);
$path = $photo->store($storagePath); $path = $photo->storePublicly($storagePath);
$hash = \hash_file('sha256', $photo); $hash = \hash_file('sha256', $photo);
$license = null; $license = null;
$mime = $photo->getMimeType(); $mime = $photo->getMimeType();
@ -1815,7 +1815,7 @@ class ApiV1Controller extends Controller
} }
$storagePath = MediaPathService::get($user, 2); $storagePath = MediaPathService::get($user, 2);
$path = $photo->store($storagePath); $path = $photo->storePublicly($storagePath);
$hash = \hash_file('sha256', $photo); $hash = \hash_file('sha256', $photo);
$license = null; $license = null;
$mime = $photo->getMimeType(); $mime = $photo->getMimeType();
@ -2501,6 +2501,8 @@ class ApiV1Controller extends Controller
} }
if($status['replies_count']) { if($status['replies_count']) {
$filters = UserFilterService::filters($pid);
$descendants = DB::table('statuses') $descendants = DB::table('statuses')
->where('in_reply_to_id', $id) ->where('in_reply_to_id', $id)
->limit(20) ->limit(20)
@ -2508,8 +2510,8 @@ class ApiV1Controller extends Controller
->map(function($sid) { ->map(function($sid) {
return StatusService::getMastodon($sid, false); return StatusService::getMastodon($sid, false);
}) })
->filter(function($post) { ->filter(function($post) use($filters) {
return $post && isset($post['account']); return $post && isset($post['account'], $post['account']['id']) && !in_array($post['account']['id'], $filters);
}) })
->map(function($status) use($pid) { ->map(function($status) use($pid) {
$status['favourited'] = LikeService::liked($pid, $status['id']); $status['favourited'] = LikeService::liked($pid, $status['id']);
@ -3358,7 +3360,11 @@ class ApiV1Controller extends Controller
->cursorPaginate($limit); ->cursorPaginate($limit);
} }
$data = $ids->map(function($post) use($pid) { $filters = UserFilterService::filters($pid);
$data = $ids->filter(function($post) use($filters) {
return !in_array($post->profile_id, $filters);
})
->map(function($post) use($pid) {
$status = StatusService::get($post->id, false); $status = StatusService::get($post->id, false);
if(!$status || !isset($status['id'])) { if(!$status || !isset($status['id'])) {

View file

@ -112,7 +112,7 @@ class BaseApiController extends Controller
$name = $path['name']; $name = $path['name'];
$public = $path['storage']; $public = $path['storage'];
$currentAvatar = storage_path('app/'.$profile->avatar->media_path); $currentAvatar = storage_path('app/'.$profile->avatar->media_path);
$loc = $request->file('upload')->storeAs($public, $name); $loc = $request->file('upload')->storePubliclyAs($public, $name);
$avatar = Avatar::whereProfileId($profile->id)->firstOrFail(); $avatar = Avatar::whereProfileId($profile->id)->firstOrFail();
$opath = $avatar->media_path; $opath = $avatar->media_path;

View file

@ -30,7 +30,7 @@ class AvatarController extends Controller
$dir = $path['root']; $dir = $path['root'];
$name = $path['name']; $name = $path['name'];
$public = $path['storage']; $public = $path['storage'];
$loc = $request->file('avatar')->storeAs($public, $name); $loc = $request->file('avatar')->storePubliclyAs($public, $name);
$avatar = Avatar::firstOrNew(['profile_id' => $profile->id]); $avatar = Avatar::firstOrNew(['profile_id' => $profile->id]);
$currentAvatar = $avatar->recentlyCreated ? null : storage_path('app/'.$profile->avatar->media_path); $currentAvatar = $avatar->recentlyCreated ? null : storage_path('app/'.$profile->avatar->media_path);

View file

@ -123,7 +123,7 @@ class ComposeController extends Controller
abort_if(in_array($photo->getMimeType(), $mimes) == false, 400, 'Invalid media format'); abort_if(in_array($photo->getMimeType(), $mimes) == false, 400, 'Invalid media format');
$storagePath = MediaPathService::get($user, 2); $storagePath = MediaPathService::get($user, 2);
$path = $photo->store($storagePath); $path = $photo->storePublicly($storagePath);
$hash = \hash_file('sha256', $photo); $hash = \hash_file('sha256', $photo);
$mime = $photo->getMimeType(); $mime = $photo->getMimeType();
@ -209,7 +209,7 @@ class ComposeController extends Controller
$name = last($fragments); $name = last($fragments);
array_pop($fragments); array_pop($fragments);
$dir = implode('/', $fragments); $dir = implode('/', $fragments);
$path = $photo->storeAs($dir, $name); $path = $photo->storePubliclyAs($dir, $name);
$res = [ $res = [
'url' => $media->url() . '?v=' . time() 'url' => $media->url() . '?v=' . time()
]; ];

View file

@ -602,7 +602,7 @@ class DirectMessageController extends Controller
} }
$storagePath = MediaPathService::get($user, 2) . Str::random(8); $storagePath = MediaPathService::get($user, 2) . Str::random(8);
$path = $photo->store($storagePath); $path = $photo->storePublicly($storagePath);
$hash = \hash_file('sha256', $photo); $hash = \hash_file('sha256', $photo);
abort_if(MediaBlocklistService::exists($hash) == true, 451); abort_if(MediaBlocklistService::exists($hash) == true, 451);

View file

@ -93,7 +93,7 @@ trait Instagram
continue; continue;
} }
$storagePath = "import/{$job->uuid}"; $storagePath = "import/{$job->uuid}";
$path = $v->store($storagePath); $path = $v->storePublicly($storagePath);
DB::transaction(function() use ($profile, $job, $path, $original) { DB::transaction(function() use ($profile, $job, $path, $original) {
$data = new ImportData; $data = new ImportData;
$data->profile_id = $profile->id; $data->profile_id = $profile->id;
@ -141,7 +141,7 @@ trait Instagram
return abort(500); return abort(500);
} }
$storagePath = "import/{$job->uuid}"; $storagePath = "import/{$job->uuid}";
$path = $media->store($storagePath); $path = $media->storePublicly($storagePath);
$job->media_json = $path; $job->media_json = $path;
$job->stage = 3; $job->stage = 3;
$job->save(); $job->save();

View file

@ -354,7 +354,7 @@ class StoryApiV1Controller extends Controller
} }
$storagePath = MediaPathService::story($user->profile); $storagePath = MediaPathService::story($user->profile);
$path = $photo->storeAs($storagePath, Str::random(random_int(2, 12)) . '_' . Str::random(random_int(32, 35)) . '_' . Str::random(random_int(1, 14)) . '.' . $photo->extension()); $path = $photo->storePubliclyAs($storagePath, Str::random(random_int(2, 12)) . '_' . Str::random(random_int(32, 35)) . '_' . Str::random(random_int(1, 14)) . '.' . $photo->extension());
return $path; return $path;
} }
} }

View file

@ -111,7 +111,7 @@ class StoryComposeController extends Controller
} }
$storagePath = MediaPathService::story($user->profile); $storagePath = MediaPathService::story($user->profile);
$path = $photo->storeAs($storagePath, Str::random(random_int(2, 12)) . '_' . Str::random(random_int(32, 35)) . '_' . Str::random(random_int(1, 14)) . '.' . $photo->extension()); $path = $photo->storePubliclyAs($storagePath, Str::random(random_int(2, 12)) . '_' . Str::random(random_int(32, 35)) . '_' . Str::random(random_int(1, 14)) . '.' . $photo->extension());
if(in_array($photo->getMimeType(), ['image/jpeg','image/png'])) { if(in_array($photo->getMimeType(), ['image/jpeg','image/png'])) {
$fpath = storage_path('app/' . $path); $fpath = storage_path('app/' . $path);
$img = Intervention::make($fpath); $img = Intervention::make($fpath);

View file

@ -46,6 +46,16 @@ return [
'local' => [ 'local' => [
'driver' => 'local', 'driver' => 'local',
'root' => storage_path('app'), 'root' => storage_path('app'),
'permissions' => [
'file' => [
'public' => 0644,
'private' => 0600,
],
'dir' => [
'public' => 0755,
'private' => 0700,
],
],
], ],
'public' => [ 'public' => [