2013-02-19 15:16:50 -05:00
|
|
|
require_dependency 'discourse_hub'
|
|
|
|
require_dependency 'discourse_updates'
|
|
|
|
|
|
|
|
module Jobs
|
|
|
|
class VersionCheck < Jobs::Base
|
|
|
|
|
|
|
|
def execute(args)
|
2013-07-03 11:06:07 -04:00
|
|
|
if SiteSetting.version_checks and (DiscourseUpdates.updated_at.nil? or DiscourseUpdates.updated_at < 1.minute.ago)
|
2013-03-25 11:35:33 -04:00
|
|
|
begin
|
|
|
|
json = DiscourseHub.discourse_version_check
|
|
|
|
DiscourseUpdates.latest_version = json['latestVersion']
|
|
|
|
DiscourseUpdates.critical_updates_available = json['criticalUpdates']
|
|
|
|
DiscourseUpdates.missing_versions_count = json['missingVersionsCount']
|
2013-07-03 11:06:07 -04:00
|
|
|
DiscourseUpdates.updated_at = Time.zone.now
|
2013-03-25 11:35:33 -04:00
|
|
|
rescue => e
|
|
|
|
raise e unless Rails.env == 'development' # Fail version check silently in development mode
|
|
|
|
end
|
2013-02-21 10:19:02 -05:00
|
|
|
end
|
2013-02-19 15:16:50 -05:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|