Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions Refresh.Database/GameDatabaseContext.Users.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ public void UpdateUserData(GameUser user, IApiEditUserRequest data)

if (data.IconHash != null)
user.IconHash = data.IconHash;

if (data.VitaIconHash != null)
user.VitaIconHash = data.VitaIconHash;

if (data.BetaIconHash != null)
user.BetaIconHash = data.BetaIconHash;

if (data.Description != null)
user.Description = data.Description;
Expand Down
2 changes: 2 additions & 0 deletions Refresh.Database/Query/IApiEditUserRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ namespace Refresh.Database.Query;
public interface IApiEditUserRequest
{
string? IconHash { get; set; }
string? VitaIconHash { get; set; }
string? BetaIconHash { get; set; }
string? Description { get; set; }
bool? AllowIpAuthentication { get; set; }
bool? PsnAuthenticationAllowed { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace Refresh.Interfaces.APIv3.Endpoints.DataTypes.Request;
public class ApiUpdateUserRequest : IApiEditUserRequest
{
public string? IconHash { get; set; }
public string? VitaIconHash { get; set; }
public string? BetaIconHash { get; set; }
public string? Description { get; set; }
public bool? AllowIpAuthentication { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class ApiExtendedGameUserResponse : IApiResponse, IDataConvertableFrom<Ap
public required string UserId { get; set; }
public required string Username { get; set; }
public required string IconHash { get; set; }
public required string VitaIconHash { get; set; }
public required string BetaIconHash { get; set; }
public required string Description { get; set; }
public required ApiGameLocationResponse Location { get; set; }
public required DateTimeOffset JoinDate { get; set; }
Expand Down Expand Up @@ -57,7 +59,9 @@ public class ApiExtendedGameUserResponse : IApiResponse, IDataConvertableFrom<Ap
{
UserId = user.UserId.ToString()!,
Username = user.Username,
IconHash = dataContext.Database.GetAssetFromHash(user.IconHash)?.GetAsIcon(TokenGame.Website, dataContext) ?? user.IconHash,
IconHash = dataContext.GetIconFromHash(user.IconHash),
VitaIconHash = dataContext.GetIconFromHash(user.VitaIconHash),
BetaIconHash = dataContext.GetIconFromHash(user.BetaIconHash),
Description = user.Description,
Location = ApiGameLocationResponse.FromLocation(user.LocationX, user.LocationY)!,
JoinDate = user.JoinDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class ApiGameUserResponse : IApiResponse, IDataConvertableFrom<ApiGameUse
public required string UserId { get; set; }
public required string Username { get; set; }
public required string IconHash { get; set; }
public required string VitaIconHash { get; set; }
public required string BetaIconHash { get; set; }

public required string YayFaceHash { get; set; }
public required string BooFaceHash { get; set; }
Expand All @@ -39,6 +41,8 @@ public class ApiGameUserResponse : IApiResponse, IDataConvertableFrom<ApiGameUse
Username = user.Username,

IconHash = dataContext.GetIconFromHash(user.IconHash),
VitaIconHash = dataContext.GetIconFromHash(user.VitaIconHash),
BetaIconHash = dataContext.GetIconFromHash(user.BetaIconHash),
YayFaceHash = dataContext.GetIconFromHash(user.YayFaceHash),
BooFaceHash = dataContext.GetIconFromHash(user.BooFaceHash),
MehFaceHash = dataContext.GetIconFromHash(user.MehFaceHash),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public class ApiMinimalUserResponse : IApiResponse, IDataConvertableFrom<ApiMini
public required string UserId { get; set; }
public required string Username { get; set; }
public required string IconHash { get; set; }

public required string VitaIconHash { get; set; }
public required string BetaIconHash { get; set; }

public static ApiMinimalUserResponse? FromOld(GameUser? old, DataContext dataContext)
{
Expand All @@ -19,7 +20,9 @@ public class ApiMinimalUserResponse : IApiResponse, IDataConvertableFrom<ApiMini
{
UserId = old.UserId.ToString(),
Username = old.Username,
IconHash = old.IconHash,
IconHash = dataContext.GetIconFromHash(old.IconHash),
VitaIconHash = dataContext.GetIconFromHash(old.VitaIconHash),
BetaIconHash = dataContext.GetIconFromHash(old.BetaIconHash),
};
}

Expand Down
6 changes: 6 additions & 0 deletions Refresh.Interfaces.APIv3/Endpoints/UserApiEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ public ApiResponse<ApiExtendedGameUserResponse> UpdateUser(RequestContext contex
{
if (body.IconHash != null && database.GetAssetFromHash(body.IconHash) == null)
return ApiNotFoundError.Instance;

if (body.VitaIconHash != null && database.GetAssetFromHash(body.VitaIconHash) == null)
return ApiNotFoundError.Instance;

if (body.BetaIconHash != null && database.GetAssetFromHash(body.BetaIconHash) == null)
return ApiNotFoundError.Instance;

if (body.EmailAddress != null && !smtpService.CheckEmailDomainValidity(body.EmailAddress))
return ApiValidationError.EmailDoesNotActuallyExistError;
Expand Down