mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 17:13:25 +08:00
FIX: Error when an invalid date is passed to certificate generator.
https://meta.discourse.org/t/broken-image-in-discobot-certificate-with-no-logo-small-url/76594/2
This commit is contained in:
@ -2,7 +2,19 @@ module DiscourseNarrativeBot
|
||||
class CertificateGenerator
|
||||
def initialize(user, date)
|
||||
@user = user
|
||||
@date = I18n.l(Date.parse(date), format: :date_only)
|
||||
|
||||
date =
|
||||
begin
|
||||
Date.parse(date)
|
||||
rescue ArgumentError => e
|
||||
if e.message == 'invalid date'
|
||||
Date.parse(Date.today.to_s)
|
||||
else
|
||||
raise e
|
||||
end
|
||||
end
|
||||
|
||||
@date = I18n.l(date, format: :date_only)
|
||||
@discobot_user = User.find(-2)
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user