Merge pull request #35 from simple-login/directory-separator

Directory separator
This commit is contained in:
Son Nguyen Kim 2020-01-20 10:23:00 +01:00 committed by GitHub
commit 448d9d1a01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 9 deletions

View File

@ -36,3 +36,10 @@ jobs:
name: simplelogin/app
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Send Telegram message
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
args: New Docker image pushed

View File

@ -11,16 +11,27 @@
<h1 class="h3"> Directories </h1>
{% if not current_user.is_premium() %}
<div class="alert alert-danger" role="alert">
This feature is only available in premium plan.
</div>
<div class="alert alert-danger" role="alert">
This feature is only available in premium plan.
</div>
{% endif %}
<div class="alert alert-primary" role="alert">
Directory allows you to create aliases <b>on the fly</b>. <br>
Simply use <em>directory/<b>anything</b>@{{ EMAIL_DOMAIN }}</em>
Directory allows you to create aliases <b>on the fly</b>. Simply use <br>
<div class="pl-3 py-2 bg-white">
<em>your_directory/<b>anything</b>@{{ EMAIL_DOMAIN }}</em> or <br>
<em>your_directory+<b>anything</b>@{{ EMAIL_DOMAIN }}</em> or <br>
<em>your_directory#<b>anything</b>@{{ EMAIL_DOMAIN }}</em> <br>
</div>
next time you need an email address. <br>
The alias will be created the first time it receives an email.
<em><b>anything</b></em> could really be anything, it's up to you to invent the most creative alias 😉. <br>
<em>your_directory</em> is the name of one of your directories. <br>
<div class="h4 text-primary mt-3">
The alias will be created the first time it receives an email.
</div>
</div>
{% for dir in dirs %}

View File

@ -51,6 +51,11 @@ def directory():
if Directory.get_by(name=new_dir_name):
flash(f"{new_dir_name} already added", "warning")
elif new_dir_name == "reply":
flash(
"directory name cannot be *reply*, please choose another name",
"warning",
)
else:
new_dir = Directory.create(
name=new_dir_name, user_id=current_user.id

View File

@ -121,13 +121,20 @@ class MailHandler:
# check if alias belongs to a directory, ie having directory/anything@EMAIL_DOMAIN format
if alias.endswith(EMAIL_DOMAIN):
if "/" in alias:
directory_name = alias[: alias.find("/")]
if "/" in alias or "+" in alias or "#" in alias:
if "/" in alias:
sep = "/"
elif "+" in alias:
sep = "+"
else:
sep = "#"
directory_name = alias[: alias.find(sep)]
LOG.d("directory_name %s", directory_name)
directory = Directory.get_by(name=directory_name)
# Only premium user can continue using the directory feature
# Only premium user can use the directory feature
if directory:
dir_user = directory.user
if dir_user.is_premium():