Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2019-06-17 23:09:14 +0300
committerJulius Härtl <jus@bitgrid.net>2019-06-17 23:09:14 +0300
commit91f8e8a88df5cd41e113572060a491b92886f308 (patch)
treeeefc32dd18614f96844e6be39d42187881c1d2f2 /lib
parent1518d421d05943ca9e1e670c433360d4131cf6dd (diff)
Some code cleanup
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/Db/SessionMapper.php2
-rw-r--r--lib/Db/StepMapper.php4
-rw-r--r--lib/Service/ApiService.php15
3 files changed, 14 insertions, 7 deletions
diff --git a/lib/Db/SessionMapper.php b/lib/Db/SessionMapper.php
index c162d82ae..fc1b7fa79 100644
--- a/lib/Db/SessionMapper.php
+++ b/lib/Db/SessionMapper.php
@@ -47,7 +47,7 @@ class SessionMapper extends QBMapper {
* @return Session
* @throws DoesNotExistException
*/
- public function find($documentId, $sessionId, $token) {
+ public function find($documentId, $sessionId, $token): Session {
/* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder();
$result = $qb->select('*')
diff --git a/lib/Db/StepMapper.php b/lib/Db/StepMapper.php
index 7c15fd44b..1146af6b1 100644
--- a/lib/Db/StepMapper.php
+++ b/lib/Db/StepMapper.php
@@ -51,7 +51,7 @@ class StepMapper extends QBMapper {
return $this->findEntities($qb);
}
- public function deleteAll($documentId) {
+ public function deleteAll($documentId): void {
/* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder();
$qb->delete($this->getTableName())
@@ -59,7 +59,7 @@ class StepMapper extends QBMapper {
->execute();
}
- public function deleteBeforeVersion($documentId, $version) {
+ public function deleteBeforeVersion($documentId, $version): void {
/* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder();
$qb->delete($this->getTableName())
diff --git a/lib/Service/ApiService.php b/lib/Service/ApiService.php
index 2b0280ece..de6e4229a 100644
--- a/lib/Service/ApiService.php
+++ b/lib/Service/ApiService.php
@@ -28,6 +28,7 @@ namespace OCA\Text\Service;
use Exception;
use OC\Files\Node\File;
+use OCA\Activity\Data;
use OCA\Text\DocumentHasUnsavedChangesException;
use OCA\Text\DocumentSaveConflictException;
use OCA\Text\VersionMismatchException;
@@ -37,7 +38,6 @@ use OCP\AppFramework\Http\NotFoundResponse;
use OCP\Constants;
use OCP\Files\NotFoundException;
use OCP\ICacheFactory;
-use OCP\IRequest;
class ApiService {
@@ -45,7 +45,7 @@ class ApiService {
protected $sessionService;
protected $documentService;
- public function __construct(IRequest $request, ICacheFactory $cacheFactory, SessionService $sessionService, DocumentService $documentService) {
+ public function __construct(ICacheFactory $cacheFactory, SessionService $sessionService, DocumentService $documentService) {
$this->cache = $cacheFactory->createDistributed('textSession');
$this->sessionService = $sessionService;
$this->documentService = $documentService;
@@ -75,7 +75,7 @@ class ApiService {
$this->sessionService->removeInactiveSessions($file->getId());
$activeSessions = $this->sessionService->getActiveSessions($file->getId());
- if (count($activeSessions) === 0 || $forceRecreate) {
+ if ($forceRecreate || count($activeSessions) === 0) {
try {
$this->documentService->resetDocument($file->getId(), $forceRecreate);
} catch (DocumentHasUnsavedChangesException $e) {
@@ -121,6 +121,10 @@ class ApiService {
return new DataResponse([]);
}
+ /**
+ * @throws NotFoundException
+ * @throws \OCP\AppFramework\Db\DoesNotExistException
+ */
public function push($documentId, $sessionId, $sessionToken, $version, $steps, $token = null): DataResponse {
if ($token) {
$file = $this->documentService->getFileByShareToken($token);
@@ -171,7 +175,10 @@ class ApiService {
]);
}
- public function updateSession(int $documentId, int $sessionId, string $sessionToken, string $guestName) {
+ /**
+ * @throws \OCP\AppFramework\Db\DoesNotExistException
+ */
+ public function updateSession(int $documentId, int $sessionId, string $sessionToken, string $guestName): DataResponse {
if (!$this->sessionService->isValidSession($documentId, $sessionId, $sessionToken)) {
return new DataResponse([], 500);
}