feat: add notifications (#216)

* feat: initial notifications support

* chore: update deps
This commit is contained in:
Ludvig Lundgren 2022-04-04 19:13:09 +02:00 committed by GitHub
parent 3185832708
commit 431742fd94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 1632 additions and 36 deletions

View file

@ -157,26 +157,37 @@ func (s *service) runAction(action domain.Action, release domain.Release) error
return nil
}
if rejections != nil {
s.bus.Publish("release:push-rejected", &domain.ReleaseActionStatus{
ReleaseID: release.ID,
Status: domain.ReleasePushStatusRejected,
Action: action.Name,
Type: action.Type,
Rejections: rejections,
Timestamp: time.Now(),
})
return nil
}
s.bus.Publish("release:push-approved", &domain.ReleaseActionStatus{
rlsActionStatus := &domain.ReleaseActionStatus{
ReleaseID: release.ID,
Status: domain.ReleasePushStatusApproved,
Action: action.Name,
Type: action.Type,
Rejections: []string{},
Timestamp: time.Now(),
}
if rejections != nil {
rlsActionStatus.Status = domain.ReleasePushStatusRejected
rlsActionStatus.Rejections = rejections
}
// send event for actions
s.bus.Publish("release:push", rlsActionStatus)
// send separate event for notifications
s.bus.Publish("events:release:push", &domain.EventsReleasePushed{
ReleaseName: release.TorrentName,
Filter: release.Filter.Name,
Indexer: release.Indexer,
InfoHash: release.TorrentHash,
Size: release.Size,
Status: domain.ReleasePushStatusApproved,
Action: action.Name,
ActionType: action.Type,
Rejections: []string{},
Protocol: domain.ReleaseProtocolTorrent,
Implementation: domain.ReleaseImplementationIRC,
Timestamp: time.Now(),
})
return nil