* EPL/mail: support SpamTitan REST API to manage spam, requires an API token

This commit is contained in:
Ralf Becker 2021-02-08 17:31:22 +02:00
parent 98d5e86121
commit c37581f43c
12 changed files with 55 additions and 25 deletions

View File

@ -1362,7 +1362,7 @@ class admin_mail
} }
// If no EPL available, show that in spamtitan blur // If no EPL available, show that in spamtitan blur
$content['spamtitan_blur'] = $GLOBALS['egw_info']['user']['apps']['stylite'] ? '' : lang('SpamTitian integration requires EPL version'); $content['spamtitan_blur'] = $GLOBALS['egw_info']['user']['apps']['stylite'] ? '' : lang('SpamTitan integration requires EPL version');
$tpl->exec(static::APP_CLASS.'edit', $content, $sel_options, $readonlys, $content, 2); $tpl->exec(static::APP_CLASS.'edit', $content, $sel_options, $readonlys, $content, 2);
} }

View File

@ -234,6 +234,10 @@
<description for="acc_spam_api" value="SpamTitan API URL"/> <description for="acc_spam_api" value="SpamTitan API URL"/>
<url id="acc_spam_api" blur="@spamtitan_blur" width="95%" maxlength="128"/> <url id="acc_spam_api" blur="@spamtitan_blur" width="95%" maxlength="128"/>
</row> </row>
<row>
<description for="acc_spam_password" value="API Token"/>
<passwd id="acc_spam_password" blur="@spamtitan_blur" width="95%" suggest="24"/>
</row>
</rows> </rows>
</grid> </grid>
</template> </template>

View File

@ -1274,6 +1274,18 @@ class Account implements \ArrayAccess
Credentials::delete($data['acc_id'], 0, Credentials::ADMIN); Credentials::delete($data['acc_id'], 0, Credentials::ADMIN);
} }
// store or delete SpamTitan credentials
if ($data['acc_spam_api'] && $data['acc_spam_password'])
{
Credentials::write($data['acc_id'], $data['acc_spam_api'],
$data['acc_spam_password'], Credentials::SPAMTITAN, 0,
$data['acc_spam_cred_id']);
}
else
{
Credentials::delete($data['acc_id'], 0, Credentials::SPAMTITAN);
}
// store notification folders // store notification folders
Notifications::write($data['acc_id'], $data['notify_save_default'] ? 0 : Notifications::write($data['acc_id'], $data['notify_save_default'] ? 0 :
($data['called_for'] ? $data['called_for'] : $GLOBALS['egw_info']['user']['account_id']), ($data['called_for'] ? $data['called_for'] : $GLOBALS['egw_info']['user']['account_id']),

View File

@ -74,10 +74,15 @@ class Credentials
*/ */
const COLLABORA = 64; const COLLABORA = 64;
/**
* SpamTitan API Token
*/
const SPAMTITAN = 128;
/** /**
* All credentials * All credentials
*/ */
const ALL = self::IMAP|self::SMTP|self::ADMIN|self::SMIME|self::TWOFA; const ALL = self::IMAP|self::SMTP|self::ADMIN|self::SMIME|self::TWOFA|self::SPAMTITAN;
/** /**
* Password in cleartext * Password in cleartext
@ -126,6 +131,7 @@ class Credentials
self::ADMIN => 'acc_imap_admin_', self::ADMIN => 'acc_imap_admin_',
self::SMIME => 'acc_smime_', self::SMIME => 'acc_smime_',
self::TWOFA => '2fa_', self::TWOFA => '2fa_',
self::SPAMTITAN => 'acc_spam_',
); );
/** /**

View File

@ -984,11 +984,23 @@ class mail_ui
} }
if ($GLOBALS['egw_info']['apps']['stylite'] && $this->mail_bo->icServer->acc_spam_api) if ($GLOBALS['egw_info']['apps']['stylite'] && $this->mail_bo->icServer->acc_spam_api)
{ {
stylite_mail_spamtitan::setActionItems($_action, $_items, array( if (strpos($user=$this->mail_bo->icServer->acc_imap_username, '@') === false)
{
if (!empty($this->mail_bo->icServer->acc_domain))
{
$user .= '@'.$this->mail_bo->icServer->acc_domain;
}
else
{
$user = $this->mail_bo->icServer->ident_email;
}
}
stylite_mail_spamtitan::setActionItems($_action, $_items, $auth=[
'user' => $user,
'userpwd' => $this->mail_bo->icServer->acc_imap_password, 'userpwd' => $this->mail_bo->icServer->acc_imap_password,
'user' => $this->mail_bo->icServer->acc_imap_username, 'api_url' => $this->mail_bo->icServer->acc_spam_api,
'api_url' => $this->mail_bo->icServer->acc_spam_api 'api_token' => $this->mail_bo->icServer->acc_spam_password,
)); ]);
// sync aliases to SpamTitan when the first spam action in a session is used // sync aliases to SpamTitan when the first spam action in a session is used
if (Api\Mail\Account::read($this->mail_bo->profileID)->acc_smtp_type !== 'EGroupware\\Api\\Mail\\Smtp' && if (Api\Mail\Account::read($this->mail_bo->profileID)->acc_smtp_type !== 'EGroupware\\Api\\Mail\\Smtp' &&
@ -996,11 +1008,7 @@ class mail_ui
{ {
$data = Api\Mail\Account::read($this->mail_bo->profileID)->smtpServer()->getUserData($GLOBALS['egw_info']['user']['account_id']); $data = Api\Mail\Account::read($this->mail_bo->profileID)->smtpServer()->getUserData($GLOBALS['egw_info']['user']['account_id']);
if (($m = stylite_mail_spamtitan::setActionItems('sync_aliases', if (($m = stylite_mail_spamtitan::setActionItems('sync_aliases',
array(array_merge((array)$data['mailLocalAddress'], (array)$data['mailAlternateAddress'])), array( array(array_merge((array)$data['mailLocalAddress'], (array)$data['mailAlternateAddress'])), $auth)))
'userpwd' => $this->mail_bo->icServer->acc_imap_password,
'user' => $this->mail_bo->icServer->acc_imap_username,
'api_url' => $this->mail_bo->icServer->acc_spam_api
))))
{ {
$msg[] = $m; $msg[] = $m;
} }

View File

@ -579,8 +579,8 @@ some clients fail to detect correct charset, if flowed lines are enabled. mail d
sort order mail de Sortierreihenfolge sort order mail de Sortierreihenfolge
source mail de Quelltext source mail de Quelltext
sources mail de HTML-Quellcode sources mail de HTML-Quellcode
spamtitian api url mail de SpamTitian API URL spamtitan api url mail de SpamTitan API URL
spamtitian integration requires epl version mail de SpamTitian-Integration benötigt die EPL Version spamtitan integration requires epl version mail de SpamTitan-Integration benötigt die EPL Version
start new messages with mime type plain/text or html? mail de Sollen neue E-Mails als plain/text oder HTML Nachrichten verfasst werden? start new messages with mime type plain/text or html? mail de Sollen neue E-Mails als plain/text oder HTML Nachrichten verfasst werden?
start reply messages with mime type plain/text or html or try to use the displayed format (default)? mail de Antworten auf und Inline-Weiterleiten von E-Mails im Text-, im HTML-Format oder entsprechend des Formats, in dem die E-Mail vom Sender ursprünglich verfasst wurde. start reply messages with mime type plain/text or html or try to use the displayed format (default)? mail de Antworten auf und Inline-Weiterleiten von E-Mails im Text-, im HTML-Format oder entsprechend des Formats, in dem die E-Mail vom Sender ursprünglich verfasst wurde.
step 1: imap - incoming mail mail de 1. Schritt: Posteingang (IMAP) einrichten step 1: imap - incoming mail mail de 1. Schritt: Posteingang (IMAP) einrichten

View File

@ -579,8 +579,8 @@ some clients fail to detect correct charset, if flowed lines are enabled. mail e
sort order mail en Sort order sort order mail en Sort order
source mail en Source source mail en Source
sources mail en Sources sources mail en Sources
spamtitian api url mail en SpamTitian API URL spamtitan api url mail en SpamTitan API URL
spamtitian integration requires epl version mail en SpamTitian integration requires EPL version spamtitan integration requires epl version mail en SpamTitan integration requires EPL version
start new messages with mime type plain/text or html? mail en start new messages with MIME-type plain/text or HTML? start new messages with mime type plain/text or html? mail en start new messages with MIME-type plain/text or HTML?
start reply messages with mime type plain/text or html or try to use the displayed format (default)? mail en start reply messages with MIME-type plain/text or HTML or try to use the displayed format (default)? start reply messages with mime type plain/text or html or try to use the displayed format (default)? mail en start reply messages with MIME-type plain/text or HTML or try to use the displayed format (default)?
step 1: imap - incoming mail mail en Step 1: IMAP - incoming mail step 1: imap - incoming mail mail en Step 1: IMAP - incoming mail

View File

@ -483,8 +483,8 @@ some clients fail to detect correct charset, if flowed lines are enabled. mail e
sort order mail es-es Orden en la página sort order mail es-es Orden en la página
source mail es-es Fuente source mail es-es Fuente
sources mail es-es Fuentes sources mail es-es Fuentes
spamtitian api url mail es-es URL del API SpamTitian spamtitan api url mail es-es URL del API SpamTitan
spamtitian integration requires epl version mail es-es La integración de SpamTitan requiere la versión EPL spamtitan integration requires epl version mail es-es La integración de SpamTitan requiere la versión EPL
start new messages with mime type plain/text or html? mail es-es ¿Comenzar nuevos mensajes con el tipo MIME plain/text o html? start new messages with mime type plain/text or html? mail es-es ¿Comenzar nuevos mensajes con el tipo MIME plain/text o html?
step 1: imap - incoming mail mail es-es Paso 1: IMAP - correo entrante step 1: imap - incoming mail mail es-es Paso 1: IMAP - correo entrante
step 2: folder mail es-es Paso 2: Carpeta step 2: folder mail es-es Paso 2: Carpeta

View File

@ -521,8 +521,8 @@ some clients fail to detect correct charset, if flowed lines are enabled. mail i
sort order mail it Ordinamento sort order mail it Ordinamento
source mail it Sorgente source mail it Sorgente
sources mail it Sorgenti sources mail it Sorgenti
spamtitian api url mail it URL della API di spamTitan spamtitan api url mail it URL della API di spamTitan
spamtitian integration requires epl version mail it L'integrazione di spamTitan richiede la versione EPL spamtitan integration requires epl version mail it L'integrazione di spamTitan richiede la versione EPL
start new messages with mime type plain/text or html? mail it Iniziare nuovi messaggi con mime type plain/test o HTML start new messages with mime type plain/text or html? mail it Iniziare nuovi messaggi con mime type plain/test o HTML
start reply messages with mime type plain/text or html or try to use the displayed format (default)? mail it Iniziare i messaggi di risposta con mime type plain/text oppure provare a usare il formato mostrato (predefinito)? start reply messages with mime type plain/text or html or try to use the displayed format (default)? mail it Iniziare i messaggi di risposta con mime type plain/text oppure provare a usare il formato mostrato (predefinito)?
step 1: imap - incoming mail mail it Primo passo: IMAP - posta in arrivo step 1: imap - incoming mail mail it Primo passo: IMAP - posta in arrivo

View File

@ -539,8 +539,8 @@ some clients fail to detect correct charset, if flowed lines are enabled. mail j
sort order mail ja ソート順 sort order mail ja ソート順
source mail ja メールのソース source mail ja メールのソース
sources mail ja メールのソース sources mail ja メールのソース
spamtitian api url mail ja SpamTitian API URL spamtitan api url mail ja SpamTitan API URL
spamtitian integration requires epl version mail ja SpamTitian を利用するには EPL 版が必要 spamtitan integration requires epl version mail ja SpamTitan を利用するには EPL 版が必要
start new messages with mime type plain/text or html? mail ja 新規メッセージを plain/text で作成しますかHTMLで作成しますか start new messages with mime type plain/text or html? mail ja 新規メッセージを plain/text で作成しますかHTMLで作成しますか
start reply messages with mime type plain/text or html or try to use the displayed format (default)? mail ja 返信を plain/text で作成しますかHTMLで作成しますか表示中の形式を使用しますか既定 start reply messages with mime type plain/text or html or try to use the displayed format (default)? mail ja 返信を plain/text で作成しますかHTMLで作成しますか表示中の形式を使用しますか既定
step 1: imap - incoming mail mail ja ステップ 1: IMAP - 受信メール step 1: imap - incoming mail mail ja ステップ 1: IMAP - 受信メール

View File

@ -541,8 +541,8 @@ some clients fail to detect correct charset, if flowed lines are enabled. mail s
sort order mail sk Usporiadať podľa sort order mail sk Usporiadať podľa
source mail sk Zdroj source mail sk Zdroj
sources mail sk Zdroje sources mail sk Zdroje
spamtitian api url mail sk SpamTitan API URL spamtitan api url mail sk SpamTitan API URL
spamtitian integration requires epl version mail sk Integrácia so SpamTitan vyžaduje verziu EPL spamtitan integration requires epl version mail sk Integrácia so SpamTitan vyžaduje verziu EPL
start new messages with mime type plain/text or html? mail sk Vytvárať nové správy pomocou mime typu čistý text, alebo HTML? start new messages with mime type plain/text or html? mail sk Vytvárať nové správy pomocou mime typu čistý text, alebo HTML?
start reply messages with mime type plain/text or html or try to use the displayed format (default)? mail sk Začínať odpovedacie správy mime typom čistý text alebo html alebo skúsiť použiť zobrazený formát (predvolené)? start reply messages with mime type plain/text or html or try to use the displayed format (default)? mail sk Začínať odpovedacie správy mime typom čistý text alebo html alebo skúsiť použiť zobrazený formát (predvolené)?
step 1: imap - incoming mail mail sk Krok 1: IMAP - prijatá pošta step 1: imap - incoming mail mail sk Krok 1: IMAP - prijatá pošta

View File

@ -565,8 +565,8 @@ some clients fail to detect correct charset, if flowed lines are enabled. mail s
sort order mail sl Način sortiranja sort order mail sl Način sortiranja
source mail sl Vir source mail sl Vir
sources mail sl Viri sources mail sl Viri
spamtitian api url mail sl URL za SpamTitian API spamtitan api url mail sl URL za SpamTitan API
spamtitian integration requires epl version mail sl Integracija SpamTitian zahteva različico EPL spamtitan integration requires epl version mail sl Integracija SpamTitan zahteva različico EPL
start new messages with mime type plain/text or html? mail sl Začnem novo sporočilo kot navadno besedilo ali kot HTML? start new messages with mime type plain/text or html? mail sl Začnem novo sporočilo kot navadno besedilo ali kot HTML?
start reply messages with mime type plain/text or html or try to use the displayed format (default)? mail sl začnite odgovarjati s sporočilom mime type plain / text ali html ali poskusite uporabiti prikazano obliko (privzeto)? start reply messages with mime type plain/text or html or try to use the displayed format (default)? mail sl začnite odgovarjati s sporočilom mime type plain / text ali html ali poskusite uporabiti prikazano obliko (privzeto)?
step 1: imap - incoming mail mail sl Korak 1: IMAP - prihajajoča pošta step 1: imap - incoming mail mail sl Korak 1: IMAP - prihajajoča pošta