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 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 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 }); } } }