fix(releases): max downloads per hour (#883)

* fix(releases): max downloads per hour

* refactor: release processing

* compare apples to apples (#884)

* from rocketships back to apples

* Update internal/database/filter.go

* cast me to the

* keep your eye on the case

---------

Co-authored-by: Kyle Sanderson <kyle.leet@gmail.com>
This commit is contained in:
ze0s 2023-04-29 21:52:49 +02:00 committed by GitHub
parent da5492febb
commit ef3445cbed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 139 additions and 107 deletions

View file

@ -93,18 +93,6 @@ func (s *service) RunAction(ctx context.Context, action *domain.Action, release
return rejections, err
}
rlsActionStatus := &domain.ReleaseActionStatus{
ReleaseID: release.ID,
Status: domain.ReleasePushStatusApproved,
Action: action.Name,
Type: action.Type,
Client: action.Client.Name,
Filter: release.Filter.Name,
FilterID: int64(release.Filter.ID),
Rejections: []string{},
Timestamp: time.Now(),
}
payload := &domain.NotificationPayload{
Event: domain.NotificationEventPushApproved,
ReleaseName: release.TorrentName,
@ -126,26 +114,17 @@ func (s *service) RunAction(ctx context.Context, action *domain.Action, release
if err != nil {
s.log.Error().Err(err).Msgf("process action failed: %v for '%v'", action.Name, release.TorrentName)
rlsActionStatus.Status = domain.ReleasePushStatusErr
rlsActionStatus.Rejections = []string{err.Error()}
payload.Event = domain.NotificationEventPushError
payload.Status = domain.ReleasePushStatusErr
payload.Rejections = []string{err.Error()}
}
if rejections != nil {
rlsActionStatus.Status = domain.ReleasePushStatusRejected
rlsActionStatus.Rejections = rejections
payload.Event = domain.NotificationEventPushRejected
payload.Status = domain.ReleasePushStatusRejected
payload.Rejections = rejections
}
// send event for actions
s.bus.Publish("release:push", rlsActionStatus)
// send separate event for notifications
s.bus.Publish("events:notification", &payload.Event, payload)