add voice service call service and more

This commit is contained in:
2025-11-25 16:49:18 +03:30
parent 60d20a2734
commit 9ba81d944f
49 changed files with 4428 additions and 19 deletions

View File

@@ -8,10 +8,12 @@ namespace GreenHome.Api.Controllers;
public class TelemetryController : ControllerBase
{
private readonly ITelemetryService telemetryService;
private readonly IAlertService alertService;
public TelemetryController(ITelemetryService telemetryService)
public TelemetryController(ITelemetryService telemetryService, IAlertService alertService)
{
this.telemetryService = telemetryService;
this.alertService = alertService;
}
[HttpGet]
@@ -37,6 +39,26 @@ public class TelemetryController : ControllerBase
TimestampUtc = DateTime.UtcNow
};
var id = await telemetryService.AddAsync(dto, cancellationToken);
// Check and send alerts if needed (fire and forget)
_ = Task.Run(async () =>
{
try
{
// Get deviceId from the saved telemetry record
var deviceId = dto.DeviceId;
if (deviceId > 0)
{
await alertService.CheckAndSendAlertsAsync(deviceId, dto, cancellationToken);
}
}
catch
{
// Log error but don't fail the request
// Errors are logged in AlertService
}
}, cancellationToken);
return Ok(id);
}