Move `after_commit` for `Release` to the creation service instead
Discovered as part of !22620 (merged):
Yeah, this one actually needs Sidekiq to run inline as the notification is sent as an
after_commit
hook inRelease
: https://gitlab.com/gitlab-org/gitlab/blob/786347041e87fa2c405c72f388f9b4ffb47539ba/app/models/release.rb#L38 => https://gitlab.com/gitlab-org/gitlab/blob/786347041e87fa2c405c72f388f9b4ffb47539ba/app/models/release.rb#L106 which delegates to a Sidekiq worker.I believe this has two conceptual problems:
- Notifications isn't a model's responsibility, so it should be moved to the service that creates a release instead.
- There's no need to delegate the notification to a Sidekiq worker, has notifications are already sent async via ActiveJob.