IYouTubePubSubService.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. namespace Application.Abstractions.YouTube;
  2. /// <summary>
  3. /// YouTube PubSubHubbub(WebSub) 구독 관리
  4. /// 채널의 새 영상/생방송 알림을 푸시로 수신
  5. /// </summary>
  6. public interface IYouTubePubSubService
  7. {
  8. /// <summary>특정 채널의 피드 구독 신청</summary>
  9. Task<bool> SubscribeAsync(string channelId, CancellationToken ct);
  10. /// <summary>특정 채널의 피드 구독 해지</summary>
  11. Task<bool> UnsubscribeAsync(string channelId, CancellationToken ct);
  12. /// <summary>Atom Feed 알림 파싱</summary>
  13. YouTubePubSubNotification? ParseNotification(string atomXml);
  14. /// <summary>HMAC 서명 검증</summary>
  15. bool VerifySignature(string payload, string signature);
  16. /// <summary>현재 구독 중인 YouTube 채널 ID 목록 조회</summary>
  17. Task<IReadOnlyList<string>> GetSubscribedChannelIdsAsync(CancellationToken ct);
  18. /// <summary>
  19. /// PubSub 알림 중복 처리 방지용 마커.
  20. /// 처음 호출 시 true, 이미 처리된 videoId면 false 반환.
  21. /// </summary>
  22. Task<bool> TryMarkProcessedAsync(string videoId, CancellationToken ct);
  23. /// <summary>
  24. /// 채널의 마지막으로 처리된 videoId 조회 (Feed 폴링 중복 감지용).
  25. /// </summary>
  26. Task<string?> GetLastProcessedVideoIdAsync(string youtubeChannelID, CancellationToken ct);
  27. /// <summary>
  28. /// 채널의 마지막 처리 videoId 저장 (PubSub/Feed 어느 경로든 처리 후 호출).
  29. /// </summary>
  30. Task SetLastProcessedVideoIdAsync(string youtubeChannelID, string videoId, CancellationToken ct);
  31. /// <summary>
  32. /// 채널별 마지막 Feed 폴링 시각 저장 (신규 비디오 감지 여부와 무관, 매 폴링 시 호출).
  33. /// </summary>
  34. Task SetLastPolledAtAsync(string youtubeChannelID, DateTime utcNow, CancellationToken ct);
  35. /// <summary>
  36. /// 모든 채널의 마지막 Feed 폴링 시각 일괄 조회 (관리자 대시보드용).
  37. /// </summary>
  38. Task<IReadOnlyDictionary<string, DateTime>> GetAllLastPolledAtAsync(CancellationToken ct);
  39. /// <summary>
  40. /// 모든 채널의 마지막 처리 videoId 일괄 조회 (관리자 대시보드용).
  41. /// </summary>
  42. Task<IReadOnlyDictionary<string, string>> GetAllLastProcessedVideoIdsAsync(CancellationToken ct);
  43. /// <summary>
  44. /// 채널의 PubSub lease 만료 예정 시각 저장 (구독 verify 시 lease_seconds 기반).
  45. /// </summary>
  46. Task SetLeaseExpiryAsync(string youtubeChannelID, DateTime expiresAtUtc, CancellationToken ct);
  47. /// <summary>
  48. /// 모든 채널의 PubSub lease 만료 예정 시각 일괄 조회 (관리자 대시보드용).
  49. /// </summary>
  50. Task<IReadOnlyDictionary<string, DateTime>> GetAllLeaseExpiriesAsync(CancellationToken ct);
  51. }