mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 15:55:22 +00:00
Update AvatarController, remove deprecated thumb_path
This commit is contained in:
parent
1e9958f521
commit
889c3d8758
5 changed files with 1 additions and 20 deletions
|
@ -183,7 +183,6 @@ class BaseApiController extends Controller
|
||||||
$avatar = Avatar::whereProfileId($profile->id)->firstOrFail();
|
$avatar = Avatar::whereProfileId($profile->id)->firstOrFail();
|
||||||
$opath = $avatar->media_path;
|
$opath = $avatar->media_path;
|
||||||
$avatar->media_path = "$public/$name";
|
$avatar->media_path = "$public/$name";
|
||||||
$avatar->thumb_path = null;
|
|
||||||
$avatar->change_count = ++$avatar->change_count;
|
$avatar->change_count = ++$avatar->change_count;
|
||||||
$avatar->last_processed_at = null;
|
$avatar->last_processed_at = null;
|
||||||
$avatar->save();
|
$avatar->save();
|
||||||
|
|
|
@ -35,7 +35,6 @@ class AvatarController extends Controller
|
||||||
$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);
|
||||||
$avatar->media_path = "$public/$name";
|
$avatar->media_path = "$public/$name";
|
||||||
$avatar->thumb_path = null;
|
|
||||||
$avatar->change_count = ++$avatar->change_count;
|
$avatar->change_count = ++$avatar->change_count;
|
||||||
$avatar->last_processed_at = null;
|
$avatar->last_processed_at = null;
|
||||||
$avatar->save();
|
$avatar->save();
|
||||||
|
@ -121,10 +120,7 @@ class AvatarController extends Controller
|
||||||
$avatar = $profile->avatar;
|
$avatar = $profile->avatar;
|
||||||
|
|
||||||
if( $avatar->media_path == 'public/avatars/default.png' ||
|
if( $avatar->media_path == 'public/avatars/default.png' ||
|
||||||
$avatar->thumb_path == 'public/avatars/default.png' ||
|
$avatar->media_path == 'public/avatars/default.jpg'
|
||||||
$avatar->media_path == 'public/avatars/default.jpg' ||
|
|
||||||
$avatar->thumb_path == 'public/avatars/default.jpg'
|
|
||||||
|
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -133,12 +129,7 @@ class AvatarController extends Controller
|
||||||
@unlink(storage_path('app/' . $avatar->media_path));
|
@unlink(storage_path('app/' . $avatar->media_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_file(storage_path('app/' . $avatar->thumb_path))) {
|
|
||||||
@unlink(storage_path('app/' . $avatar->thumb_path));
|
|
||||||
}
|
|
||||||
|
|
||||||
$avatar->media_path = 'public/avatars/default.jpg';
|
$avatar->media_path = 'public/avatars/default.jpg';
|
||||||
$avatar->thumb_path = 'public/avatars/default.jpg';
|
|
||||||
$avatar->change_count = $avatar->change_count + 1;
|
$avatar->change_count = $avatar->change_count + 1;
|
||||||
$avatar->save();
|
$avatar->save();
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,6 @@ class AvatarOptimize implements ShouldQueue
|
||||||
$img->save($file, $quality);
|
$img->save($file, $quality);
|
||||||
|
|
||||||
$avatar = Avatar::whereProfileId($this->profile->id)->firstOrFail();
|
$avatar = Avatar::whereProfileId($this->profile->id)->firstOrFail();
|
||||||
$avatar->thumb_path = $avatar->media_path;
|
|
||||||
$avatar->change_count = ++$avatar->change_count;
|
$avatar->change_count = ++$avatar->change_count;
|
||||||
$avatar->last_processed_at = Carbon::now();
|
$avatar->last_processed_at = Carbon::now();
|
||||||
$avatar->save();
|
$avatar->save();
|
||||||
|
|
|
@ -45,7 +45,6 @@ class CreateAvatar implements ShouldQueue
|
||||||
$avatar = new Avatar();
|
$avatar = new Avatar();
|
||||||
$avatar->profile_id = $profile->id;
|
$avatar->profile_id = $profile->id;
|
||||||
$avatar->media_path = $path;
|
$avatar->media_path = $path;
|
||||||
$avatar->thumb_path = $path;
|
|
||||||
$avatar->change_count = 0;
|
$avatar->change_count = 0;
|
||||||
$avatar->last_processed_at = \Carbon\Carbon::now();
|
$avatar->last_processed_at = \Carbon\Carbon::now();
|
||||||
$avatar->save();
|
$avatar->save();
|
||||||
|
|
|
@ -54,13 +54,6 @@ class AvatarObserver
|
||||||
) {
|
) {
|
||||||
@unlink($path);
|
@unlink($path);
|
||||||
}
|
}
|
||||||
$path = storage_path('app/'.$avatar->thumb_path);
|
|
||||||
if( is_file($path) &&
|
|
||||||
$avatar->thumb_path != 'public/avatars/default.png' &&
|
|
||||||
$avatar->media_path != 'public/avatars/default.jpg'
|
|
||||||
) {
|
|
||||||
@unlink($path);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue