|
@@ 90-111 (lines=22) @@
|
| 87 |
|
/** |
| 88 |
|
* @NoAdminRequired |
| 89 |
|
*/ |
| 90 |
|
public function accept($requestId) { |
| 91 |
|
// Check this user is the recipient of this request |
| 92 |
|
try { |
| 93 |
|
// Not found, bad request |
| 94 |
|
$request = $this->transferManager->getRequestById($requestId); |
| 95 |
|
} catch (DoesNotExistException $e) { |
| 96 |
|
return new JSONResponse([], Http::STATUS_BAD_REQUEST); |
| 97 |
|
} |
| 98 |
|
$sessionUser = $this->userSession->getUser(); |
| 99 |
|
if ($request->getDestinationUserId() !== $sessionUser->getUID()) { |
| 100 |
|
// This isn't their request to respond to, bad request |
| 101 |
|
return new JSONResponse([], Http::STATUS_BAD_REQUEST); |
| 102 |
|
} |
| 103 |
|
|
| 104 |
|
try { |
| 105 |
|
$this->transferManager->acceptRequest($request); |
| 106 |
|
return new JSONResponse([]); |
| 107 |
|
} catch (\Exception $e) { |
| 108 |
|
$this->logger->logException($e, ['app' => 'files']); |
| 109 |
|
return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR); |
| 110 |
|
} |
| 111 |
|
} |
| 112 |
|
|
| 113 |
|
/** |
| 114 |
|
* @NoAdminRequired |
|
@@ 116-137 (lines=22) @@
|
| 113 |
|
/** |
| 114 |
|
* @NoAdminRequired |
| 115 |
|
*/ |
| 116 |
|
public function reject($requestId) { |
| 117 |
|
// Check this user is the recipient of this request |
| 118 |
|
try { |
| 119 |
|
// Not found, bad request |
| 120 |
|
$request = $this->transferManager->getRequestById($requestId); |
| 121 |
|
} catch (DoesNotExistException $e) { |
| 122 |
|
return new JSONResponse([], Http::STATUS_BAD_REQUEST); |
| 123 |
|
} |
| 124 |
|
$sessionUser = $this->userSession->getUser(); |
| 125 |
|
if ($request->getDestinationUserId() !== $sessionUser->getUID()) { |
| 126 |
|
// This isn't their request to respond to, bad request |
| 127 |
|
return new JSONResponse([], Http::STATUS_BAD_REQUEST); |
| 128 |
|
} |
| 129 |
|
|
| 130 |
|
try { |
| 131 |
|
$this->transferManager->rejectRequest($request); |
| 132 |
|
return new JSONResponse([]); |
| 133 |
|
} catch (\Exception $e) { |
| 134 |
|
$this->logger->logException($e, ['app' => 'files']); |
| 135 |
|
return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR); |
| 136 |
|
} |
| 137 |
|
} |
| 138 |
|
|
| 139 |
|
|
| 140 |
|
|