mirror of
https://github.com/maxpozdeev/mytinytodo.git
synced 2026-03-11 08:55:27 +00:00
little update of notifications extension
This commit is contained in:
parent
5325274a91
commit
8c74e3cbd7
3 changed files with 15 additions and 9 deletions
|
|
@ -111,14 +111,7 @@ class Sender
|
|||
$fromAddr = str_replace( ["\r", "\n", ":", "\"", "'", "?"], '', $this->prefs['mailfrom']);
|
||||
}
|
||||
else {
|
||||
$host = parse_url(get_unsafe_mttinfo('url'), PHP_URL_HOST);
|
||||
$host = preg_replace('/^(www\.)/', '', $host);
|
||||
if (function_exists('posix_getuid') && false !== ($userinfo = posix_getpwuid(posix_getuid())) ) {
|
||||
$fromAddr = $userinfo['name']. '@'. $host;
|
||||
}
|
||||
else {
|
||||
$fromAddr = "mytinytodo@$host";
|
||||
}
|
||||
$fromAddr = self::suggestedMailFrom();
|
||||
}
|
||||
$from = "myTinyTodo <$fromAddr>";
|
||||
$mttTitle = str_replace( ["\r","\n"], '', get_unsafe_mttinfo('title') );
|
||||
|
|
@ -195,4 +188,15 @@ class Sender
|
|||
fclose($fh);
|
||||
}
|
||||
|
||||
public static function suggestedMailFrom(): string
|
||||
{
|
||||
$host = parse_url(get_unsafe_mttinfo('url'), PHP_URL_HOST);
|
||||
$host = preg_replace('/^(www\.)/', '', $host);
|
||||
//$host = gethostname();
|
||||
if (function_exists('posix_getuid') && false !== ($userinfo = posix_getpwuid(posix_getuid())) ) {
|
||||
return $userinfo['name']. '@'. $host;
|
||||
}
|
||||
return "mytinytodo@$host";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
"notifications.bot_not_configured": "Бот не настроен",
|
||||
"notifications.h_email": "E-Mail:",
|
||||
"notifications.d_email": "Разделите несколько адресов c помощью запятой.",
|
||||
"notifications.h_mailfrom": "Адрес отправителя:",
|
||||
"notifications.d_mailfrom": "Этот адрес будет указан как адрес отправителя в письмах с уведомлениями.",
|
||||
"notifications.h_telegram": "Telegram",
|
||||
"notifications.h_token": "Токен для бота:",
|
||||
"notifications.d_token": "Токен для телеграм-бота, полученный от @BotFather.",
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class NotificationsExtension extends MTTExtension implements MTTHttpApiExtender,
|
|||
$prefs = self::preferences();
|
||||
$emails = htmlspecialchars( implode(', ', $prefs['emails']) );
|
||||
$mailfrom = htmlspecialchars($prefs['mailfrom'] ?? '');
|
||||
$mailfromDefault = htmlspecialchars( ini_get('sendmail_from') ?: '' );
|
||||
$mailfromDefault = htmlspecialchars(Notify\Sender::suggestedMailFrom());
|
||||
$numberOfChats = count($prefs['chats']);
|
||||
|
||||
$token = $prefs['token'] ?? '';
|
||||
|
|
|
|||
Loading…
Reference in a new issue