mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-02-23 14:59:07 +08:00
Remove Legacy API from core
This commit is contained in:
parent
f9e4436503
commit
07566c4c16
@ -64,39 +64,6 @@ class TextureController extends Controller
|
||||
return $this->texture($hash);
|
||||
}
|
||||
|
||||
public function skin($player_name)
|
||||
{
|
||||
return $this->getBinaryTextureFromPlayer($player_name, 'skin');
|
||||
}
|
||||
|
||||
public function cape($player_name)
|
||||
{
|
||||
return $this->getBinaryTextureFromPlayer($player_name, 'cape');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the texture image of given type and player.
|
||||
*
|
||||
* @param string $player_name
|
||||
* @param string $type "steve" or "alex" or "cape"
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
protected function getBinaryTextureFromPlayer($player_name, $type)
|
||||
{
|
||||
$player = $this->getPlayerInstance($player_name);
|
||||
|
||||
if ($hash = $player->getTexture($type)) {
|
||||
return $this->texture(
|
||||
$hash,
|
||||
['Last-Modified' => $player->last_modified],
|
||||
trans('general.texture-deleted')
|
||||
);
|
||||
} else {
|
||||
abort(404, trans('general.texture-not-uploaded', ['type' => $type]));
|
||||
}
|
||||
}
|
||||
|
||||
public function avatarByTid($tid, $size = 128)
|
||||
{
|
||||
if ($t = Texture::find($tid)) {
|
||||
|
@ -20,14 +20,8 @@ class CheckPlayerExist
|
||||
}
|
||||
}
|
||||
|
||||
if (stripos($request->getUri(), '.json') != false) {
|
||||
preg_match('/\/([^\/]*)\.json/', $request->getUri(), $matches);
|
||||
} else {
|
||||
preg_match('/\/([^\/]*)\.png/', $request->getUri(), $matches);
|
||||
}
|
||||
|
||||
preg_match('/\/([^\/]*)\.json/', $request->getUri(), $matches);
|
||||
$player_name = urldecode($matches[1]);
|
||||
|
||||
$responses = event(new CheckPlayerExists($player_name));
|
||||
|
||||
if (is_array($responses)) {
|
||||
|
@ -57,6 +57,7 @@
|
||||
- Removed settings of "Method of Retrieving IP".
|
||||
- Removed "3rd-party comment", and please install separated plugin if you need it.
|
||||
- Removed enabling or disabling Redis via Web UI.
|
||||
- Removed Legacy API from core. (Install plugin if you need it.)
|
||||
|
||||
## Internal Changes
|
||||
|
||||
|
@ -57,6 +57,7 @@
|
||||
- 移除「IP 获取方法」的设置
|
||||
- 移除「第三方评论」功能,如有需要请安装独立插件
|
||||
- 移除通过 UI 来开启或关闭 Redis 的功能
|
||||
- 移除「传统皮肤加载方式」(如有需要,请安装插件)
|
||||
|
||||
## 内部更改
|
||||
|
||||
|
@ -4,9 +4,6 @@ Route::group(['middleware' => 'player'], function () {
|
||||
// Json profile
|
||||
Route::get('/{player_name}.json', 'TextureController@json');
|
||||
Route::get('/{api}/{player_name}.json', 'TextureController@jsonWithApi')->where('api', 'usm|csl');
|
||||
// Legacy links
|
||||
Route::get('/skin/{player_name}.png', 'TextureController@skin');
|
||||
Route::get('/cape/{player_name}.png', 'TextureController@cape');
|
||||
});
|
||||
|
||||
Route::get('/textures/{hash}', 'TextureController@texture');
|
||||
|
@ -151,40 +151,6 @@ class TextureControllerTest extends TestCase
|
||||
->assertSuccessful();
|
||||
}
|
||||
|
||||
public function testSkin()
|
||||
{
|
||||
Storage::fake('textures');
|
||||
$skin = factory(Texture::class)->create();
|
||||
$player = factory(Player::class)->create();
|
||||
|
||||
$this->get("/skin/{$player->name}.png")
|
||||
->assertSee(e(trans('general.texture-not-uploaded', ['type' => 'skin'])));
|
||||
|
||||
$player->tid_skin = $skin->tid;
|
||||
$player->save();
|
||||
$this->get("/skin/{$player->name}.png")
|
||||
->assertSee(trans('general.texture-deleted'));
|
||||
|
||||
Storage::disk('textures')->put($skin->hash, '');
|
||||
$this->get("/skin/{$player->name}.png")
|
||||
->assertHeader('Content-Type', 'image/png')
|
||||
->assertHeader('Last-Modified')
|
||||
->assertHeader('Accept-Ranges', 'bytes')
|
||||
->assertHeader('Content-Length', Storage::disk('textures')->size($skin->hash))
|
||||
->assertSuccessful();
|
||||
}
|
||||
|
||||
public function testCape()
|
||||
{
|
||||
$cape = factory(Texture::class, 'cape')->create();
|
||||
$player = factory(Player::class)->create([
|
||||
'tid_cape' => $cape->tid,
|
||||
]);
|
||||
|
||||
$this->get("/cape/{$player->name}.png")
|
||||
->assertSee(trans('general.texture-deleted'));
|
||||
}
|
||||
|
||||
public function testAvatarByTid()
|
||||
{
|
||||
$this->get('/avatar/1')->assertHeader('Content-Type', 'image/png');
|
||||
|
@ -18,10 +18,6 @@ class CheckPlayerExistTest extends TestCase
|
||||
->assertStatus(404)
|
||||
->assertSee(trans('general.unexistent-player'));
|
||||
|
||||
$this->get('/skin/nope.png')
|
||||
->assertStatus(404)
|
||||
->assertSee(trans('general.unexistent-player'));
|
||||
|
||||
option(['return_204_when_notfound' => true]);
|
||||
$this->getJson('/nope.json')->assertNoContent();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user