Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Refresh.Interfaces.APIv3/Endpoints/ResourceApiEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ IntegrationConfig integration
return new ApiValidationError($"The asset must be under 2MB. Your file was {body.Length:N0} bytes.");
}

if (body.Length + user.FilesizeQuotaUsage > config.UserFilesizeQuota)
{
context.Logger.LogWarning(BunkumCategory.UserContent, "User {0} has hit the filesize quota ({1} bytes), rejecting.", user.Username, config.UserFilesizeQuota);
return new ApiValidationError($"You have exceeded your filesize quota.");
}

GameAsset? gameAsset = importer.ReadAndVerifyAsset(hash, body, TokenPlatform.Website, database);
if (gameAsset == null)
return ApiValidationError.CannotReadAssetError;
Expand All @@ -213,6 +219,7 @@ IntegrationConfig integration

database.AddAssetToDatabase(gameAsset);
dataContext.Cache.CacheAsset(gameAsset.AssetHash, gameAsset);
database.IncrementUserFilesizeQuota(user, body.Length);

return new ApiResponse<ApiGameAssetResponse>(ApiGameAssetResponse.FromOld(gameAsset, dataContext)!, Created);
}
Expand Down
Loading