mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 00:17:03 +03:00
SMTP errors for client side (labs.smtp_show_server_errors)
This commit is contained in:
parent
9334187954
commit
2c1087b987
11 changed files with 88 additions and 43 deletions
|
|
@ -330,6 +330,7 @@ Enums.Notification = {
|
||||||
'AccountAlreadyExists': 801,
|
'AccountAlreadyExists': 801,
|
||||||
|
|
||||||
'MailServerError': 901,
|
'MailServerError': 901,
|
||||||
|
'ClientViewError': 902,
|
||||||
'UnknownNotification': 999,
|
'UnknownNotification': 999,
|
||||||
'UnknownError': 999
|
'UnknownError': 999
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -539,11 +539,17 @@ Utils.log = function (sDesc)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} iCode
|
* @param {number} iCode
|
||||||
|
* @param {ыекштп=} mMessage = ''
|
||||||
* @return {string}
|
* @return {string}
|
||||||
*/
|
*/
|
||||||
Utils.getNotification = function (iCode)
|
Utils.getNotification = function (iCode, mMessage)
|
||||||
{
|
{
|
||||||
iCode = Utils.pInt(iCode);
|
iCode = Utils.pInt(iCode);
|
||||||
|
if (Enums.Notification.ClientViewError === iCode && mMessage)
|
||||||
|
{
|
||||||
|
return mMessage;
|
||||||
|
}
|
||||||
|
|
||||||
return Utils.isUnd(NotificationI18N[iCode]) ? '' : NotificationI18N[iCode];
|
return Utils.isUnd(NotificationI18N[iCode]) ? '' : NotificationI18N[iCode];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,19 +59,6 @@ function PopupsComposeViewModel()
|
||||||
this.saving = ko.observable(false);
|
this.saving = ko.observable(false);
|
||||||
this.attachments = ko.observableArray([]);
|
this.attachments = ko.observableArray([]);
|
||||||
|
|
||||||
// this.attachmentsInProcess = ko.computed(function () {
|
|
||||||
// return _.filter(this.attachments(), function (oItem) {
|
|
||||||
// return oItem && '' === oItem.tempName();
|
|
||||||
// });
|
|
||||||
// }, this);
|
|
||||||
//
|
|
||||||
// this.attachmentsInReady = ko.computed(function () {
|
|
||||||
// return _.filter(this.attachments(), function (oItem) {
|
|
||||||
// return oItem && '' !== oItem.tempName();
|
|
||||||
// });
|
|
||||||
// }, this);
|
|
||||||
|
|
||||||
|
|
||||||
this.attachmentsInProcess = this.attachments.filter(function (oItem) {
|
this.attachmentsInProcess = this.attachments.filter(function (oItem) {
|
||||||
return oItem && '' === oItem.tempName();
|
return oItem && '' === oItem.tempName();
|
||||||
});
|
});
|
||||||
|
|
@ -486,7 +473,10 @@ PopupsComposeViewModel.prototype.formattedFrom = function (bHeaderResult)
|
||||||
|
|
||||||
PopupsComposeViewModel.prototype.sendMessageResponse = function (sResult, oData)
|
PopupsComposeViewModel.prototype.sendMessageResponse = function (sResult, oData)
|
||||||
{
|
{
|
||||||
var bResult = false;
|
var
|
||||||
|
bResult = false,
|
||||||
|
sMessage = ''
|
||||||
|
;
|
||||||
|
|
||||||
this.sending(false);
|
this.sending(false);
|
||||||
|
|
||||||
|
|
@ -508,8 +498,11 @@ PopupsComposeViewModel.prototype.sendMessageResponse = function (sResult, oData)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
sMessage = Utils.getNotification(oData && oData.ErrorCode ? oData.ErrorCode : Enums.Notification.CantSendMessage,
|
||||||
|
oData && oData.ErrorMessage ? oData.ErrorMessage : '');
|
||||||
|
|
||||||
this.sendError(true);
|
this.sendError(true);
|
||||||
window.alert(Utils.getNotification(oData && oData.ErrorCode ? oData.ErrorCode : Enums.Notification.CantSendMessage));
|
window.alert(sMessage || Utils.getNotification(Enums.Notification.CantSendMessage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4122,12 +4122,30 @@ class Actions
|
||||||
}
|
}
|
||||||
catch (\MailSo\Net\Exceptions\ConnectionException $oException)
|
catch (\MailSo\Net\Exceptions\ConnectionException $oException)
|
||||||
{
|
{
|
||||||
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::ConnectionError, $oException);
|
if ($this->Config()->Get('labs', 'smtp_show_server_errors'))
|
||||||
|
{
|
||||||
|
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::ClientViewError, $oException);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::ConnectionError, $oException);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (\MailSo\Smtp\Exceptions\LoginException $oException)
|
catch (\MailSo\Smtp\Exceptions\LoginException $oException)
|
||||||
{
|
{
|
||||||
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AuthError, $oException);
|
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AuthError, $oException);
|
||||||
}
|
}
|
||||||
|
catch (\Exception $oException)
|
||||||
|
{
|
||||||
|
if ($this->Config()->Get('labs', 'smtp_show_server_errors'))
|
||||||
|
{
|
||||||
|
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::ClientViewError, $oException);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw $oException;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -5802,6 +5820,10 @@ class Actions
|
||||||
{
|
{
|
||||||
$iErrorCode = $oException->getCode();
|
$iErrorCode = $oException->getCode();
|
||||||
$sErrorMessage = null;
|
$sErrorMessage = null;
|
||||||
|
if ($iErrorCode === \RainLoop\Notifications::ClientViewError)
|
||||||
|
{
|
||||||
|
$sErrorMessage = $oException->getMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -5819,7 +5841,7 @@ class Actions
|
||||||
$this->Logger()->WriteException($oException);
|
$this->Logger()->WriteException($oException);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->FalseResponse($sActionName, $iErrorCode);
|
return $this->FalseResponse($sActionName, $iErrorCode, $sErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -221,6 +221,7 @@ Enables caching in the system'),
|
||||||
'use_imap_auth_plain' => array(false),
|
'use_imap_auth_plain' => array(false),
|
||||||
'imap_forwarded_flag' => array('$Forwarded'),
|
'imap_forwarded_flag' => array('$Forwarded'),
|
||||||
'imap_read_receipt_flag' => array('$ReadReceipt'),
|
'imap_read_receipt_flag' => array('$ReadReceipt'),
|
||||||
|
'smtp_show_server_errors' => array(false),
|
||||||
'autocreate_system_folders' => array(true),
|
'autocreate_system_folders' => array(true),
|
||||||
'repo_type' => array('stable'),
|
'repo_type' => array('stable'),
|
||||||
'custom_repo' => array(''),
|
'custom_repo' => array(''),
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,6 @@ class ClientException extends Exception
|
||||||
{
|
{
|
||||||
public function __construct($iCode, $oPrevious = null)
|
public function __construct($iCode, $oPrevious = null)
|
||||||
{
|
{
|
||||||
parent::__construct(\RainLoop\Notifications::GetNotificationsMessage($iCode), $iCode, $oPrevious);
|
parent::__construct(\RainLoop\Notifications::GetNotificationsMessage($iCode, $oPrevious), $iCode, $oPrevious);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,10 +51,19 @@ class Notifications
|
||||||
const AccountAlreadyExists = 801;
|
const AccountAlreadyExists = 801;
|
||||||
|
|
||||||
const MailServerError = 901;
|
const MailServerError = 901;
|
||||||
|
const ClientViewError = 902;
|
||||||
const UnknownNotification = 998;
|
const UnknownNotification = 998;
|
||||||
const UnknownError = 999;
|
const UnknownError = 999;
|
||||||
|
|
||||||
static public function GetNotificationsMessage($iCode)
|
/**
|
||||||
|
* @staticvar array $aMap
|
||||||
|
*
|
||||||
|
* @param int $iCode
|
||||||
|
* @param \Exception|null $oPrevious
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
static public function GetNotificationsMessage($iCode, $oPrevious = null)
|
||||||
{
|
{
|
||||||
static $aMap = array(
|
static $aMap = array(
|
||||||
self::InvalidToken => 'InvalidToken',
|
self::InvalidToken => 'InvalidToken',
|
||||||
|
|
@ -93,10 +102,16 @@ class Notifications
|
||||||
self::DemoSendMessageError => 'DemoSendMessageError',
|
self::DemoSendMessageError => 'DemoSendMessageError',
|
||||||
self::AccountAlreadyExists => 'AccountAlreadyExists',
|
self::AccountAlreadyExists => 'AccountAlreadyExists',
|
||||||
self::MailServerError => 'MailServerError',
|
self::MailServerError => 'MailServerError',
|
||||||
|
self::ClientViewError => 'ClientViewError',
|
||||||
self::UnknownNotification => 'UnknownNotification',
|
self::UnknownNotification => 'UnknownNotification',
|
||||||
self::UnknownError => 'UnknownError'
|
self::UnknownError => 'UnknownError'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (self::ClientViewError === $iCode && $oPrevious instanceof \Exception)
|
||||||
|
{
|
||||||
|
return $oPrevious->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
return isset($aMap[$iCode]) ? $aMap[$iCode].'['.$iCode.']' : 'UnknownNotification['.$iCode.']';
|
return isset($aMap[$iCode]) ? $aMap[$iCode].'['.$iCode.']' : 'UnknownNotification['.$iCode.']';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -608,6 +608,7 @@ Enums.Notification = {
|
||||||
'AccountAlreadyExists': 801,
|
'AccountAlreadyExists': 801,
|
||||||
|
|
||||||
'MailServerError': 901,
|
'MailServerError': 901,
|
||||||
|
'ClientViewError': 902,
|
||||||
'UnknownNotification': 999,
|
'UnknownNotification': 999,
|
||||||
'UnknownError': 999
|
'UnknownError': 999
|
||||||
};
|
};
|
||||||
|
|
@ -1151,11 +1152,17 @@ Utils.log = function (sDesc)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} iCode
|
* @param {number} iCode
|
||||||
|
* @param {ыекштп=} mMessage = ''
|
||||||
* @return {string}
|
* @return {string}
|
||||||
*/
|
*/
|
||||||
Utils.getNotification = function (iCode)
|
Utils.getNotification = function (iCode, mMessage)
|
||||||
{
|
{
|
||||||
iCode = Utils.pInt(iCode);
|
iCode = Utils.pInt(iCode);
|
||||||
|
if (Enums.Notification.ClientViewError === iCode && mMessage)
|
||||||
|
{
|
||||||
|
return mMessage;
|
||||||
|
}
|
||||||
|
|
||||||
return Utils.isUnd(NotificationI18N[iCode]) ? '' : NotificationI18N[iCode];
|
return Utils.isUnd(NotificationI18N[iCode]) ? '' : NotificationI18N[iCode];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
2
rainloop/v/0.0.0/static/js/admin.min.js
vendored
2
rainloop/v/0.0.0/static/js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -608,6 +608,7 @@ Enums.Notification = {
|
||||||
'AccountAlreadyExists': 801,
|
'AccountAlreadyExists': 801,
|
||||||
|
|
||||||
'MailServerError': 901,
|
'MailServerError': 901,
|
||||||
|
'ClientViewError': 902,
|
||||||
'UnknownNotification': 999,
|
'UnknownNotification': 999,
|
||||||
'UnknownError': 999
|
'UnknownError': 999
|
||||||
};
|
};
|
||||||
|
|
@ -1151,11 +1152,17 @@ Utils.log = function (sDesc)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} iCode
|
* @param {number} iCode
|
||||||
|
* @param {ыекштп=} mMessage = ''
|
||||||
* @return {string}
|
* @return {string}
|
||||||
*/
|
*/
|
||||||
Utils.getNotification = function (iCode)
|
Utils.getNotification = function (iCode, mMessage)
|
||||||
{
|
{
|
||||||
iCode = Utils.pInt(iCode);
|
iCode = Utils.pInt(iCode);
|
||||||
|
if (Enums.Notification.ClientViewError === iCode && mMessage)
|
||||||
|
{
|
||||||
|
return mMessage;
|
||||||
|
}
|
||||||
|
|
||||||
return Utils.isUnd(NotificationI18N[iCode]) ? '' : NotificationI18N[iCode];
|
return Utils.isUnd(NotificationI18N[iCode]) ? '' : NotificationI18N[iCode];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -8045,19 +8052,6 @@ function PopupsComposeViewModel()
|
||||||
this.saving = ko.observable(false);
|
this.saving = ko.observable(false);
|
||||||
this.attachments = ko.observableArray([]);
|
this.attachments = ko.observableArray([]);
|
||||||
|
|
||||||
// this.attachmentsInProcess = ko.computed(function () {
|
|
||||||
// return _.filter(this.attachments(), function (oItem) {
|
|
||||||
// return oItem && '' === oItem.tempName();
|
|
||||||
// });
|
|
||||||
// }, this);
|
|
||||||
//
|
|
||||||
// this.attachmentsInReady = ko.computed(function () {
|
|
||||||
// return _.filter(this.attachments(), function (oItem) {
|
|
||||||
// return oItem && '' !== oItem.tempName();
|
|
||||||
// });
|
|
||||||
// }, this);
|
|
||||||
|
|
||||||
|
|
||||||
this.attachmentsInProcess = this.attachments.filter(function (oItem) {
|
this.attachmentsInProcess = this.attachments.filter(function (oItem) {
|
||||||
return oItem && '' === oItem.tempName();
|
return oItem && '' === oItem.tempName();
|
||||||
});
|
});
|
||||||
|
|
@ -8472,7 +8466,10 @@ PopupsComposeViewModel.prototype.formattedFrom = function (bHeaderResult)
|
||||||
|
|
||||||
PopupsComposeViewModel.prototype.sendMessageResponse = function (sResult, oData)
|
PopupsComposeViewModel.prototype.sendMessageResponse = function (sResult, oData)
|
||||||
{
|
{
|
||||||
var bResult = false;
|
var
|
||||||
|
bResult = false,
|
||||||
|
sMessage = ''
|
||||||
|
;
|
||||||
|
|
||||||
this.sending(false);
|
this.sending(false);
|
||||||
|
|
||||||
|
|
@ -8494,8 +8491,11 @@ PopupsComposeViewModel.prototype.sendMessageResponse = function (sResult, oData)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
sMessage = Utils.getNotification(oData && oData.ErrorCode ? oData.ErrorCode : Enums.Notification.CantSendMessage,
|
||||||
|
oData && oData.ErrorMessage ? oData.ErrorMessage : '');
|
||||||
|
|
||||||
this.sendError(true);
|
this.sendError(true);
|
||||||
window.alert(Utils.getNotification(oData && oData.ErrorCode ? oData.ErrorCode : Enums.Notification.CantSendMessage));
|
window.alert(sMessage || Utils.getNotification(Enums.Notification.CantSendMessage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
10
rainloop/v/0.0.0/static/js/app.min.js
vendored
10
rainloop/v/0.0.0/static/js/app.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue