remove Contact.from_header column

This commit is contained in:
Son Nguyen Kim 2021-09-27 12:19:33 +02:00
parent 8301015afd
commit 339d611e63
3 changed files with 29 additions and 13 deletions

View File

@ -1417,8 +1417,6 @@ class Contact(db.Model, ModelMixin):
# to investigate why the website_email is sometimes not correctly parsed
# the envelope mail_from
mail_from = db.Column(db.Text, nullable=True, default=None)
# the message["From"] header
from_header = db.Column(db.Text, nullable=True, default=None)
# a contact can have an empty email address, in this case it can't receive emails
invalid_email = db.Column(

View File

@ -237,16 +237,6 @@ def get_or_create_contact(from_header: str, mail_from: str, alias: Alias) -> Con
)
contact.mail_from = mail_from
db.session.commit()
if not contact.from_header and from_header:
LOG.d(
"Set contact from_header %s: %s to %s",
contact,
contact.from_header,
from_header,
)
contact.from_header = from_header
db.session.commit()
else:
LOG.d(
"create contact %s for alias %s",
@ -261,7 +251,6 @@ def get_or_create_contact(from_header: str, mail_from: str, alias: Alias) -> Con
website_email=contact_email,
name=contact_name,
mail_from=mail_from,
from_header=from_header,
reply_email=generate_reply_email(contact_email, alias.user)
if is_valid_email(contact_email)
else NOREPLY,

View File

@ -0,0 +1,29 @@
"""empty message
Revision ID: 5ee767807344
Revises: b8b4f9598240
Create Date: 2021-09-27 12:19:14.398709
"""
import sqlalchemy_utils
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '5ee767807344'
down_revision = 'b8b4f9598240'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('contact', 'from_header')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('contact', sa.Column('from_header', sa.TEXT(), autoincrement=False, nullable=True))
# ### end Alembic commands ###