using Tiku.Application.Learning;
using Tiku.Application.Security;

namespace Tiku.Api.Controllers;

public sealed class LearningActorResolver(
    ICurrentUser currentUser,
    ITenantContext currentTenant)
{
    internal LearningActor Resolve()
    {
        if (currentTenant.TenantId is null || currentUser.UserId is null) throw new LearningAccessDeniedException();

        return new LearningActor(currentTenant.TenantId.Value, currentUser.UserId.Value);
    }
}

public sealed class LearningAccessDeniedException()
    : Exception("Learning actor was not resolved.");
