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

Commit

Permalink
Missing GruntFile.
Browse files Browse the repository at this point in the history
 New event response.send. Core.mq can append instruction on requests when websocket is not active.
  • Loading branch information
cdujeu committed May 23, 2016
1 parent fb1f8af commit 90d42b9
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 2 deletions.
3 changes: 2 additions & 1 deletion core/src/core/src/pydio/Core/Controller/Controller.php
Expand Up @@ -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){
Expand Down
54 changes: 54 additions & 0 deletions core/src/plugins/core.mq/ConsumeChannelMessage.php
@@ -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/>";
}
}
15 changes: 15 additions & 0 deletions core/src/plugins/core.mq/class.MqManager.php
Expand Up @@ -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;
Expand Down Expand Up @@ -61,6 +62,7 @@ class MqManager extends Plugin
*/
private $msgExchanger = false;
private $useQueue = false ;
private $hasPendingMessage = false;


public function init($options)
Expand Down Expand Up @@ -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());
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions core/src/plugins/core.mq/manifest.xml
Expand Up @@ -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>
Expand Down
34 changes: 34 additions & 0 deletions core/src/plugins/core.tasks/Gruntfile.js
@@ -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']);

};
14 changes: 14 additions & 0 deletions core/src/plugins/core.tasks/package.json
@@ -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"
}
}
2 changes: 1 addition & 1 deletion core/src/plugins/core.tasks/src/TaskService.php
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 90d42b9

Please sign in to comment.