From e52316bb0860fd884ab55bedd42de01854c3fcf1 Mon Sep 17 00:00:00 2001 From: djmaze <> Date: Fri, 31 Dec 2021 11:25:37 +0100 Subject: [PATCH] Allow demo account to send messages to itself --- plugins/demo-account/index.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/plugins/demo-account/index.php b/plugins/demo-account/index.php index b10a309ff..0b9d4d06e 100644 --- a/plugins/demo-account/index.php +++ b/plugins/demo-account/index.php @@ -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,7 +78,23 @@ class DemoAccountPlugin extends \RainLoop\Plugins\AbstractPlugin public function FilterSendMessage($oMessage) { if ($oMessage && $this->isDemoAccount()) { - throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::DemoSendMessageError); + $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); } }