sdfdsf
This commit is contained in:
parent
adad46ce7d
commit
30e928c6e6
|
|
@ -16,41 +16,45 @@ table = dynamodb.Table(TABLE)
|
||||||
|
|
||||||
def generate_sieve(email, rules):
|
def generate_sieve(email, rules):
|
||||||
"""Generate Sieve script from DynamoDB rules"""
|
"""Generate Sieve script from DynamoDB rules"""
|
||||||
script = ['require ["copy","vacation","variables"];']
|
lines = ['require ["copy","vacation","variables"];', '']
|
||||||
|
|
||||||
# Skip if already processed by worker
|
# Skip if already processed by worker
|
||||||
script.append('# Skip if already processed by worker')
|
lines.extend([
|
||||||
script.append('if header :contains "X-SES-Worker-Processed" "" {')
|
'# Skip if already processed by worker',
|
||||||
script.append(' keep;')
|
'if header :contains "X-SES-Worker-Processed" "" {',
|
||||||
script.append(' stop;')
|
' keep;',
|
||||||
script.append('}')
|
' stop;',
|
||||||
|
'}',
|
||||||
|
''
|
||||||
|
])
|
||||||
|
|
||||||
# Forwards
|
# Forwards
|
||||||
forwards = rules.get('forwards', [])
|
forwards = rules.get('forwards', [])
|
||||||
if forwards:
|
if forwards:
|
||||||
script.append('# rule:[forward]')
|
lines.append('# rule:[forward]')
|
||||||
for fwd in forwards:
|
for fwd in forwards:
|
||||||
script.append(f'redirect :copy "{fwd}";')
|
lines.append(f'redirect :copy "{fwd}";')
|
||||||
|
lines.append('')
|
||||||
|
|
||||||
# OOO
|
# OOO
|
||||||
if rules.get('ooo_active'):
|
if rules.get('ooo_active'):
|
||||||
msg = rules.get('ooo_message', 'I am away')
|
msg = rules.get('ooo_message', 'I am away')
|
||||||
content_type = rules.get('ooo_content_type', 'text')
|
content_type = rules.get('ooo_content_type', 'text')
|
||||||
|
|
||||||
script.append('# rule:[reply]')
|
lines.append('# rule:[reply]')
|
||||||
|
|
||||||
if content_type == 'html':
|
if content_type == 'html':
|
||||||
# HTML mit :mime
|
lines.extend([
|
||||||
script.append(f'vacation :days 1 :from "{email}" :mime text:')
|
f'vacation :days 1 :from "{email}" :mime text:',
|
||||||
script.append(f'Content-Type: text/html; charset=utf-8')
|
'Content-Type: text/html; charset=utf-8',
|
||||||
script.append(f'')
|
'',
|
||||||
script.append(msg)
|
msg,
|
||||||
script.append('.')
|
'.'
|
||||||
|
])
|
||||||
else:
|
else:
|
||||||
# Plain text
|
lines.append(f'vacation :days 1 :from "{email}" "{msg}";')
|
||||||
script.append(f'vacation :days 1 :from "{email}" "{msg}";')
|
|
||||||
|
|
||||||
return '\n'.join(script)
|
return '\n'.join(lines)
|
||||||
|
|
||||||
def sync():
|
def sync():
|
||||||
"""Sync all rules from DynamoDB to Sieve"""
|
"""Sync all rules from DynamoDB to Sieve"""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue