Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce Whitehall.attachment_notifier
This is intended to work in a similar way to the notifier in EditionServiceCoordinator, except that it's used to publish events concerning the Attachment class. My plan is to subscribe an instance of ServiceListeners::AttachmentDraftStatusUpdater to this notifier in order to keep the draft status of attachments associated with policy groups up-to-date in Asset Manager. Note that the visibility of attachments on a policy group is determined simply by the existence of the policy group. This logic is already encapsulated in the AttachmentVisibility class which is used in the ServiceListeners::AttachmentDraftStatusUpdater. I did consider introducing a service for creating attachments, but there doesn't seem to be any precedent for using services in that way and in any case it felt a bit like overkill. I also considered wiring an instance of ServiceListeners::AttachmentDraftStatusUpdater directly into the Admin::AttachmentsController, but that felt at odds with the approach taken elsewhere and would've introduced unnecessary coupling and made testing of the controller harder. Note that there's no need to publish 'update' events as well as 'create' events, because updating an attachment should not have any effect on the draft status of its corresponding asset. We might need to introduce a 'destroy' event at some point, but we're planning to tackle that separately in this issue [1]. [1]: alphagov/asset-manager#469
- Loading branch information