-
-
Notifications
You must be signed in to change notification settings - Fork 530
Ability to block domains when receiving emails #2 #2384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
7f01f4f to
8aa10b5
Compare
|
|
||
| domain = sa.Column(sa.String(128), nullable=False) | ||
|
|
||
| user_id = sa.Column(sa.ForeignKey(User.id, ondelete="cascade"), nullable=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's missing a composite index with user_id and domain to avoid full table scans.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the previous line I have this constraint:
__table_args__ = (
sa.UniqueConstraint("user_id", "domain", name="uq_blocked_domain"),
)This should create that composite index. I checked in my environment and I see that index created automatically.
But let me know if I misunderstand something.
|
I updated the code, except the one where I asked the question |
|
@tozo can you please add also sender block? Now SL doesn't have option to block sender and/or domain account wide. What stops spammer from if I block him in [email protected] just send emails to [email protected]? As I see, such adresses created automatically by default on subdomains. So this feature will help against this. |
|
@aksolotl222 If I understand you correctly this PR does what you describe. You can block complete domains so no matter what email addresses the sender use on that domain they all will be blocked. |
|
Hi @acasajus Could you let me know if there is any other changes that need to be done? |
updating ui adding tests, fixing bugs
moved the function is_domain_blocked into its own utils refactoring the function can_domain_be_used
| ) | ||
|
|
||
| new_domain = sanitize_domain(domain) | ||
| domain_forbidden_cause = can_domain_be_used(user, new_domain) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this changed. This would allow users to create a custom domain with an invalid domain or an SL domain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the original code I modified the existing and created 2 separate functions (can_domain_be_used, can_custom_domain_be_used and can_blocked_domain_be_used respectively).
Because of that I also had to change this to call the function can_custom_domain_be_used to still include all the previously executed checks.
But inside of that function I call the can_domain_be_used which should check for the domain validity and SL domain as well and if that reason is not None, then return with that error.
Currently in this branch that call is in line 119:
reason = can_domain_be_used(user, domain)
if reason is not None:
return reason
|
Guys, can you also add ability to
What do you think? |
Sorry, I had to recreate this PR.
This PR adds the functionality to block domains so that the user won't receive emails no matter which email was used from that domain.
It's mainly to prevent spam emails coming from the same domain but from different email addresses.
Since this feature is not tied to a specific alias/custom domain I added it to the setting page.
Let me know if there is a better place for this feature or if anything else needs to be changed.
Note: This feature was discussed here: #1344
Couple of screenshots:
Default view:

Page once domains are blocked:
