mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-09-04 20:24:12 +08: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,
|
||||
|
||||
'MailServerError': 901,
|
||||
'ClientViewError': 902,
|
||||
'UnknownNotification': 999,
|
||||
'UnknownError': 999
|
||||
};
|
||||
|
|
|
@ -539,11 +539,17 @@ Utils.log = function (sDesc)
|
|||
|
||||
/**
|
||||
* @param {number} iCode
|
||||
* @param {ыекштп=} mMessage = ''
|
||||
* @return {string}
|
||||
*/
|
||||
Utils.getNotification = function (iCode)
|
||||
Utils.getNotification = function (iCode, mMessage)
|
||||
{
|
||||
iCode = Utils.pInt(iCode);
|
||||
if (Enums.Notification.ClientViewError === iCode && mMessage)
|
||||
{
|
||||
return mMessage;
|
||||
}
|
||||
|
||||
return Utils.isUnd(NotificationI18N[iCode]) ? '' : NotificationI18N[iCode];
|
||||
};
|
||||
|
||||
|
|
|
@ -59,19 +59,6 @@ function PopupsComposeViewModel()
|
|||
this.saving = ko.observable(false);
|
||||
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) {
|
||||
return oItem && '' === oItem.tempName();
|
||||
});
|
||||
|
@ -486,7 +473,10 @@ PopupsComposeViewModel.prototype.formattedFrom = function (bHeaderResult)
|
|||
|
||||
PopupsComposeViewModel.prototype.sendMessageResponse = function (sResult, oData)
|
||||
{
|
||||
var bResult = false;
|
||||
var
|
||||
bResult = false,
|
||||
sMessage = ''
|
||||
;
|
||||
|
||||
this.sending(false);
|
||||
|
||||
|
@ -508,8 +498,11 @@ PopupsComposeViewModel.prototype.sendMessageResponse = function (sResult, oData)
|
|||
}
|
||||
else
|
||||
{
|
||||
sMessage = Utils.getNotification(oData && oData.ErrorCode ? oData.ErrorCode : Enums.Notification.CantSendMessage,
|
||||
oData && oData.ErrorMessage ? oData.ErrorMessage : '');
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
|
@ -5802,6 +5820,10 @@ class Actions
|
|||
{
|
||||
$iErrorCode = $oException->getCode();
|
||||
$sErrorMessage = null;
|
||||
if ($iErrorCode === \RainLoop\Notifications::ClientViewError)
|
||||
{
|
||||
$sErrorMessage = $oException->getMessage();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -5819,7 +5841,7 @@ class Actions
|
|||
$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),
|
||||
'imap_forwarded_flag' => array('$Forwarded'),
|
||||
'imap_read_receipt_flag' => array('$ReadReceipt'),
|
||||
'smtp_show_server_errors' => array(false),
|
||||
'autocreate_system_folders' => array(true),
|
||||
'repo_type' => array('stable'),
|
||||
'custom_repo' => array(''),
|
||||
|
|
|
@ -10,6 +10,6 @@ class ClientException extends Exception
|
|||
{
|
||||
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 MailServerError = 901;
|
||||
const ClientViewError = 902;
|
||||
const UnknownNotification = 998;
|
||||
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(
|
||||
self::InvalidToken => 'InvalidToken',
|
||||
|
@ -93,10 +102,16 @@ class Notifications
|
|||
self::DemoSendMessageError => 'DemoSendMessageError',
|
||||
self::AccountAlreadyExists => 'AccountAlreadyExists',
|
||||
self::MailServerError => 'MailServerError',
|
||||
self::ClientViewError => 'ClientViewError',
|
||||
self::UnknownNotification => 'UnknownNotification',
|
||||
self::UnknownError => 'UnknownError'
|
||||
);
|
||||
|
||||
if (self::ClientViewError === $iCode && $oPrevious instanceof \Exception)
|
||||
{
|
||||
return $oPrevious->getMessage();
|
||||
}
|
||||
|
||||
return isset($aMap[$iCode]) ? $aMap[$iCode].'['.$iCode.']' : 'UnknownNotification['.$iCode.']';
|
||||
}
|
||||
}
|
|
@ -608,6 +608,7 @@ Enums.Notification = {
|
|||
'AccountAlreadyExists': 801,
|
||||
|
||||
'MailServerError': 901,
|
||||
'ClientViewError': 902,
|
||||
'UnknownNotification': 999,
|
||||
'UnknownError': 999
|
||||
};
|
||||
|
@ -1151,11 +1152,17 @@ Utils.log = function (sDesc)
|
|||
|
||||
/**
|
||||
* @param {number} iCode
|
||||
* @param {ыекштп=} mMessage = ''
|
||||
* @return {string}
|
||||
*/
|
||||
Utils.getNotification = function (iCode)
|
||||
Utils.getNotification = function (iCode, mMessage)
|
||||
{
|
||||
iCode = Utils.pInt(iCode);
|
||||
if (Enums.Notification.ClientViewError === iCode && mMessage)
|
||||
{
|
||||
return mMessage;
|
||||
}
|
||||
|
||||
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,
|
||||
|
||||
'MailServerError': 901,
|
||||
'ClientViewError': 902,
|
||||
'UnknownNotification': 999,
|
||||
'UnknownError': 999
|
||||
};
|
||||
|
@ -1151,11 +1152,17 @@ Utils.log = function (sDesc)
|
|||
|
||||
/**
|
||||
* @param {number} iCode
|
||||
* @param {ыекштп=} mMessage = ''
|
||||
* @return {string}
|
||||
*/
|
||||
Utils.getNotification = function (iCode)
|
||||
Utils.getNotification = function (iCode, mMessage)
|
||||
{
|
||||
iCode = Utils.pInt(iCode);
|
||||
if (Enums.Notification.ClientViewError === iCode && mMessage)
|
||||
{
|
||||
return mMessage;
|
||||
}
|
||||
|
||||
return Utils.isUnd(NotificationI18N[iCode]) ? '' : NotificationI18N[iCode];
|
||||
};
|
||||
|
||||
|
@ -8045,19 +8052,6 @@ function PopupsComposeViewModel()
|
|||
this.saving = ko.observable(false);
|
||||
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) {
|
||||
return oItem && '' === oItem.tempName();
|
||||
});
|
||||
|
@ -8472,7 +8466,10 @@ PopupsComposeViewModel.prototype.formattedFrom = function (bHeaderResult)
|
|||
|
||||
PopupsComposeViewModel.prototype.sendMessageResponse = function (sResult, oData)
|
||||
{
|
||||
var bResult = false;
|
||||
var
|
||||
bResult = false,
|
||||
sMessage = ''
|
||||
;
|
||||
|
||||
this.sending(false);
|
||||
|
||||
|
@ -8494,8 +8491,11 @@ PopupsComposeViewModel.prototype.sendMessageResponse = function (sResult, oData)
|
|||
}
|
||||
else
|
||||
{
|
||||
sMessage = Utils.getNotification(oData && oData.ErrorCode ? oData.ErrorCode : Enums.Notification.CantSendMessage,
|
||||
oData && oData.ErrorMessage ? oData.ErrorMessage : '');
|
||||
|
||||
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
Reference in a new issue