2022-05-06 12:20:57 +02:00
|
|
|
class Attachment::ShowComponent < ApplicationComponent
|
2024-04-08 10:13:05 +02:00
|
|
|
def initialize(attachment:, new_tab: false, truncate: false)
|
2022-05-06 12:20:57 +02:00
|
|
|
@attachment = attachment
|
2022-12-05 15:59:50 +01:00
|
|
|
@new_tab = new_tab
|
2024-04-08 10:13:05 +02:00
|
|
|
@truncate = truncate
|
2022-05-06 12:20:57 +02:00
|
|
|
end
|
|
|
|
|
2024-04-08 10:13:05 +02:00
|
|
|
attr_reader :attachment, :new_tab, :truncate
|
2022-05-06 12:20:57 +02:00
|
|
|
|
|
|
|
def should_display_link?
|
|
|
|
(attachment.virus_scanner.safe? || !attachment.virus_scanner.started?) && !attachment.watermark_pending?
|
|
|
|
end
|
|
|
|
|
2022-11-09 12:33:20 +01:00
|
|
|
def error_message
|
|
|
|
case
|
|
|
|
when attachment.virus_scanner.infected?
|
2022-11-22 19:25:45 +01:00
|
|
|
t(".errors.virus_infected")
|
2022-11-09 12:33:20 +01:00
|
|
|
when attachment.virus_scanner.corrupt?
|
2022-11-22 19:25:45 +01:00
|
|
|
t(".errors.corrupted_file")
|
2022-11-09 12:33:20 +01:00
|
|
|
end
|
2022-05-06 12:20:57 +02:00
|
|
|
end
|
|
|
|
|
2022-11-09 12:33:20 +01:00
|
|
|
def error?
|
|
|
|
attachment.virus_scanner_error?
|
2022-05-06 12:20:57 +02:00
|
|
|
end
|
|
|
|
end
|