mirror of
https://github.com/simple-login/app.git
synced 2024-09-30 05:31:30 +02:00
Merge pull request #118 from simple-login/tmp
Handle empty bounce email
This commit is contained in:
commit
f3a70ca909
@ -108,7 +108,7 @@ with open(DKIM_PUBLIC_KEY_PATH) as f:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
DKIM_HEADERS = [b"from", b"to", b"subject"]
|
DKIM_HEADERS = [b"from", b"to"]
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
DB_URI = os.environ["DB_URI"]
|
DB_URI = os.environ["DB_URI"]
|
||||||
|
@ -982,7 +982,7 @@ class RefusedEmail(db.Model, ModelMixin):
|
|||||||
full_report_path = db.Column(db.String(128), unique=True, nullable=False)
|
full_report_path = db.Column(db.String(128), unique=True, nullable=False)
|
||||||
|
|
||||||
# The original email, to display to user
|
# The original email, to display to user
|
||||||
path = db.Column(db.String(128), unique=True, nullable=False)
|
path = db.Column(db.String(128), unique=True, nullable=True)
|
||||||
|
|
||||||
user_id = db.Column(db.ForeignKey(User.id, ondelete="cascade"), nullable=False)
|
user_id = db.Column(db.ForeignKey(User.id, ondelete="cascade"), nullable=False)
|
||||||
|
|
||||||
@ -993,7 +993,10 @@ class RefusedEmail(db.Model, ModelMixin):
|
|||||||
deleted = db.Column(db.Boolean, nullable=False, default=False, server_default="0")
|
deleted = db.Column(db.Boolean, nullable=False, default=False, server_default="0")
|
||||||
|
|
||||||
def get_url(self, expires_in=3600):
|
def get_url(self, expires_in=3600):
|
||||||
|
if self.path:
|
||||||
return s3.get_url(self.path, expires_in)
|
return s3.get_url(self.path, expires_in)
|
||||||
|
else:
|
||||||
|
return s3.get_url(self.full_report_path, expires_in)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<Refused Email {self.id} {self.path} {self.delete_at}>"
|
return f"<Refused Email {self.id} {self.path} {self.delete_at}>"
|
||||||
|
@ -548,8 +548,12 @@ def handle_bounce(
|
|||||||
full_report_path = f"refused-emails/full-{random_name}.eml"
|
full_report_path = f"refused-emails/full-{random_name}.eml"
|
||||||
s3.upload_email_from_bytesio(full_report_path, BytesIO(msg.as_bytes()), random_name)
|
s3.upload_email_from_bytesio(full_report_path, BytesIO(msg.as_bytes()), random_name)
|
||||||
|
|
||||||
|
file_path = None
|
||||||
|
if orig_msg:
|
||||||
file_path = f"refused-emails/{random_name}.eml"
|
file_path = f"refused-emails/{random_name}.eml"
|
||||||
s3.upload_email_from_bytesio(file_path, BytesIO(orig_msg.as_bytes()), random_name)
|
s3.upload_email_from_bytesio(
|
||||||
|
file_path, BytesIO(orig_msg.as_bytes()), random_name
|
||||||
|
)
|
||||||
|
|
||||||
refused_email = RefusedEmail.create(
|
refused_email = RefusedEmail.create(
|
||||||
path=file_path, full_report_path=full_report_path, user_id=user.id
|
path=file_path, full_report_path=full_report_path, user_id=user.id
|
||||||
|
33
migrations/versions/2020_032216_541ce53ab6e9_.py
Normal file
33
migrations/versions/2020_032216_541ce53ab6e9_.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 541ce53ab6e9
|
||||||
|
Revises: 30c13ca016e4
|
||||||
|
Create Date: 2020-03-22 16:51:01.141010
|
||||||
|
|
||||||
|
"""
|
||||||
|
import sqlalchemy_utils
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '541ce53ab6e9'
|
||||||
|
down_revision = '30c13ca016e4'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.alter_column('refused_email', 'path',
|
||||||
|
existing_type=sa.VARCHAR(length=128),
|
||||||
|
nullable=True)
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.alter_column('refused_email', 'path',
|
||||||
|
existing_type=sa.VARCHAR(length=128),
|
||||||
|
nullable=False)
|
||||||
|
# ### end Alembic commands ###
|
Loading…
Reference in New Issue
Block a user