1
0
mirror of synced 2024-11-27 16:10:53 +01:00

Prevent exception from guest mode results

This commit is contained in:
asesidaa 2022-09-16 23:45:08 +08:00
parent 70264aa47b
commit 116b134b70
2 changed files with 9 additions and 3 deletions

View File

@ -45,6 +45,12 @@ public class PlayResultController : BaseController<PlayResultController>
Result = 1
};
// Fix issue caused by guest play, god knows why they send guest play data
if (request.BaidConf == 0 || await userDatumService.GetFirstUserDatumOrNull(request.BaidConf) is null)
{
return Ok(response);
}
var lastPlayDatetime = DateTime.ParseExact(playResultData.PlayDatetime, Constants.DATE_TIME_FORMAT,
CultureInfo.InvariantCulture);
@ -168,7 +174,7 @@ public class PlayResultController : BaseController<PlayResultController>
{
var userdata = await userDatumService.GetFirstUserDatumOrNull(request.BaidConf);
userdata.ThrowIfNull();
userdata.ThrowIfNull($"User data is null! Baid: {request.BaidConf}");
userdata.Title = playResultData.Title;
userdata.TitlePlateId = playResultData.TitleplateId;

View File

@ -59,7 +59,7 @@ public class UserDatumService : IUserDatumService
public async Task<List<uint>> GetFavoriteSongIds(uint baid)
{
var userDatum = await context.UserData.FindAsync(baid);
userDatum.ThrowIfNull();
userDatum.ThrowIfNull($"User with baid: {baid} not found!");
using var stringStream = GZipBytesUtil.GenerateStreamFromString(userDatum.FavoriteSongsArray);
List<uint>? result;
@ -79,7 +79,7 @@ public class UserDatumService : IUserDatumService
public async Task UpdateFavoriteSong(uint baid, uint songId, bool isFavorite)
{
var userDatum = await context.UserData.FindAsync(baid);
userDatum.ThrowIfNull();
userDatum.ThrowIfNull($"User with baid: {baid} not found!");
using var stringStream = GZipBytesUtil.GenerateStreamFromString(userDatum.FavoriteSongsArray);
List<uint>? favoriteSongIds;