16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/services/collavre/tools/creative_remove_attachment_service.rb', line 16
def call(creative_id:, signed_id:)
raise "Current.user is required" unless Current.user
creative = Creative.find_by(id: creative_id)
return { error: "Creative not found", id: creative_id } unless creative
unless creative.has_permission?(Current.user, :write)
return { error: "No write permission on Creative", id: creative_id }
end
removed = creative.remove_attachment!(signed_id)
return { error: "Attachment not found on this Creative" } unless removed
{ success: true, creative_id: creative.id, removed_signed_id: signed_id }
end
|