From 8a6fa34040789a4e849ff115e311f6e1b500f42d Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 2 Oct 2023 16:42:52 +0200 Subject: [PATCH] Fix incorrectly keeping outdated update notices absent from the API endpoint (#27021) --- app/services/software_update_check_service.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/services/software_update_check_service.rb b/app/services/software_update_check_service.rb index 49b92f104db..c8ce1753f5f 100644 --- a/app/services/software_update_check_service.rb +++ b/app/services/software_update_check_service.rb @@ -35,11 +35,13 @@ class SoftwareUpdateCheckService < BaseService end def process_update_notices!(update_notices) - return if update_notices.blank? || update_notices['updatesAvailable'].blank? + return if update_notices.blank? || update_notices['updatesAvailable'].nil? # Clear notices that are not listed by the update server anymore SoftwareUpdate.where.not(version: update_notices['updatesAvailable'].pluck('version')).delete_all + return if update_notices['updatesAvailable'].blank? + # Check if any of the notices is new, and issue notifications known_versions = SoftwareUpdate.where(version: update_notices['updatesAvailable'].pluck('version')).pluck(:version) new_update_notices = update_notices['updatesAvailable'].filter { |notice| known_versions.exclude?(notice['version']) }