Permalink
Browse files

Missing GruntFile.

 New event response.send. Core.mq can append instruction on requests when websocket is not active.
  • Loading branch information...
1 parent fb1f8af commit 90d42b9a5d0fa8cddba54400439d3188f70113d3 @cdujeu cdujeu committed May 23, 2016
@@ -240,8 +240,9 @@ public static function run(ServerRequestInterface $request, &$actionNode = null)
}
}
- return $response;
+ self::applyHook("response.send", array(&$response));
+ return $response;
}
public static function applyTaskInBackground(Task $task){
@@ -0,0 +1,54 @@
+<?php
+/*
+ * Copyright 2007-2015 Abstrium <contact (at) pydio.com>
+ * This file is part of Pydio.
+ *
+ * Pydio is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pydio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with Pydio. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * The latest code can be found at <http://pyd.io/>.
+ */
+
+use Pydio\Core\Http\Response\JSONSerializableResponseChunk;
+use Pydio\Core\Http\Response\XMLSerializableResponseChunk;
+
+defined('AJXP_EXEC') or die('Access not allowed');
+
+
+class ConsumeChannelMessage implements XMLSerializableResponseChunk, JSONSerializableResponseChunk
+{
+
+ /**
+ * @return mixed
+ */
+ public function jsonSerializableData()
+ {
+ return ["consume_channel"=>"now"];
+ }
+
+ /**
+ * @return string
+ */
+ public function jsonSerializableKey()
+ {
+ return "mq";
+ }
+
+ /**
+ * @return string
+ */
+ public function toXML()
+ {
+ return "<consume_channel/>";
+ }
+}
@@ -19,6 +19,7 @@
* The latest code can be found at <http://pyd.io/>.
*/
+use Psr\Http\Message\ResponseInterface;
use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Access\Core\Filter\AJXP_Permission;
use Pydio\Core\Controller\Controller;
@@ -61,6 +62,7 @@ class MqManager extends Plugin
*/
private $msgExchanger = false;
private $useQueue = false ;
+ private $hasPendingMessage = false;
public function init($options)
@@ -206,6 +208,19 @@ public function sendInstantMessage($xmlContent, $repositoryId, $targetUserId = n
@$this->wsClient->sendMessage($msg);
}
+ $this->hasPendingMessage = true;
+
+ }
+
+ public function appendRefreshInstruction(ResponseInterface &$responseInterface){
+ if(! $this->hasPendingMessage ){
+ return;
+ }
+ $respType = &$responseInterface->getBody();
+ if($respType instanceof \Pydio\Core\Http\Response\SerializableResponseStream){
+ require_once("ConsumeChannelMessage.php");
+ $respType->addChunk(new ConsumeChannelMessage());
+ }
}
/**
@@ -81,6 +81,7 @@
<serverCallback methodName="publishNodeChange" hookName="node.change" defer="true"/>
<serverCallback methodName="sendInstantMessage" hookName="msg.instant" />
<serverCallback methodName="sendToQueue" hookName="msg.queue_notification" />
+ <serverCallback methodName="appendRefreshInstruction" hookName="response.send" />
</hooks>
</registry_contributions>
<dependencies>
@@ -0,0 +1,34 @@
+module.exports = function(grunt) {
+ grunt.initConfig({
+ babel: {
+ options: {},
+
+ dist: {
+ files: [
+ {
+ expand: true,
+ cwd: 'js/react/',
+ src: ['**/*.js'],
+ dest: 'js/build/',
+ ext: '.js'
+ }
+ ]
+ }
+ },
+ watch: {
+ js: {
+ files: [
+ "js/react/**/*"
+ ],
+ tasks: ['babel'],
+ options: {
+ spawn: false
+ }
+ }
+ }
+ });
+ grunt.loadNpmTasks('grunt-babel');
+ grunt.loadNpmTasks('grunt-contrib-watch');
+ grunt.registerTask('default', ['babel']);
+
+};
@@ -0,0 +1,14 @@
+{
+ "name": "core.tasks",
+ "version": "6.5.1",
+ "description": "",
+ "source_path":"js",
+ "main": "index.js",
+ "author": "Abstrium SAS",
+ "license": "AGPL",
+ "devDependencies": {
+ "grunt": "~0.4.5",
+ "grunt-babel": "~5.0.3",
+ "grunt-contrib-watch": "~0.6.1"
+ }
+}
@@ -72,7 +72,7 @@ public function enqueueTask(Task $task, ServerRequestInterface $request, Respons
->withAttribute("action", $action)
->withAttribute("pydio-task-id", $id)
->withParsedBody($params);
- Controller::run($request);
+ $response = Controller::run($request);
}
}

0 comments on commit 90d42b9

Please sign in to comment.