change judgement of duplicate textures (fix #132) (#133)

* change judgement of duplicate textures

* fix test
This commit is contained in:
Steven Qiu 2020-02-23 08:38:36 +08:00 committed by GitHub
parent f721ac269c
commit 1b0e1b154b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1 additions and 21 deletions

View File

@ -252,7 +252,7 @@ class SkinlibController extends Controller
foreach ($results as $result) {
// if the texture already uploaded was set to private,
// then allow to re-upload it.
if ($result->type == $t->type && $result->public) {
if ($result->public) {
return json(trans('skinlib.upload.repeated'), 0, ['tid' => $result->tid]);
}
}
@ -391,14 +391,6 @@ class SkinlibController extends Controller
return json(trans('skinlib.no-permission'), 1);
}
$duplicate = Texture::where('hash', $t->hash)
->where('type', $request->input('model'))
->where('tid', '<>', $t->tid)
->first();
if ($duplicate && $duplicate->public) {
return json(trans('skinlib.model.duplicate', ['name' => $duplicate->name]), 1);
}
$t->type = $request->input('model');
$t->save();

View File

@ -88,7 +88,6 @@ rename:
model:
success: The texture's model was changed to :model successfully.
duplicate: "The same texture available for the chosen model already exists in skinlib (Name: :name). You can add it to your closet directly."
no-permission: You have no permission to moderate this texture.
non-existent: No such texture.

View File

@ -947,17 +947,6 @@ class SkinlibControllerTest extends TestCase
'hash' => $texture->hash,
]);
// Should fail if there is already a texture with same hash and chosen model
$this->actingAs($uploader)
->postJson('/skinlib/model', [
'tid' => $texture->tid,
'model' => 'alex',
])
->assertJson([
'code' => 1,
'message' => trans('skinlib.model.duplicate', ['name' => $duplicate->name]),
]);
// Allow private texture
$duplicate->public = false;
$duplicate->save();