html content

This commit is contained in:
Andreas Knuth 2026-01-24 16:37:46 -06:00
parent 424175fe72
commit adad46ce7d
1 changed files with 21 additions and 11 deletions

View File

@ -16,16 +16,14 @@ table = dynamodb.Table(TABLE)
def generate_sieve(email, rules):
"""Generate Sieve script from DynamoDB rules"""
script = [
'require ["copy","vacation","variables"];',
'',
'# Skip if already processed by worker',
'if header :contains "X-SES-Worker-Processed" "" {',
' keep;',
' stop;',
'}',
''
]
script = ['require ["copy","vacation","variables"];']
# Skip if already processed by worker
script.append('# Skip if already processed by worker')
script.append('if header :contains "X-SES-Worker-Processed" "" {')
script.append(' keep;')
script.append(' stop;')
script.append('}')
# Forwards
forwards = rules.get('forwards', [])
@ -37,7 +35,19 @@ def generate_sieve(email, rules):
# OOO
if rules.get('ooo_active'):
msg = rules.get('ooo_message', 'I am away')
content_type = rules.get('ooo_content_type', 'text')
script.append('# rule:[reply]')
if content_type == 'html':
# HTML mit :mime
script.append(f'vacation :days 1 :from "{email}" :mime text:')
script.append(f'Content-Type: text/html; charset=utf-8')
script.append(f'')
script.append(msg)
script.append('.')
else:
# Plain text
script.append(f'vacation :days 1 :from "{email}" "{msg}";')
return '\n'.join(script)