using GmRelay.Shared.Platform;
using Telegram.Bot.Types;

namespace GmRelay.Bot.Features.Sessions.ExportCalendar;

public sealed class ExportCalendarHandler(
    GmRelay.Shared.Features.Sessions.ExportCalendar.ExportCalendarHandler sharedHandler)
{
    public Task HandleAsync(Message message, CancellationToken cancellationToken)
    {
        var command = new GmRelay.Shared.Features.Sessions.ExportCalendar.ExportCalendarCommand(
            new PlatformGroup(
                PlatformKind.Telegram,
                message.Chat.Id.ToString(),
                message.Chat.Title ?? "Private Chat",
                message.MessageThreadId?.ToString()),
            new PlatformUser(
                PlatformKind.Telegram,
                message.From?.Id.ToString() ?? string.Empty,
                message.From?.FirstName ?? string.Empty,
                message.From?.Username));

        return sharedHandler.HandleAsync(command, cancellationToken);
    }
}
