feat: improve recording automation and task workflows

This commit is contained in:
2026-04-23 23:18:11 +08:00
parent 1c892259a9
commit 23ead56781
88 changed files with 9579 additions and 1581 deletions
@@ -1,5 +1,6 @@
using LiveRecorder.Application.Abstractions.Notifications;
using LiveRecorder.Application.Abstractions.Platforms;
using LiveRecorder.Application.Abstractions.Scripting;
using LiveRecorder.Domain.Entities;
using LiveRecorder.Domain.Enums;
@@ -8,10 +9,14 @@ namespace LiveRecorder.Application.Services;
public sealed class LiveRoomStatusService
{
private readonly IEmailNotificationService _emailNotificationService;
private readonly IEventScriptService _eventScriptService;
public LiveRoomStatusService(IEmailNotificationService emailNotificationService)
public LiveRoomStatusService(
IEmailNotificationService emailNotificationService,
IEventScriptService eventScriptService)
{
_emailNotificationService = emailNotificationService;
_eventScriptService = eventScriptService;
}
public async Task ApplySnapshotAsync(
@@ -23,17 +28,32 @@ public sealed class LiveRoomStatusService
ArgumentNullException.ThrowIfNull(liveRoom);
ArgumentNullException.ThrowIfNull(liveStatus);
liveRoom.UpdateMetadata(liveStatus.Title, liveStatus.AnchorName, liveStatus.CoverUrl, observedAt);
var wasLive = liveRoom.AvailabilityStatus == LiveRoomAvailabilityStatus.Live;
liveRoom.UpdateMetadata(
liveStatus.Title,
liveStatus.AnchorName,
liveStatus.AnchorId,
liveStatus.AvatarUrl,
liveStatus.CoverUrl,
observedAt);
liveRoom.UpdateAvailability(
liveStatus.IsLive ? LiveRoomAvailabilityStatus.Live : LiveRoomAvailabilityStatus.Offline,
observedAt);
if (wasLive && !liveStatus.IsLive)
{
await _eventScriptService.RunLiveEndedAsync(liveRoom, observedAt, cancellationToken);
return;
}
if (!liveStatus.IsLive || liveRoom.HasSentLiveNotificationForCurrentSession)
{
return;
}
await _emailNotificationService.SendLiveStartedAsync(liveRoom, cancellationToken);
await _eventScriptService.RunLiveStartedAsync(liveRoom, observedAt, cancellationToken);
liveRoom.MarkLiveNotificationSent(observedAt);
}
}