Order alias by latest activity instead of alias creation date. Show the latest activity & contact
This commit is contained in:
parent
af9178e216
commit
460c306712
|
@ -135,19 +135,39 @@
|
||||||
<hr class="my-2">
|
<hr class="my-2">
|
||||||
|
|
||||||
<p class="small-text">
|
<p class="small-text">
|
||||||
Created {{ alias.created_at | dt }}
|
|
||||||
{% if alias_info.highlight %}
|
{% if alias_info.highlight %}
|
||||||
- <span class="font-weight-bold text-success small-text">New</span>
|
- <span class="font-weight-bold text-success small-text">New</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="" style="font-size: 12px">
|
<div class="" style="font-size: 12px">
|
||||||
|
{% if alias_info.latest_email_log != None %}
|
||||||
|
{% set email_log = alias_info.latest_email_log %}
|
||||||
|
{% set contact = alias_info.latest_contact %}
|
||||||
|
|
||||||
|
{% if email_log.is_reply %}
|
||||||
|
Email sent/reply to {{ contact.website_email }}
|
||||||
|
{{ email_log.created_at | dt }}
|
||||||
|
{% elif email_log.bounced %}
|
||||||
|
<span class="text-danger">Email from {{ contact.website_email }} bounced
|
||||||
|
{{ email_log.created_at | dt }}
|
||||||
|
</span>
|
||||||
|
{% elif email_log.blocked %}
|
||||||
|
Email from {{ contact.website_email }} blocked
|
||||||
|
{{ email_log.created_at | dt }}
|
||||||
|
{% else %}
|
||||||
|
Email from {{ contact.website_email }}
|
||||||
|
{{ email_log.created_at | dt }}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
<br>
|
||||||
|
|
||||||
<span class="alias-activity">{{ alias_info.nb_forward }}</span> forwards,
|
<span class="alias-activity">{{ alias_info.nb_forward }}</span> forwards,
|
||||||
<span class="alias-activity">{{ alias_info.nb_blocked }}</span> blocks,
|
<span class="alias-activity">{{ alias_info.nb_blocked }}</span> blocks,
|
||||||
<span class="alias-activity">{{ alias_info.nb_reply }}</span> replies
|
<span class="alias-activity">{{ alias_info.nb_reply }}</span> replies
|
||||||
<a href="{{ url_for('dashboard.alias_log', alias_id=alias.id) }}"
|
<a href="{{ url_for('dashboard.alias_log', alias_id=alias.id) }}"
|
||||||
class="btn btn-sm btn-link">
|
class="btn btn-sm btn-link">
|
||||||
See All Activity →
|
See All →
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,15 @@ from app.models import (
|
||||||
class AliasInfo:
|
class AliasInfo:
|
||||||
alias: Alias
|
alias: Alias
|
||||||
mailbox: Mailbox
|
mailbox: Mailbox
|
||||||
|
|
||||||
nb_forward: int
|
nb_forward: int
|
||||||
nb_blocked: int
|
nb_blocked: int
|
||||||
nb_reply: int
|
nb_reply: int
|
||||||
|
|
||||||
|
latest_activity: Arrow
|
||||||
|
latest_email_log: EmailLog = None
|
||||||
|
latest_contact: Contact = None
|
||||||
|
|
||||||
show_intro_test_send_email: bool = False
|
show_intro_test_send_email: bool = False
|
||||||
highlight: bool = False
|
highlight: bool = False
|
||||||
|
|
||||||
|
@ -210,12 +215,18 @@ def get_alias_infos(user, query=None, highlight_alias_id=None) -> [AliasInfo]:
|
||||||
nb_forward=0,
|
nb_forward=0,
|
||||||
nb_reply=0,
|
nb_reply=0,
|
||||||
highlight=alias.id == highlight_alias_id,
|
highlight=alias.id == highlight_alias_id,
|
||||||
|
latest_activity=alias.created_at,
|
||||||
)
|
)
|
||||||
|
|
||||||
alias_info = aliases[alias.email]
|
alias_info = aliases[alias.email]
|
||||||
if not email_log:
|
if not email_log:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if email_log.created_at > alias_info.latest_activity:
|
||||||
|
alias_info.latest_activity = email_log.created_at
|
||||||
|
alias_info.latest_email_log = email_log
|
||||||
|
alias_info.latest_contact = contact
|
||||||
|
|
||||||
if email_log.is_reply:
|
if email_log.is_reply:
|
||||||
alias_info.nb_reply += 1
|
alias_info.nb_reply += 1
|
||||||
elif email_log.blocked:
|
elif email_log.blocked:
|
||||||
|
@ -224,6 +235,7 @@ def get_alias_infos(user, query=None, highlight_alias_id=None) -> [AliasInfo]:
|
||||||
alias_info.nb_forward += 1
|
alias_info.nb_forward += 1
|
||||||
|
|
||||||
ret = list(aliases.values())
|
ret = list(aliases.values())
|
||||||
|
ret = sorted(ret, key=lambda a: a.latest_activity, reverse=True)
|
||||||
|
|
||||||
# make sure the highlighted alias is the first element
|
# make sure the highlighted alias is the first element
|
||||||
highlight_index = None
|
highlight_index = None
|
||||||
|
|
|
@ -732,7 +732,6 @@ class Contact(db.Model, ModelMixin):
|
||||||
db.String(512), nullable=True, default=None, server_default=text("NULL")
|
db.String(512), nullable=True, default=None, server_default=text("NULL")
|
||||||
)
|
)
|
||||||
|
|
||||||
# used to be envelope header, should be mail header from instead
|
|
||||||
website_email = db.Column(db.String(512), nullable=False)
|
website_email = db.Column(db.String(512), nullable=False)
|
||||||
|
|
||||||
# the email from header, e.g. AB CD <ab@cd.com>
|
# the email from header, e.g. AB CD <ab@cd.com>
|
||||||
|
|
Loading…
Reference in a new issue