@@ -20,38 +20,37 @@ public static ValidatedAssetResult ValidateReference(AssetValidationParameters p
2020 GameAsset ? asset = null ;
2121 bool existsInDataStore = false ;
2222 bool isPSP = parameters . GameToUseIn == TokenGame . LittleBigPlanetPSP ;
23- Action < string > ? onNewAssetRefCallback = parameters . OnNewAssetRefCallback ;
2423
2524 if ( parameters . AssetRef . IsBlankHash ( ) )
2625 {
27- if ( ! parameters . MayBeBlank ) return new ( BadRequest , "0" , $ "The { assetTypeStr } must be set.", onNewAssetRefCallback ) ;
28- else return new ( OK , "0" , null , onNewAssetRefCallback ) ;
26+ if ( ! parameters . MayBeBlank ) return new ( BadRequest , "0" , $ "The { assetTypeStr } must be set.") ;
27+ else return new ( OK , "0" , null ) ;
2928 }
3029
3130 else if ( parameters . AssetRef . StartsWith ( 'g' ) )
3231 {
33- if ( ! parameters . MayBeGuid ) return new ( BadRequest , null , $ "The { assetTypeStr } may not be an in-game asset.", onNewAssetRefCallback ) ;
34- if ( parameters . AssetRef . Length < 2 ) return new ( BadRequest , null , $ "The used in-game { assetTypeStr } is invalid (empty GUID).", onNewAssetRefCallback ) ;
32+ if ( ! parameters . MayBeGuid ) return new ( BadRequest , null , $ "The { assetTypeStr } may not be an in-game asset.") ;
33+ if ( parameters . AssetRef . Length < 2 ) return new ( BadRequest , null , $ "The used in-game { assetTypeStr } is invalid (empty GUID).") ;
3534
3635 // This should only happen if the user is messing with mods/the API/beta builds, so give them a more detailed response
3736 bool canParseGuid = long . TryParse ( parameters . AssetRef [ 1 ..] , out long guid ) ;
3837 if ( ! canParseGuid )
39- return new ( BadRequest , null , $ "The used in-game { assetTypeStr } is invalid (badly formatted GUID).", onNewAssetRefCallback ) ;
38+ return new ( BadRequest , null , $ "The used in-game { assetTypeStr } is invalid (badly formatted GUID).") ;
4039
4140 if ( parameters . MustBeTexture && ! parameters . GuidChecker . IsTextureGuid ( parameters . GameToUseIn , guid ) )
42- return new ( BadRequest , null , $ "The used in-game { assetTypeStr } was not a valid image (unknown GUID).", onNewAssetRefCallback ) ;
41+ return new ( BadRequest , null , $ "The used in-game { assetTypeStr } was not a valid image (unknown GUID).") ;
4342 }
4443
4544 // At this point the reference is a hash
4645 else if ( ! parameters . MayBeHash )
4746 {
48- return new ( BadRequest , null , $ "The { assetTypeStr } may not be a custom asset.", onNewAssetRefCallback ) ;
47+ return new ( BadRequest , null , $ "The { assetTypeStr } may not be a custom asset.") ;
4948 }
5049
5150 else if ( ! CommonPatterns . Sha1Regex ( ) . IsMatch ( parameters . AssetRef ) )
5251 {
5352 // This should only happen if a player is messing with mods/the API, so give them a more detailed response
54- return new ( BadRequest , null , $ "The used { assetTypeStr } had an invalid hash.", onNewAssetRefCallback ) ;
53+ return new ( BadRequest , null , $ "The used { assetTypeStr } had an invalid hash.") ;
5554 }
5655
5756 else
@@ -60,7 +59,7 @@ public static ValidatedAssetResult ValidateReference(AssetValidationParameters p
6059 if ( disallowed != null )
6160 {
6261 logger . LogWarning ( BunkumCategory . UserContent , $ "{ parameters . User } tried to use a manually disallowed { assetTypeStr } .") ;
63- return new ( Unauthorized , disallowanceInfo : disallowed , onNewAssetRefCallback : onNewAssetRefCallback ) ;
62+ return new ( Unauthorized , disallowanceInfo : disallowed ) ;
6463 }
6564
6665 string filename = isPSP ? $ "psp/{ parameters . AssetRef } " : parameters . AssetRef ;
@@ -71,7 +70,7 @@ public static ValidatedAssetResult ValidateReference(AssetValidationParameters p
7170 logger . LogDebug ( BunkumCategory . UserContent , $ "Referenced asset '{ filename } ' could not be found in data store.") ;
7271
7372 if ( parameters . MustBeInDataStoreIfHash )
74- return new ( NotFound , null , $ "The used { assetTypeStr } did not exist on the server.", onNewAssetRefCallback ) ;
73+ return new ( NotFound , null , $ "The used { assetTypeStr } did not exist on the server.") ;
7574 }
7675
7776 asset = parameters . Cache . GetAssetInfo ( parameters . AssetRef , parameters . Database ) ;
@@ -88,15 +87,15 @@ public static ValidatedAssetResult ValidateReference(AssetValidationParameters p
8887 sw . Stop ( ) ;
8988 logger . LogError ( BunkumCategory . UserContent , $ "Failed to read '{ filename } ' from data store!") ;
9089 logger . LogDebug ( BunkumCategory . UserContent , $ "Failed to get '{ filename } ' after { sw . ElapsedMilliseconds } ms.") ;
91- return new ( InternalServerError , null , $ "Failed to read { assetTypeStr } internally. Please report this to the server owner.", onNewAssetRefCallback , existsInDataStore : existsInDataStore ) ;
90+ return new ( InternalServerError , null , $ "Failed to read { assetTypeStr } internally. Please report this to the server owner.", existsInDataStore : existsInDataStore ) ;
9291 }
9392
9493 asset = parameters . AssetImporter . ReadAndVerifyAsset ( parameters . AssetRef , assetData , parameters . PlatformToUseIn , parameters . Database ) ;
9594 if ( asset == null )
9695 {
9796 sw . Stop ( ) ;
9897 logger . LogDebug ( BunkumCategory . UserContent , $ "Failed to get '{ filename } ' after { sw . ElapsedMilliseconds } ms.") ;
99- return new ( BadRequest , null , $ "The used { assetTypeStr } was invalid or corrupt.", onNewAssetRefCallback , existsInDataStore : existsInDataStore ) ;
98+ return new ( BadRequest , null , $ "The used { assetTypeStr } was invalid or corrupt.", existsInDataStore : existsInDataStore ) ;
10099 }
101100
102101 sw . Stop ( ) ;
@@ -109,12 +108,12 @@ public static ValidatedAssetResult ValidateReference(AssetValidationParameters p
109108 bool isHashedTexture = ( asset . AssetFlags & AssetFlags . Imagery ) != 0 ;
110109
111110 if ( parameters . MustBeTexture && ! isHashedTexture )
112- return new ( BadRequest , null , $ "The used { assetTypeStr } was not a valid custom image.", onNewAssetRefCallback , assetInfo : asset , existsInDataStore : existsInDataStore ) ;
111+ return new ( BadRequest , null , $ "The used { assetTypeStr } was not a valid custom image.", assetInfo : asset , existsInDataStore : existsInDataStore ) ;
113112
114113 // TODO: actually use AIPI to scan image if not null
115114 }
116115 }
117116
118- return new ( OK , parameters . AssetRef , null , onNewAssetRefCallback , assetInfo : asset , existsInDataStore : existsInDataStore ) ;
117+ return new ( OK , parameters . AssetRef , assetInfo : asset , existsInDataStore : existsInDataStore ) ;
119118 }
120119}
0 commit comments