Allow demo account to send messages to itself

This commit is contained in:
djmaze 2021-12-31 11:25:37 +01:00
parent ab5715b536
commit e52316bb08

View file

@ -5,6 +5,7 @@ class DemoAccountPlugin extends \RainLoop\Plugins\AbstractPlugin
const
NAME = 'Demo Account Extension',
CATEGORY = 'Login',
REQUIRED = '2.10.1',
DESCRIPTION = 'Extension to enable a demo account';
/**
@ -77,9 +78,25 @@ class DemoAccountPlugin extends \RainLoop\Plugins\AbstractPlugin
public function FilterSendMessage($oMessage)
{
if ($oMessage && $this->isDemoAccount()) {
$sEmail = $this->Config()->Get('plugin', 'email');
foreach ($oMessage->GetTo() as $oEmail) {
if ($oEmail->GetEmail() !== $sEmail) {
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::DemoSendMessageError);
}
}
foreach ($oMessage->GetCc() ?: [] as $oEmail) {
if ($oEmail->GetEmail() !== $sEmail) {
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::DemoSendMessageError);
}
}
foreach ($oMessage->GetBcc() ?: [] as $oEmail) {
if ($oEmail->GetEmail() !== $sEmail) {
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::DemoSendMessageError);
}
}
// throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::DemoSendMessageError);
}
}
/**
* @param string $sName