3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/controllers/spree/digital_links_controller.rb', line 3
def show
if digital_link.authorize!
if digital_link.downloadable?
mark_shipment_as_fullfiled if digital_link.access_counter == 1
if defined?(ActiveStorage::Service::DiskService) && ActiveStorage::Blob.service.instance_of?(ActiveStorage::Service::DiskService)
send_file(
ActiveStorage::Blob.service.path_for(attachment.key),
filename: digital_link.filename.to_s,
type: digital_link.content_type.to_s,
status: :ok
) and return
else
redirect_to attachment.url(
expires_in: current_store.preferred_digital_asset_link_expire_time.seconds,
disposition: 'attachment'
), allow_other_host: true and return
end
else
flash[:error] = I18n.t('spree.api.v2.digitals.unpaid')
if try_spree_current_user.present?
redirect_to spree.order_path(digital_link.order) and return
else
redirect_to root_path and return
end
end
end
flash[:error] = Spree.t(:digital_link_unauthorized)
if try_spree_current_user.present?
redirect_to spree.order_path(digital_link.order) and return
else
redirect_to root_path and return
end
end
|