websocket fixes
This commit is contained in:
@@ -37,41 +37,51 @@ class AclCheck extends Base
|
||||
$scope = $options['scope'] ?? null;
|
||||
$id = $options['id'] ?? null;
|
||||
$action = $options['action'] ?? null;
|
||||
$portalId = $options['portalId'] ?? null;
|
||||
|
||||
if (empty($userId)) return;
|
||||
if (empty($scope)) return;
|
||||
if (empty($id)) return;
|
||||
|
||||
$container = $this->getContainer();
|
||||
|
||||
if ($portalId) {
|
||||
$application = new \Espo\Core\Portal\Application($portalId);
|
||||
$container = $application->getContainer();
|
||||
}
|
||||
|
||||
$entityManager = $container->get('entityManager');
|
||||
|
||||
$user = $entityManager->getEntity('User', $userId);
|
||||
if (!$user) return;
|
||||
|
||||
if ($portalId) {
|
||||
if (
|
||||
!$user->isPortal()
|
||||
||
|
||||
!in_array($portalId, $user->getLinkMultipleIdList('portals'))
|
||||
) {
|
||||
return;
|
||||
if ($user->isPortal()) {
|
||||
$portalIdList = $user->getLinkMultipleIdList('portals');
|
||||
foreach ($portalIdList as $portalId) {
|
||||
$application = new \Espo\Core\Portal\Application($portalId);
|
||||
$containerPortal = $application->getContainer();
|
||||
$entityManager = $containerPortal->get('entityManager');
|
||||
|
||||
$user = $entityManager->getEntity('User', $userId);
|
||||
if (!$user) return;
|
||||
|
||||
$result = $this->check($user, $scope, $id, $action, $containerPortal);
|
||||
if ($result) {
|
||||
return 'true';
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->check($user, $scope, $id, $action, $container)) {
|
||||
return 'true';
|
||||
}
|
||||
}
|
||||
|
||||
protected function check($user, $scope, $id, $action, $container)
|
||||
{
|
||||
$entityManager = $container->get('entityManager');
|
||||
|
||||
$entity = $entityManager->getEntity($scope, $id);
|
||||
if (!$entity) return;
|
||||
|
||||
$aclManager = $container->get('aclManager');
|
||||
|
||||
if ($aclManager->check($user, $entity, $action)) {
|
||||
return 'true';
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ class Pusher implements WampServerInterface
|
||||
if ($checkCommand) {
|
||||
$checkResult = shell_exec($checkCommand);
|
||||
if ($checkResult !== 'true') {
|
||||
if ($this->isDebugMode) echo "check access faied for topic {$topicId} for user {$userId}\n";
|
||||
if ($this->isDebugMode) echo "check access failed for topic {$topicId} for user {$userId}\n";
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -309,14 +309,16 @@ class Pusher implements WampServerInterface
|
||||
$connection->event($topicId, $data);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->isDebugMode) echo "onMessage {$topicId} for {$userId}\n";
|
||||
} else {
|
||||
$topic = $this->topicHash[$topicId] ?? null;
|
||||
if ($topic) {
|
||||
$topic->broadcast($data);
|
||||
if ($this->isDebugMode) echo "send {$topicId} to all\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->isDebugMode) echo "onMessage {$topicId} for {$userId}\n";
|
||||
if ($this->isDebugMode) echo "onMessage {$topicId} for all\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
"categories": {
|
||||
"newNotification": {},
|
||||
"streamUpdate": {
|
||||
"paramList": ["scope", "id", "portalId"],
|
||||
"accessCheckCommand": "AclCheck --userId=:userId --scope=:scope --id=:id --action=stream --portalId=:portalId"
|
||||
"paramList": ["scope", "id"],
|
||||
"accessCheckCommand": "AclCheck --userId=:userId --scope=:scope --id=:id --action=stream"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,9 +190,6 @@ Espo.define('views/stream/panel', ['views/record/panels/relationship', 'lib!Text
|
||||
if (!this.getConfig().get('useWebSocket')) return;
|
||||
|
||||
var topic = 'streamUpdate.' + this.model.entityType + '.' + this.model.id;
|
||||
if (this.getUser().isPortal()) {
|
||||
topic += '.' + this.getUser().get('portalId');
|
||||
}
|
||||
this.streamUpdateWebSocketTopic = topic;
|
||||
|
||||
this.isSubscribedToWebSocked = true;
|
||||
|
||||
Reference in New Issue
Block a user