using LiteCqrs;
using TeleWave.Application.Common.Interfaces;

namespace TeleWave.Application.Settings.GetSiteSettings;

public sealed class GetSiteSettingsQueryHandler(ISiteSettings siteSettings)
    : IQueryHandler<GetSiteSettingsQuery, SiteSettingsDto>
{
    public async Task<SiteSettingsDto> Handle(
        GetSiteSettingsQuery query,
        CancellationToken cancellationToken
    )
    {
        var registrationEnabled = await siteSettings.IsRegistrationEnabledAsync(cancellationToken);
        var preferredAudio = await siteSettings.GetPreferredAudioLanguagesAsync(cancellationToken);
        var channelNumbers = await siteSettings.AreChannelNumbersEnabledAsync(cancellationToken);
        return new SiteSettingsDto(registrationEnabled, preferredAudio, channelNumbers);
    }
}
