pull/34/head
Andrei Sacuiu 7 years ago
parent 0a8c089ee0
commit 9c4da055a8

@ -124,15 +124,24 @@ var odfViewer = {
$('#app-content #controls').addClass('hidden');
$('#app-content').append($iframe);
$.ajax({type: 'GET', url: OC.filePath('richdocuments', 'ajax', 'generate.php'), data: {id: context.$file.attr('data-id')}, async: false, success: function(result) {
if(result.status=="success"){
var $chatroom = $('<iframe id="chatroom" data-chatroom-password="'+result.password+'" data-chatroom-title="'+fileName+'" data-chatroom-name="'+result.name+'" hidden />');
$('#app-content').append($chatroom);
$.ajax({type: 'GET',
url: OC.filePath('richdocuments', 'ajax', 'generate.php'),
data: {id: context.$file.attr('data-id')},
async: false, success: function(result) {
if(result.status=="success"){
var $chatroom = $('<div />');
$chatroom.attr('id','chatroom');
$chatroom.data('chatroom-password',result.password);
$chatroom.data('chatroom-name',result.name);
$chatroom.data('chatroom-title',fileName);
$('#app-content').append($chatroom);
} else {
console.log(result.message);
}
}, error: function(xhr, textStatus, errorThrown){
console.log(errorThrown);
}
}, error: function(xhr, textStatus, errorThrown){
password=errorThrown;
}});
});
},

@ -256,35 +256,33 @@ class DocumentController extends Controller {
* @NoAdminRequired
*/
public function generate($id) {
if((!empty($id))) {
$view = \OC\Files\Filesystem::getView();
try {
$path = $view->getPath($id);
if ($view->is_file($path) && $view->isReadable($path)) {
$secret = \OC::$server->getConfig()->getSystemValue("secret");
$instanceID = \OC::$server->getConfig()->getSystemValue("instanceid");
$chatRoomPassword = hash('sha512', "chatroom-password".$instanceID.$secret.$id);
$chatRoomName = hash('sha512', "chatroom-name".$instanceID.$secret.$id);
return array(
'status' => 'success','password' => $chatRoomPassword,'name' => $chatRoomName
);
} else {
return array(
'status' => 'unauthorised'
);
}
} catch (\Exception $e) {
if (empty($id)) {
return array(
'status' => 'error',
'message' => 'no id received');
}
$view = \OC\Files\Filesystem::getView();
try {
$path = $view->getPath($id);
if ($view->is_file($path) && $view->isReadable($path)) {
$secret = \OC::$server->getConfig()->getSystemValue('secret');
$instanceID = \OC::$server->getConfig()->getSystemValue('instanceid');
$chatRoomPassword = hash('sha512', 'chatroom-password'.$instanceID.$secret.$id);
$chatRoomName = hash('sha512','chatroom-name'.$instanceID.$secret.$id);
return array(
'status' => 'success',
'password' => $chatRoomPassword,
'name' => $chatRoomName);
} else {
return array(
'status' => 'unauthorised'
);
'status' => 'error',
'message' => 'user unauthorised to view file');
}
} catch (\Exception $e) {
return array(
'status' => 'error',
'message' => 'user unauthorised to view file');
}
return array(
'status' => 'no id received'
);
}
}

Loading…
Cancel
Save