@startuml MonitorAlbum - Already Owned (Early Return) skinparam sequenceMessageAlign center skinparam responseMessageBelowArrow true title MonitorAlbum: Album Already Owned in Requested Quality actor Client participant "MusicAgregatorService" as Service participant "MetadataService" as Metadata database "metadata-agregator\n(gRPC)" as MetaGRPC database "PostgreSQL" as DB Client -> Service: MonitorAlbum(album_id, quality=LOSSLESS) Service -> Metadata: GetAlbum(album_id) Metadata -> MetaGRPC: GetAlbum(id) MetaGRPC --> Metadata: Album Metadata -> DB: albums.GetByExternalID() DB --> Metadata: found (already persisted) note right: Album exists from\nprevious MonitorAlbum\nor GetArtists discovery Metadata --> Service: Album Service -> DB: albums.GetByExternalID() DB --> Service: dbAlbum Service -> DB: albums.SetMonitorState(id, monitored) note right #lightgreen: Always set monitored\nregardless of outcome Service -> DB: downloads.HasAlbumInQuality(id, LOSSLESS, "16-44") DB --> Service: true note right #lightgreen: Found existing download\nwith state IN\n('completed', 'seeding') Service -> Service: buildMonitorAlbumResponse() Service -> DB: downloads.GetByAlbumID() DB --> Service: download (completed, FLAC, /downloads) Service -> DB: artists.GetByExternalID() DB --> Service: artist Service --> Client: MonitorAlbumResponse note right #lightgreen: album: monitored, download info\nartist: monitored\nrelease: nil (no new search)\n\nNo indexer search.\nNo torrent client interaction.\nFast response. @enduml