app_upgrade: display pre and post notifications

This commit is contained in:
axolotle 2022-11-23 16:05:11 +01:00
parent cdcd967eb1
commit c4432b7823

View file

@ -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()