Adding SQL Like format for aliases

master
XYunknown 8 years ago
parent b3d7b657ab
commit 6d4243ec66

@ -86,6 +86,8 @@ class UserReplyForm(Form):
class AliasForm(Form):
localpart = fields.StringField('Alias', [validators.DataRequired()])
wildcard = fields.BooleanField(
'Use SQL Like Syntax (e.g. for catch-all aliases, admin-%@domain.com)')
destination = DestinationField('Destination')
comment = fields.StringField('Comment')
submit = fields.SubmitField('Create')

@ -189,6 +189,7 @@ class Alias(Email):
"""
domain = db.relationship(Domain,
backref=db.backref('aliases', cascade='all, delete-orphan'))
wildcard = db.Column(db.Boolean(), default=False)
destination = db.Column(CommaSeparatedList, nullable=False, default=[])

@ -12,6 +12,7 @@ Create alias
<form class="form" method="post" role="form">
{{ form.hidden_tag() }}
{{ macros.form_field(form.localpart, append='<span class="input-group-addon">@'+domain.name+'</span>') }}
{{ macros.form_field(form.wildcard) }}
{{ macros.form_field(form.destination, id='destination') }}
{{ macros.form_field(form.comment) }}
{{ macros.form_field(form.submit) }}

@ -1,5 +1,11 @@
dbpath = /data/freeposte.db
query =
SELECT destination
FROM alias
WHERE alias.email = '%s'
FROM alias
WHERE alias.email = '%s'
AND alias.wildcard = 0
UNION SELECT destination
FROM alias
WHERE '%s' LIKE alias.email
AND alias.wildcard = 1
LIMIT 1

Loading…
Cancel
Save