Move handlers to catch more exceptions
This commit is contained in:
parent
988ae02b8e
commit
d283572fce
@ -18,13 +18,21 @@ class SessionController extends Controller{
|
|||||||
$uid = self::preDispatchGuest();
|
$uid = self::preDispatchGuest();
|
||||||
$uid = substr(@$_POST['name'], 0, 16) .' '. $uid;
|
$uid = substr(@$_POST['name'], 0, 16) .' '. $uid;
|
||||||
$token = @$args['token'];
|
$token = @$args['token'];
|
||||||
|
try {
|
||||||
$file = File::getByShareToken($token);
|
$file = File::getByShareToken($token);
|
||||||
self::join($uid, $file);
|
self::join($uid, $file);
|
||||||
|
} catch (\Exception $e){
|
||||||
|
Helper::warnLog('Starting a session failed. Reason: ' . $e->getMessage());
|
||||||
|
\OCP\JSON::error();
|
||||||
|
exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function joinAsUser($args){
|
public static function joinAsUser($args){
|
||||||
$uid = self::preDispatch();
|
$uid = self::preDispatch();
|
||||||
$fileId = intval(@$args['file_id']);
|
$fileId = intval(@$args['file_id']);
|
||||||
|
|
||||||
|
try {
|
||||||
$file = new File($fileId);
|
$file = new File($fileId);
|
||||||
|
|
||||||
if ($file->getPermissions() & \OCP\PERMISSION_UPDATE) {
|
if ($file->getPermissions() & \OCP\PERMISSION_UPDATE) {
|
||||||
@ -35,14 +43,6 @@ class SessionController extends Controller{
|
|||||||
'id' => $fileId
|
'id' => $fileId
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static function join($uid, $file){
|
|
||||||
try{
|
|
||||||
$session = Db_Session::start($uid, $file);
|
|
||||||
\OCP\JSON::success($session);
|
|
||||||
exit();
|
exit();
|
||||||
} catch (\Exception $e){
|
} catch (\Exception $e){
|
||||||
Helper::warnLog('Starting a session failed. Reason: ' . $e->getMessage());
|
Helper::warnLog('Starting a session failed. Reason: ' . $e->getMessage());
|
||||||
@ -51,6 +51,12 @@ class SessionController extends Controller{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static function join($uid, $file){
|
||||||
|
$session = Db_Session::start($uid, $file);
|
||||||
|
\OCP\JSON::success($session);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store the document content to its origin
|
* Store the document content to its origin
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user