From c4432b7823ec7c420237e5303b3ead391ea84b39 Mon Sep 17 00:00:00 2001 From: axolotle Date: Wed, 23 Nov 2022 16:05:11 +0100 Subject: [PATCH] app_upgrade: display pre and post notifications --- src/app.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/app.py b/src/app.py index fac0bd484..ef8b54a01 100644 --- a/src/app.py +++ b/src/app.py @@ -598,6 +598,19 @@ def app_upgrade(app=[], url=None, file=None, force=False, no_safety_backup=False else: raise YunohostValidationError(err, **values) + # Display pre-upgrade notifications and ask for simple confirm + if ( + manifest["notifications"]["pre_upgrade"] + and Moulinette.interface.type == "cli" + ): + settings = _get_app_settings(app_instance_name) + notifications = _filter_and_hydrate_notifications( + manifest["notifications"]["pre_upgrade"], + current_version=app_current_version, + data=settings, + ) + _display_notifications(notifications, force=force) + if manifest["packaging_format"] >= 2: if no_safety_backup: # FIXME: i18n @@ -780,6 +793,21 @@ def app_upgrade(app=[], url=None, file=None, force=False, no_safety_backup=False # So much win logger.success(m18n.n("app_upgraded", app=app_instance_name)) + # Display post-upgrade notifications and ask for simple confirm + if ( + manifest["notifications"]["post_upgrade"] + and Moulinette.interface.type == "cli" + ): + # Get updated settings to hydrate notifications + settings = _get_app_settings(app_instance_name) + notifications = _filter_and_hydrate_notifications( + manifest["notifications"]["post_upgrade"], + current_version=app_current_version, + data=settings, + ) + _display_notifications(notifications, force=force) + # FIXME Should return a response with post upgrade notif formatted with the newest settings to the web-admin + hook_callback("post_app_upgrade", env=env_dict) operation_logger.success()