using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using eprintServer.DTOs; using eprintServer.Entities; using eprintServer.Services; namespace eprintServer.Controllers; [Authorize(Roles = "ADMIN,SUB_ADMIN")] [ApiController] [Route("api/admin/oauth-settings")] public class OAuthSettingsController : ControllerBase { private readonly OAuthSettingsService _settingsService; private readonly ReportSettingsService _reportService; public OAuthSettingsController(OAuthSettingsService settingsService, ReportSettingsService reportService) { _settingsService = settingsService; _reportService = reportService; } [HttpGet] public async Task> GetSettings() { var settings = await _settingsService.GetOrCreateSettingsAsync(); return Ok(settings); } [HttpPut] public async Task> UpdateSettings([FromBody] OAuthSettingsDto dto) { var updatedSettings = await _settingsService.UpdateSettingsAsync(dto); return Ok(updatedSettings); } [HttpGet("report-mails-settings")] public async Task> GetReportsMailingSettings() { var settings = await _reportService.GetOrInitializeSettingsAsync(); return Ok(settings); } [HttpPatch("report-mails-settings")] public async Task> UpdateReportsMailingSettings( [FromBody] ReportSettings request) { var updated = await _reportService.UpdateSettingsAsync(request); return Ok(updated); } }