[Dovecot] Show last mail (pop3, imap) login in web interface

This commit is contained in:
andryyy 2020-02-25 19:38:20 +01:00
parent cbe7d7c578
commit c785c8f700
No known key found for this signature in database
GPG Key ID: 8EC34FF2794E25EF
7 changed files with 23 additions and 9 deletions

View File

@ -41,6 +41,14 @@ map {
}
EOF
# Write last logins to Redis
if [[ ! -z ${REDIS_SLAVEOF_IP} ]]; then
cp /etc/syslog-ng/syslog-ng-redis_slave.conf /etc/syslog-ng/syslog-ng.conf
echo -n "redis:host=${REDIS_SLAVEOF_IP}:port={REDIS_SLAVEOF_PORT}" > /etc/dovecot/last_login
else
echo -n "redis:host=${IPV4_NETWORK}.249:port=6379" > /etc/dovecot/last_login
fi
# Create dict used for sieve pre and postfilters
cat <<EOF > /etc/dovecot/sql/dovecot-dict-sql-sieve_before.conf
# Autogenerated by mailcow
@ -91,12 +99,12 @@ EOF
echo -n ${ACL_ANYONE} > /etc/dovecot/acl_anyone
if [[ "${SKIP_SOLR}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
echo -n 'quota acl zlib listescape mail_crypt mail_crypt_acl mail_log notify replication' > /etc/dovecot/mail_plugins
echo -n 'quota imap_quota imap_acl acl zlib imap_zlib imap_sieve listescape mail_crypt mail_crypt_acl notify replication mail_log' > /etc/dovecot/mail_plugins_imap
echo -n 'quota acl zlib listescape mail_crypt mail_crypt_acl mail_log notify replication last_login' > /etc/dovecot/mail_plugins
echo -n 'quota imap_quota imap_acl acl zlib imap_zlib imap_sieve listescape mail_crypt mail_crypt_acl notify replication mail_log last_login' > /etc/dovecot/mail_plugins_imap
echo -n 'quota sieve acl zlib listescape mail_crypt mail_crypt_acl notify replication' > /etc/dovecot/mail_plugins_lmtp
else
echo -n 'quota acl zlib listescape mail_crypt mail_crypt_acl mail_log notify fts fts_solr replication' > /etc/dovecot/mail_plugins
echo -n 'quota imap_quota imap_acl acl zlib imap_zlib imap_sieve listescape mail_crypt mail_crypt_acl notify mail_log fts fts_solr replication' > /etc/dovecot/mail_plugins_imap
echo -n 'quota acl zlib listescape mail_crypt mail_crypt_acl mail_log notify fts fts_solr replication last_login' > /etc/dovecot/mail_plugins
echo -n 'quota imap_quota imap_acl acl zlib imap_zlib imap_sieve listescape mail_crypt mail_crypt_acl notify mail_log fts fts_solr replication last_login' > /etc/dovecot/mail_plugins_imap
echo -n 'quota sieve acl zlib listescape mail_crypt mail_crypt_acl fts fts_solr notify replication' > /etc/dovecot/mail_plugins_lmtp
fi
chmod 644 /etc/dovecot/mail_plugins /etc/dovecot/mail_plugins_imap /etc/dovecot/mail_plugins_lmtp /templates/quarantine.tpl
@ -339,8 +347,4 @@ done
# May be related to something inside Docker, I seriously don't know
touch /etc/dovecot/lua/app-passdb.lua
if [[ ! -z ${REDIS_SLAVEOF_IP} ]]; then
cp /etc/syslog-ng/syslog-ng-redis_slave.conf /etc/syslog-ng/syslog-ng.conf
fi
exec "$@"

View File

@ -313,6 +313,8 @@ plugin {
acl_anyone = </etc/dovecot/acl_anyone
acl_shared_dict = file:/var/vmail/shared-mailboxes.db
acl = vfile
last_login_dict=</etc/dovecot/last_login
last_login_key = last-login/%u
fts = solr
fts_autoindex = yes
fts_solr = url=http://solr:8983/solr/dovecot-fts/

View File

@ -3170,6 +3170,10 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
}
$mailboxdata = array();
$rl = ratelimit('get', 'mailbox', $_data);
$last_mail_login = $redis->Get('last-login/' . $_data);
if ($last_mail_login === false) {
$last_mail_login = '';
}
$stmt = $pdo->prepare("SELECT
`domain`.`backupmx`,
`mailbox`.`username`,
@ -3212,6 +3216,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
}
$mailboxdata['is_relayed'] = $row['backupmx'];
$mailboxdata['name'] = $row['name'];
$mailboxdata['last_mail_login'] = $last_mail_login;
$mailboxdata['active'] = $row['active'];
$mailboxdata['active_int'] = $row['active_int'];
$mailboxdata['domain'] = $row['domain'];

View File

@ -340,6 +340,7 @@ jQuery(function($){
{"name":"spam_aliases","filterable": false,"title":lang.spam_aliases,"breakpoints":"all"},
{"name":"tls_enforce_in","filterable": false,"title":lang.tls_enforce_in,"breakpoints":"all"},
{"name":"tls_enforce_out","filterable": false,"title":lang.tls_enforce_out,"breakpoints":"all"},
{"name":"last_mail_login","breakpoints":"xs sm","formatter":function unix_time_format(tm) { if (tm == '') { return lang.no; } else { var date = new Date(tm ? tm * 1000 : 0); return date.toLocaleString(); }},"title":lang.last_mail_login,"style":{"width":"170px"}},
{"name":"quarantine_notification","filterable": false,"title":lang.quarantine_notification,"breakpoints":"all"},
{"name":"in_use","filterable": false,"type":"html","title":lang.in_use,"sortValue": function(value){
return Number($(value).find(".progress-bar").attr('aria-valuenow'));

View File

@ -564,6 +564,7 @@
"notified": "Benachrichtigt"
},
"mailbox": {
"last_mail_login": "Letzter Mail-Login",
"table_size": "Tabellengröße",
"table_size_show_n": "Zeige %s Einträge",
"tls_policy_maps": "TLS-Richtlinien",

View File

@ -563,6 +563,7 @@
"notified": "Notified"
},
"mailbox": {
"last_mail_login": "Last mail login",
"table_size": "Table size",
"table_size_show_n": "Show %s items",
"tls_policy_maps": "TLS policy maps",

View File

@ -184,7 +184,7 @@ services:
- sogo
dovecot-mailcow:
image: mailcow/dovecot:1.112
image: mailcow/dovecot:1.113
depends_on:
- mysql-mailcow
dns: