49 lines
1.4 KiB
C#
49 lines
1.4 KiB
C#
using DeluxeBackend.Models;
|
|
using DeluxeBackend.Services;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace DeluxeBackend.Controllers.Accounts
|
|
{
|
|
[Route("Accounts/accountprivacysettings")]
|
|
[ApiController]
|
|
public class AccountPrivacySettingsController(ILiteDbService db, IJwtService jwt) : ControllerBase
|
|
{
|
|
[HttpGet("{accId}")]
|
|
public async Task<IActionResult> AccountPrivacySettings(long accId)
|
|
{
|
|
|
|
Account? account = db.Accounts.FindById(accId);
|
|
|
|
if (account == null)
|
|
{
|
|
return NotFound();
|
|
}
|
|
|
|
return Ok(new
|
|
{
|
|
accountId = accId,
|
|
isRecentHistoryVisible = account.IsRecentHistoryVisible
|
|
});
|
|
}
|
|
[HttpGet("recenthistoryvisibility")]
|
|
[Authorize(Roles = "gameClient")]
|
|
public async Task<IActionResult> RecentHistoryVisibility([FromForm] bool isRecentHistoryVisible)
|
|
{
|
|
|
|
LoginWithInfoResult? login = await jwt.GetLoginWithInfo(User);
|
|
if (login == null) return Unauthorized();
|
|
|
|
Account account = login.Account;
|
|
account.IsRecentHistoryVisible = isRecentHistoryVisible;
|
|
db.Accounts.Update(account);
|
|
|
|
return Ok(new
|
|
{
|
|
Success = true
|
|
});
|
|
}
|
|
}
|
|
}
|