Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete Asset Manager assets when corresponding attachment is deleted
This wires up an instance of ServiceListeners::AttachmentDeleter so that the Asset Manager assets corresponding to an AttachmentData are deleted via a Sidekiq worker. This will mark the relevant assets as deleted in Asset Manager. While there is functionality in the Asset Manager API to restore a deleted asset, there doesn't appear to be any such functionality in Whitehall. Note that the Asset Manager assets will only be deleted if no other non-deleted Attachment instances are still referencing the AttachmentData, i.e. where AttachmentData#deleted? is `true`. Also note that it looks as if when a (consultation) Response or a PolicyGroup is destroyed, the associated attachments are not deleted. While it's not obvious that it's possible to delete a Response via the user interface, it does appear to be possible to delete a PolicyGroup. While it doesn't feel appropriate to address this here, I'd recommend that for consistency and completeness, both of these problems should be fixed by calling Attachable#delete_all_attachments from a before/after destroy callback on Response and PolicyGroup. This would mean a 'destroy' event would be published to the attachment notifier for each attachment and the relevant assets would be deleted in Asset Manager.
- Loading branch information