diff --git a/app/classes/shared/helpers.py b/app/classes/shared/helpers.py index 5955548e..7cc87b68 100644 --- a/app/classes/shared/helpers.py +++ b/app/classes/shared/helpers.py @@ -82,6 +82,7 @@ class Helpers: self.translation = Translation(self) self.update_available = False self.ignored_names = ["crafty_managed.txt", "db_stats"] + self.announcements = [] @staticmethod def auto_installer_fix(ex): @@ -579,7 +580,7 @@ class Helpers: return version_data - def get_announcements(self): + def refresh_announcements(self): data = [] try: response = requests.get("https://craftycontrol.com/notify", timeout=2) @@ -587,6 +588,10 @@ class Helpers: except Exception as e: logger.error(f"Failed to fetch notifications with error: {e}") + self.announcements = data + + def get_announcements(self): + data = self.announcements if self.update_available: data.append(self.update_available) return data diff --git a/app/classes/shared/tasks.py b/app/classes/shared/tasks.py index a117452f..8d27ddb2 100644 --- a/app/classes/shared/tasks.py +++ b/app/classes/shared/tasks.py @@ -200,6 +200,14 @@ class TasksManager: id="update_watcher", start_date=datetime.datetime.now(), ) + self.helper.refresh_announcements() + self.scheduler.add_job( + self.helper.refresh_announcements, + "interval", + hours=1, + id="annoucement_watcher", + start_date=datetime.datetime.now(), + ) # self.scheduler.add_job( # self.scheduler.print_jobs, "interval", seconds=10, id="-1" # ) diff --git a/app/frontend/templates/notify.html b/app/frontend/templates/notify.html index 4348fad5..f8c3ad9e 100644 --- a/app/frontend/templates/notify.html +++ b/app/frontend/templates/notify.html @@ -7,7 +7,8 @@ text-danger {% end %} "> -