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:
authorJulien Veyssier <eneiluj@posteo.net>2022-08-23 13:44:08 +0300
committerJulien Veyssier <eneiluj@posteo.net>2022-09-06 15:44:53 +0300
commitf5a34ceef75ce5e234bc8275b84ada6ca22c563e (patch)
treeed392a88053dbf2884066fe1cb31d2c68c1c5e96 /lib
parent5b09a00634aa1012d814c689fbf7a16201e46d2a (diff)
rename image controller/service to attachment
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/Controller/AttachmentController.php (renamed from lib/Controller/ImageController.php)32
-rw-r--r--lib/Cron/Cleanup.php10
-rw-r--r--lib/Listeners/BeforeNodeDeletedListener.php10
-rw-r--r--lib/Listeners/BeforeNodeRenamedListener.php10
-rw-r--r--lib/Listeners/NodeCopiedListener.php10
-rw-r--r--lib/Service/ApiService.php8
-rw-r--r--lib/Service/AttachmentService.php (renamed from lib/Service/ImageService.php)6
7 files changed, 43 insertions, 43 deletions
diff --git a/lib/Controller/ImageController.php b/lib/Controller/AttachmentController.php
index bacec4a0a..501aada9d 100644
--- a/lib/Controller/ImageController.php
+++ b/lib/Controller/AttachmentController.php
@@ -29,7 +29,7 @@ use Exception;
use OCA\Text\Service\SessionService;
use OCA\Text\Exception\UploadException;
use OCP\AppFramework\Http;
-use OCA\Text\Service\ImageService;
+use OCA\Text\Service\AttachmentService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataDownloadResponse;
use OCP\AppFramework\Http\DataResponse;
@@ -40,7 +40,7 @@ use OCP\IRequest;
use OCP\Util;
use Psr\Log\LoggerInterface;
-class ImageController extends Controller {
+class AttachmentController extends Controller {
public const IMAGE_MIME_TYPES = [
'image/png',
'image/jpeg',
@@ -53,7 +53,7 @@ class ImageController extends Controller {
'image/webp',
];
- private ImageService $imageService;
+ private AttachmentService $attachmentService;
private LoggerInterface $logger;
private SessionService $sessionService;
private IL10N $l10n;
@@ -64,10 +64,10 @@ class ImageController extends Controller {
IL10N $l10n,
LoggerInterface $logger,
IMimeTypeDetector $mimeTypeDetector,
- ImageService $imageService,
+ AttachmentService $attachmentService,
SessionService $sessionService) {
parent::__construct($appName, $request);
- $this->imageService = $imageService;
+ $this->attachmentService = $attachmentService;
$this->request = $request;
$this->logger = $logger;
$this->sessionService = $sessionService;
@@ -92,7 +92,7 @@ class ImageController extends Controller {
$userId = $this->getUserIdFromSession($documentId, $sessionId, $sessionToken);
try {
- $insertResult = $this->imageService->insertAttachmentFile($documentId, $filePath, $userId);
+ $insertResult = $this->attachmentService->insertAttachmentFile($documentId, $filePath, $userId);
if (isset($insertResult['error'])) {
return new DataResponse($insertResult, Http::STATUS_BAD_REQUEST);
} else {
@@ -128,10 +128,10 @@ class ImageController extends Controller {
}
$newFileName = $file['name'];
if ($shareToken) {
- $uploadResult = $this->imageService->uploadAttachmentPublic($documentId, $newFileName, $newFileResource, $shareToken);
+ $uploadResult = $this->attachmentService->uploadAttachmentPublic($documentId, $newFileName, $newFileResource, $shareToken);
} else {
$userId = $this->getUserIdFromSession($documentId, $sessionId, $sessionToken);
- $uploadResult = $this->imageService->uploadAttachment($documentId, $newFileName, $newFileResource, $userId);
+ $uploadResult = $this->attachmentService->uploadAttachment($documentId, $newFileName, $newFileResource, $userId);
}
if (isset($uploadResult['error'])) {
return new DataResponse($uploadResult, Http::STATUS_BAD_REQUEST);
@@ -192,10 +192,10 @@ class ImageController extends Controller {
try {
if ($shareToken) {
- $imageFile = $this->imageService->getImageFilePublic($documentId, $imageFileName, $shareToken);
+ $imageFile = $this->attachmentService->getImageFilePublic($documentId, $imageFileName, $shareToken);
} else {
$userId = $this->getUserIdFromSession($documentId, $sessionId, $sessionToken);
- $imageFile = $this->imageService->getImageFile($documentId, $imageFileName, $userId);
+ $imageFile = $this->attachmentService->getImageFile($documentId, $imageFileName, $userId);
}
return $imageFile !== null
? new DataDownloadResponse(
@@ -230,10 +230,10 @@ class ImageController extends Controller {
try {
if ($shareToken) {
- $mediaFile = $this->imageService->getMediaFilePublic($documentId, $mediaFileName, $shareToken);
+ $mediaFile = $this->attachmentService->getMediaFilePublic($documentId, $mediaFileName, $shareToken);
} else {
$userId = $this->getUserIdFromSession($documentId, $sessionId, $sessionToken);
- $mediaFile = $this->imageService->getMediaFile($documentId, $mediaFileName, $userId);
+ $mediaFile = $this->attachmentService->getMediaFile($documentId, $mediaFileName, $userId);
}
return $mediaFile !== null
? new DataDownloadResponse(
@@ -268,10 +268,10 @@ class ImageController extends Controller {
try {
if ($shareToken) {
- $preview = $this->imageService->getMediaFilePreviewPublic($documentId, $mediaFileName, $shareToken);
+ $preview = $this->attachmentService->getMediaFilePreviewPublic($documentId, $mediaFileName, $shareToken);
} else {
$userId = $this->getUserIdFromSession($documentId, $sessionId, $sessionToken);
- $preview = $this->imageService->getMediaFilePreview($documentId, $mediaFileName, $userId);
+ $preview = $this->attachmentService->getMediaFilePreview($documentId, $mediaFileName, $userId);
}
if ($preview === null) {
return new DataResponse('', Http::STATUS_NOT_FOUND);
@@ -312,10 +312,10 @@ class ImageController extends Controller {
try {
if ($shareToken) {
- $metadata = $this->imageService->getMediaFileMetadataPublic($documentId, $mediaFileName, $shareToken);
+ $metadata = $this->attachmentService->getMediaFileMetadataPublic($documentId, $mediaFileName, $shareToken);
} else {
$userId = $this->getUserIdFromSession($documentId, $sessionId, $sessionToken);
- $metadata = $this->imageService->getMediaFileMetadataPrivate($documentId, $mediaFileName, $userId);
+ $metadata = $this->attachmentService->getMediaFileMetadataPrivate($documentId, $mediaFileName, $userId);
}
if ($metadata === null) {
return new DataResponse('', Http::STATUS_NOT_FOUND);
diff --git a/lib/Cron/Cleanup.php b/lib/Cron/Cleanup.php
index 7faf38888..05475de4b 100644
--- a/lib/Cron/Cleanup.php
+++ b/lib/Cron/Cleanup.php
@@ -31,7 +31,7 @@ namespace OCA\Text\Cron;
use OCA\Text\Db\Session;
use OCA\Text\Exception\DocumentHasUnsavedChangesException;
use OCA\Text\Service\DocumentService;
-use OCA\Text\Service\ImageService;
+use OCA\Text\Service\AttachmentService;
use OCA\Text\Service\SessionService;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
@@ -41,17 +41,17 @@ class Cleanup extends TimedJob {
private SessionService $sessionService;
private DocumentService $documentService;
private LoggerInterface $logger;
- private ImageService $imageService;
+ private AttachmentService $attachmentService;
public function __construct(ITimeFactory $time,
SessionService $sessionService,
DocumentService $documentService,
- ImageService $imageService,
+ AttachmentService $attachmentService,
LoggerInterface $logger) {
parent::__construct($time);
$this->sessionService = $sessionService;
$this->documentService = $documentService;
- $this->imageService = $imageService;
+ $this->attachmentService = $attachmentService;
$this->logger = $logger;
$this->setInterval(SessionService::SESSION_VALID_TIME);
}
@@ -71,7 +71,7 @@ class Cleanup extends TimedJob {
try {
$this->logger->debug('Resetting document ' . $session->getDocumentId() . '');
$this->documentService->resetDocument($session->getDocumentId());
- $this->imageService->cleanupAttachments($session->getDocumentId());
+ $this->attachmentService->cleanupAttachments($session->getDocumentId());
$this->logger->debug('Resetting document ' . $session->getDocumentId() . '');
} catch (DocumentHasUnsavedChangesException $e) {
$this->logger->info('Document ' . $session->getDocumentId() . ' has not been reset, as it has unsaved changes');
diff --git a/lib/Listeners/BeforeNodeDeletedListener.php b/lib/Listeners/BeforeNodeDeletedListener.php
index fcd63fdca..77f2a705f 100644
--- a/lib/Listeners/BeforeNodeDeletedListener.php
+++ b/lib/Listeners/BeforeNodeDeletedListener.php
@@ -25,17 +25,17 @@ declare(strict_types=1);
namespace OCA\Text\Listeners;
-use OCA\Text\Service\ImageService;
+use OCA\Text\Service\AttachmentService;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Files\Events\Node\BeforeNodeDeletedEvent;
use OCP\Files\File;
class BeforeNodeDeletedListener implements IEventListener {
- private $imageService;
+ private $attachmentService;
- public function __construct(ImageService $imageService) {
- $this->imageService = $imageService;
+ public function __construct(AttachmentService $attachmentService) {
+ $this->attachmentService = $attachmentService;
}
public function handle(Event $event): void {
@@ -43,7 +43,7 @@ class BeforeNodeDeletedListener implements IEventListener {
return;
}
if ($event->getNode() instanceof File && $event->getNode()->getMimeType() === 'text/markdown') {
- $this->imageService->deleteAttachments($event->getNode());
+ $this->attachmentService->deleteAttachments($event->getNode());
}
}
}
diff --git a/lib/Listeners/BeforeNodeRenamedListener.php b/lib/Listeners/BeforeNodeRenamedListener.php
index 2212b2248..99c459fb4 100644
--- a/lib/Listeners/BeforeNodeRenamedListener.php
+++ b/lib/Listeners/BeforeNodeRenamedListener.php
@@ -25,17 +25,17 @@ declare(strict_types=1);
namespace OCA\Text\Listeners;
-use OCA\Text\Service\ImageService;
+use OCA\Text\Service\AttachmentService;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Files\Events\Node\BeforeNodeRenamedEvent;
use OCP\Files\File;
class BeforeNodeRenamedListener implements IEventListener {
- private $imageService;
+ private $attachmentService;
- public function __construct(ImageService $imageService) {
- $this->imageService = $imageService;
+ public function __construct(AttachmentService $attachmentService) {
+ $this->attachmentService = $attachmentService;
}
public function handle(Event $event): void {
@@ -46,7 +46,7 @@ class BeforeNodeRenamedListener implements IEventListener {
&& $event->getSource()->getMimeType() === 'text/markdown'
&& $event->getTarget() instanceof File
) {
- $this->imageService->moveAttachments($event->getSource(), $event->getTarget());
+ $this->attachmentService->moveAttachments($event->getSource(), $event->getTarget());
}
}
}
diff --git a/lib/Listeners/NodeCopiedListener.php b/lib/Listeners/NodeCopiedListener.php
index bb54c2ce7..59378d786 100644
--- a/lib/Listeners/NodeCopiedListener.php
+++ b/lib/Listeners/NodeCopiedListener.php
@@ -25,17 +25,17 @@ declare(strict_types=1);
namespace OCA\Text\Listeners;
-use OCA\Text\Service\ImageService;
+use OCA\Text\Service\AttachmentService;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Files\Events\Node\NodeCopiedEvent;
use OCP\Files\File;
class NodeCopiedListener implements IEventListener {
- private $imageService;
+ private $attachmentService;
- public function __construct(ImageService $imageService) {
- $this->imageService = $imageService;
+ public function __construct(AttachmentService $attachmentService) {
+ $this->attachmentService = $attachmentService;
}
public function handle(Event $event): void {
@@ -47,7 +47,7 @@ class NodeCopiedListener implements IEventListener {
&& $event->getTarget() instanceof File
&& $event->getTarget()->getMimeType() === 'text/markdown'
) {
- $this->imageService->copyAttachments($event->getSource(), $event->getTarget());
+ $this->attachmentService->copyAttachments($event->getSource(), $event->getTarget());
}
}
}
diff --git a/lib/Service/ApiService.php b/lib/Service/ApiService.php
index c9f7e649d..e2d9c95f9 100644
--- a/lib/Service/ApiService.php
+++ b/lib/Service/ApiService.php
@@ -50,20 +50,20 @@ class ApiService {
private SessionService $sessionService;
private DocumentService $documentService;
private LoggerInterface $logger;
- private ImageService $imageService;
+ private AttachmentService $attachmentService;
private EncodingService $encodingService;
public function __construct(IRequest $request,
SessionService $sessionService,
DocumentService $documentService,
- ImageService $imageService,
+ AttachmentService $attachmentService,
EncodingService $encodingService,
LoggerInterface $logger) {
$this->request = $request;
$this->sessionService = $sessionService;
$this->documentService = $documentService;
$this->logger = $logger;
- $this->imageService = $imageService;
+ $this->attachmentService = $attachmentService;
$this->encodingService = $encodingService;
}
@@ -158,7 +158,7 @@ class ApiService {
if (count($activeSessions) === 0) {
try {
$this->documentService->resetDocument($documentId);
- $this->imageService->cleanupAttachments($documentId);
+ $this->attachmentService->cleanupAttachments($documentId);
} catch (DocumentHasUnsavedChangesException $e) {
}
}
diff --git a/lib/Service/ImageService.php b/lib/Service/AttachmentService.php
index 52f70316f..625bb34d7 100644
--- a/lib/Service/ImageService.php
+++ b/lib/Service/AttachmentService.php
@@ -26,7 +26,7 @@ declare(strict_types=1);
namespace OCA\Text\Service;
-use OCA\Text\Controller\ImageController;
+use OCA\Text\Controller\AttachmentController;
use OCP\Constants;
use OCP\Files\Folder;
use OCP\Files\File;
@@ -41,7 +41,7 @@ use OCP\Util;
use OCP\Files\IRootFolder;
use OCP\Share\IManager as ShareManager;
-class ImageService {
+class AttachmentService {
/**
* @var ShareManager
@@ -113,7 +113,7 @@ class ImageService {
private function getImageFilePreview(string $imageFileName, File $textFile) {
$attachmentFolder = $this->getAttachmentDirectoryForFile($textFile, true);
$imageFile = $attachmentFolder->get($imageFileName);
- if ($imageFile instanceof File && in_array($imageFile->getMimetype(), ImageController::IMAGE_MIME_TYPES)) {
+ if ($imageFile instanceof File && in_array($imageFile->getMimetype(), AttachmentController::IMAGE_MIME_TYPES)) {
if ($this->previewManager->isMimeSupported($imageFile->getMimeType())) {
return $this->previewManager->getPreview($imageFile, 1024, 1024);
}