Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit 9815d75

Browse files
committed
Silently ignore register channel on non-readable repository. Avoid sending events on write-only repositories, see #1256
1 parent 3ad15f5 commit 9815d75

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

core/src/plugins/mq.sql/SqlMessageExchanger.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
*/
2121
namespace Pydio\Mq\Implementation;
2222

23+
use Pydio\Core\Exception\PydioException;
2324
use Pydio\Core\Model\ContextInterface;
2425

2526
use Pydio\Core\PluginFramework\SqlTableProvider;
2627
use Pydio\Core\Utils\DBHelper;
27-
use Pydio\Core\Utils\FileHelper;
2828
use Pydio\Core\Utils\Vars\OptionsHelper;
2929

3030
use Pydio\Core\PluginFramework\Plugin;
@@ -162,15 +162,15 @@ public function __destruct()
162162
* @param $channelName
163163
* @param $clientId
164164
* @return mixed
165-
* @throws \Exception
165+
* @throws PydioException
166166
*/
167167
public function suscribeToChannel(ContextInterface $ctx, $channelName, $clientId)
168168
{
169169
$this->loadChannel($channelName, true);
170170
if ($ctx->hasUser()) {
171171
$user = $ctx->getUser();
172172
if ($user == null) {
173-
throw new \Exception("You must be logged in");
173+
throw new PydioException("You must be logged in");
174174
}
175175
$GROUP_PATH = $user->getGroupPath();
176176
$USER_ID = $user->getId();
@@ -179,6 +179,14 @@ public function suscribeToChannel(ContextInterface $ctx, $channelName, $clientId
179179
$USER_ID = "shared";
180180
}
181181
if($GROUP_PATH == null) $GROUP_PATH = false;
182+
if(strpos($channelName, "nodes:") === 0 && $channelName !== "nodes:*"){
183+
$repositoryId = substr($channelName, strlen("nodes:*"));
184+
// Make sure current user has Read access on this workspace
185+
if(!empty($user) && !$user->canRead($repositoryId)){
186+
$this->suscribeToChannel($ctx, "nodes:*", $clientId);
187+
return;
188+
}
189+
}
182190
self::$channels[$channelName]["CLIENTS"][$clientId] = array(
183191
"ALIVE" => time(),
184192
"USER_ID" => $USER_ID,
@@ -187,11 +195,6 @@ public function suscribeToChannel(ContextInterface $ctx, $channelName, $clientId
187195
if(strpos($channelName, "nodes:") === 0 && $channelName !== "nodes:*"){
188196
$this->suscribeToChannel($ctx, "nodes:*", $clientId);
189197
}
190-
/*
191-
foreach (self::$channels[$channelName]["MESSAGES"] as &$object) {
192-
$object->messageRC[$clientId] = $clientId;
193-
}
194-
*/
195198
}
196199

197200
/**

0 commit comments

Comments
 (0)