mirror of
https://github.com/Mailu/Mailu.git
synced 2025-03-03 14:52:36 +02:00
fixed auto-forward
This commit is contained in:
parent
82c1f7dfb4
commit
56f4d4c894
@ -72,7 +72,7 @@ class CommaSeparatedList(db.TypeDecorator):
|
|||||||
return ",".join(value)
|
return ",".join(value)
|
||||||
|
|
||||||
def process_result_value(self, value, dialect):
|
def process_result_value(self, value, dialect):
|
||||||
return filter(bool, value.split(",")) if value else []
|
return list(filter(bool, value.split(","))) if value else []
|
||||||
|
|
||||||
|
|
||||||
class JSONEncoded(db.TypeDecorator):
|
class JSONEncoded(db.TypeDecorator):
|
||||||
|
@ -32,6 +32,14 @@ class DestinationField(fields.SelectMultipleField):
|
|||||||
if not self.validator.match(item):
|
if not self.validator.match(item):
|
||||||
raise validators.ValidationError(_('Invalid email address.'))
|
raise validators.ValidationError(_('Invalid email address.'))
|
||||||
|
|
||||||
|
class MultipleEmailAddressesVerify(object):
|
||||||
|
def __init__(self,message=_('Invalid email address.')):
|
||||||
|
self.message = message
|
||||||
|
|
||||||
|
def __call__(self, form, field):
|
||||||
|
pattern = re.compile(r'^([_a-z0-9\-]+)(\.[_a-z0-9\-]+)*@([a-z0-9\-]{2,}\.)*([a-z]{2,4})(,([_a-z0-9\-]+)(\.[_a-z0-9\-]+)*@([a-z0-9\-]{2,}\.)*([a-z]{2,4}))*$')
|
||||||
|
if not pattern.match(field.data.replace(" ", "")):
|
||||||
|
raise validators.ValidationError(self.message)
|
||||||
|
|
||||||
class ConfirmationForm(flask_wtf.FlaskForm):
|
class ConfirmationForm(flask_wtf.FlaskForm):
|
||||||
submit = fields.SubmitField(_('Confirm'))
|
submit = fields.SubmitField(_('Confirm'))
|
||||||
@ -101,9 +109,7 @@ class UserSettingsForm(flask_wtf.FlaskForm):
|
|||||||
spam_threshold = fields_.IntegerSliderField(_('Spam filter tolerance'))
|
spam_threshold = fields_.IntegerSliderField(_('Spam filter tolerance'))
|
||||||
forward_enabled = fields.BooleanField(_('Enable forwarding'))
|
forward_enabled = fields.BooleanField(_('Enable forwarding'))
|
||||||
forward_keep = fields.BooleanField(_('Keep a copy of the emails'))
|
forward_keep = fields.BooleanField(_('Keep a copy of the emails'))
|
||||||
forward_destination = fields.StringField(
|
forward_destination = fields.StringField(_('Destination'), [validators.Optional(), MultipleEmailAddressesVerify()])
|
||||||
_('Destination'), [validators.Optional(), validators.Email()]
|
|
||||||
)
|
|
||||||
submit = fields.SubmitField(_('Save settings'))
|
submit = fields.SubmitField(_('Save settings'))
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import flask_login
|
|||||||
import wtforms
|
import wtforms
|
||||||
import wtforms_components
|
import wtforms_components
|
||||||
|
|
||||||
|
|
||||||
@ui.route('/user/list/<domain_name>', methods=['GET'])
|
@ui.route('/user/list/<domain_name>', methods=['GET'])
|
||||||
@access.domain_admin(models.Domain, 'domain_name')
|
@access.domain_admin(models.Domain, 'domain_name')
|
||||||
def user_list(domain_name):
|
def user_list(domain_name):
|
||||||
@ -92,9 +91,16 @@ def user_settings(user_email):
|
|||||||
user_email_or_current = user_email or flask_login.current_user.email
|
user_email_or_current = user_email or flask_login.current_user.email
|
||||||
user = models.User.query.get(user_email_or_current) or flask.abort(404)
|
user = models.User.query.get(user_email_or_current) or flask.abort(404)
|
||||||
form = forms.UserSettingsForm(obj=user)
|
form = forms.UserSettingsForm(obj=user)
|
||||||
|
if isinstance(form.forward_destination.data,str):
|
||||||
|
data = form.forward_destination.data.replace(" ","").split(",")
|
||||||
|
else:
|
||||||
|
data = form.forward_destination.data
|
||||||
|
form.forward_destination.data = ", ".join(data)
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
|
form.forward_destination.data = form.forward_destination.data.replace(" ","").split(",")
|
||||||
form.populate_obj(user)
|
form.populate_obj(user)
|
||||||
models.db.session.commit()
|
models.db.session.commit()
|
||||||
|
form.forward_destination.data = ", ".join(form.forward_destination.data)
|
||||||
flask.flash('Settings updated for %s' % user)
|
flask.flash('Settings updated for %s' % user)
|
||||||
if user_email:
|
if user_email:
|
||||||
return flask.redirect(
|
return flask.redirect(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user