sharing/bday/summary: check for not to be empty

This commit is contained in:
Peter Bieringer
2026-05-31 07:26:19 +02:00
parent 8a28141c3e
commit d6369588f4
3 changed files with 30 additions and 3 deletions

View File

@@ -597,7 +597,7 @@ DEFAULT_CONFIG_SCHEMA: types.CONFIG_SCHEMA = OrderedDict([
("conversion_bday_summary_template", {
"value": sharing.SHARING_BDAY_SUMMARY_TEMPLATE_DEFAULT,
"help": "conversion bday summary template",
"type": sharing.check_template}),
"type": sharing.check_template_not_empty}),
("conversion_bday_description_template", {
"value": sharing.SHARING_BDAY_DESCRIPTION_TEMPLATE_DEFAULT,
"help": "conversion bday description template",

View File

@@ -152,6 +152,13 @@ def check_template(data: Any) -> str:
return data
def check_template_not_empty(data: Any) -> str:
result = check_template(data)
if result == "":
raise ValueError("template not allowed to be empty")
return data
def check_template_alarm_trigger(data: Any) -> str:
if data is not None and data != '':
for entry in data.split('|'):
@@ -169,7 +176,7 @@ def check_template_alarm_trigger(data: Any) -> str:
if alarm_description is not None and alarm_description != '':
try:
check_template(alarm_description)
check_template_not_empty(alarm_description)
except Exception as e:
raise e
else:
@@ -179,7 +186,7 @@ def check_template_alarm_trigger(data: Any) -> str:
ACTIONS_WHITELIST: dict = {
'config': {
'conversion_bday_summary_template': check_template,
'conversion_bday_summary_template': check_template_not_empty,
'conversion_bday_description_template': check_template,
'conversion_bday_alarm_trigger_template': check_template_alarm_trigger,
'conversion_bday_categories': str,

View File

@@ -5097,6 +5097,26 @@ permissions: RrWw""")
else:
raise
logging.info("\n*** configuration test: conversion_bday_summary_template empty")
try:
self.configure({"sharing": {
"conversion_bday_summary_template": "",
}})
except RuntimeError:
pass
else:
raise
logging.info("\n*** configuration test: conversion_bday_description_template empty")
try:
self.configure({"sharing": {
"conversion_bday_description_template": "",
}})
except RuntimeError:
pass
else:
pass
logging.info("\n*** configuration test: conversion_bday_alarm_trigger_template not supported")
try:
self.configure({"sharing": {