Coder Social home page Coder Social logo

Comments (7)

kaiyou avatar kaiyou commented on April 28, 2024 1

I just pushed a commit that implements :

  • a WTForm field class that handles validation based on the SelectMultipleField that you suggested,
  • a database type for comma separated lists to keep the Postfix compatibility without adding the complexity of a relation table.

What do you think of it? Still testing the forwarding part locally but it seems to fix the bug at least.

from mailu.

kaiyou avatar kaiyou commented on April 28, 2024 1

Thank you for your feedback, I'm closing the issue then.

from mailu.

kaiyou avatar kaiyou commented on April 28, 2024

I renamed the issue to better describe the bug. When editing an alias with multiple destinations, only the first email address is saved. This could be related to using select2 for aliases.

from mailu.

jkarlosb avatar jkarlosb commented on April 28, 2024

I was debugging for this issue and I found that the problem is due to use SelectField instead SelectMultipleField into class AliasForm() of forms.py:

class AliasForm(Form):
    localpart = fields.StringField('Alias', [validators.DataRequired()])
    destination = fields.SelectField('Destination')
    comment = fields.StringField('Comment')
    submit = fields.SubmitField('Create')

Because I noticed that in aliases.py, the method form.populate_obj(alias) into edit_alias() only populated one destination, data field instead raw_data field. After I changed to SelectMultipleField, data field contains multiple destinations.

But the problem is that database is not prepared for this change because is necessary introducing an array in the destination field of alias table, this is it sql schema:

CREATE TABLE alias (
    created_at DATE NOT NULL,
    updated_at DATE,
    comment VARCHAR(255),
    localpart VARCHAR(80) NOT NULL,
    destination VARCHAR NOT NULL,
    domain_name VARCHAR(80) NOT NULL,
    email VARCHAR(255) NOT NULL,
    PRIMARY KEY (email),
    FOREIGN KEY(domain_name) REFERENCES domain (name)
);

And this is the output error when I try add multiples detinations with SelectMultipleField:

sqlalchemy.exc.InterfaceError: (sqlite3.InterfaceError) Error binding parameter 1 - probably unsupported type. [SQL: 'UPDATE alias SET updated_at=?, destination=? WHERE alias.email = ?'] [parameters: ('2016-08-11', ['[email protected]', '[email protected]'], '[email protected]')]

As this bd is SQLite, we must add a relational table. Other solutions are using BLOB (as a workaround) or using no-sql db as MongoDB (maybe the optimal solution, because it support arrays as type).

Another problem is the way that Postfix query aliases ...

Meanwhile there is a workaround here (#34)

I can handle this by creating a new branch, but I need to know how proceded with this problem.

How do yo see it?

from mailu.

kaiyou avatar kaiyou commented on April 28, 2024

There are two problems with using a relational table here :

  1. it adds complexity without improving performance (either storage or access performance)
  2. postfix will be fine with a database accessed relational table but we would have to implement a different scheme for redictions because Dovecot does not support relational tables at all.

from mailu.

kaiyou avatar kaiyou commented on April 28, 2024

Prior to using Select2 we were using tagsinput (4853e54) which worked perfectly because it stored a comma separated list (Postfix compatible format) and read from the same list.

Maybe Select2 supports this as well, which would make for the simplest fix at stay compatible with both Postfix and Dovecot.

from mailu.

jkarlosb avatar jkarlosb commented on April 28, 2024

Great work! It is perfect and simply for now.

I pulled the latest automatic build freeposte/admin image and I tested it with a couple of destinations and It works fine. Congrats!

from mailu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.