diff --git a/lib/Service/Attachment/AttachmentService.php b/lib/Service/Attachment/AttachmentService.php index c91ad6f23c..929863c927 100644 --- a/lib/Service/Attachment/AttachmentService.php +++ b/lib/Service/Attachment/AttachmentService.php @@ -27,6 +27,7 @@ use OCP\AppFramework\Db\DoesNotExistException; use OCP\Files\File; use OCP\Files\Folder; +use OCP\Files\IMimeTypeDetector; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; use OCP\ICache; @@ -72,6 +73,7 @@ public function __construct( MessageMapper $imapMessageMapper, ICacheFactory $cacheFactory, private IURLGenerator $urlGenerator, + private IMimeTypeDetector $mimeTypeDetector, LoggerInterface $logger, ) { $this->mapper = $mapper; @@ -288,7 +290,8 @@ public function getAttachmentNames(Account $account, Mailbox $mailbox, Message $ 'attachmentId' => $attachment['id'], ]); $downloadUrl = $this->urlGenerator->getAbsoluteURL($downloadUrl); - return ['id' => $attachment['id'] , 'fileName' => $attachment['fileName'], 'mime' => $attachment['mime'], 'downloadUrl' => $downloadUrl]; + $mimeUrl = $this->mimeTypeDetector->mimeTypeIcon($attachment['mime']); + return ['id' => $attachment['id'] , 'fileName' => $attachment['fileName'], 'mime' => $attachment['mime'], 'downloadUrl' => $downloadUrl, 'mimeUrl' => $mimeUrl ]; }, $attachments); $this->cache->set($uniqueCacheId, $result); return $result; diff --git a/src/components/AttachmentTag.vue b/src/components/AttachmentTag.vue index 494ab44ed1..059a5055b4 100644 --- a/src/components/AttachmentTag.vue +++ b/src/components/AttachmentTag.vue @@ -4,7 +4,7 @@ --> @@ -54,6 +58,10 @@ export default { text-overflow: ellipsis; overflow: hidden; } + + &__icon{ + width: 16px; + } } .attachment-tag--remaing{ diff --git a/src/components/Envelope.vue b/src/components/Envelope.vue index 858010eba0..67876fe570 100644 --- a/src/components/Envelope.vue +++ b/src/components/Envelope.vue @@ -482,6 +482,7 @@ diff --git a/src/components/icons/FileIcon.vue b/src/components/icons/FileIcon.vue deleted file mode 100644 index b290c1d166..0000000000 --- a/src/components/icons/FileIcon.vue +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - diff --git a/src/store/constants.js b/src/store/constants.js index ee76ba8f4e..d34e342e58 100644 --- a/src/store/constants.js +++ b/src/store/constants.js @@ -18,6 +18,3 @@ export const STATUS_IMAP_SENT_MAILBOX_FAIL = 11 export const STATUS_SMTP_ERROR = 13 export const FOLLOW_UP_TAG_LABEL = '$follow_up' -export const FILE_EXTENSIONS_WORD_PROCESSING = ['doc', 'docx', 'dot', 'odt', 'dotx', 'odt', 'ott'] -export const FILE_EXTENSIONS_SPREADSHEET = ['xls', 'xlsx', 'ods'] -export const FILE_EXTENSIONS_PRESENTATION = ['ppt', 'pptx', 'odp', 'otp', 'pps', 'ppsx', 'pot', 'potx'] diff --git a/tests/Integration/Service/DraftServiceIntegrationTest.php b/tests/Integration/Service/DraftServiceIntegrationTest.php index ec762efb66..24b3e9afb8 100644 --- a/tests/Integration/Service/DraftServiceIntegrationTest.php +++ b/tests/Integration/Service/DraftServiceIntegrationTest.php @@ -32,6 +32,7 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Folder; +use OCP\Files\IMimeTypeDetector; use OCP\ICacheFactory; use OCP\IDBConnection; use OCP\IServerContainer; @@ -100,6 +101,7 @@ protected function setUp(): void { Server::get(MessageMapper::class), Server::get(ICacheFactory::class), Server::get(IURLGenerator::class), + Server::get(IMimeTypeDetector::class), new NullLogger() ); $this->client = $this->getClient($this->account); diff --git a/tests/Integration/Service/OutboxServiceIntegrationTest.php b/tests/Integration/Service/OutboxServiceIntegrationTest.php index 04e2319fd9..a503e7b483 100644 --- a/tests/Integration/Service/OutboxServiceIntegrationTest.php +++ b/tests/Integration/Service/OutboxServiceIntegrationTest.php @@ -34,6 +34,7 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Folder; +use OCP\Files\IMimeTypeDetector; use OCP\ICacheFactory; use OCP\IDBConnection; use OCP\IServerContainer; @@ -101,6 +102,7 @@ protected function setUp(): void { Server::get(\OCA\Mail\IMAP\MessageMapper::class), Server::get(ICacheFactory::class), Server::get(IURLGenerator::class), + Server::get(IMimeTypeDetector::class), new NullLogger() ); $this->client = $this->getClient($this->account); diff --git a/tests/Unit/Service/Attachment/AttachmentServiceTest.php b/tests/Unit/Service/Attachment/AttachmentServiceTest.php index 1e2d98f165..fd4c25e78d 100644 --- a/tests/Unit/Service/Attachment/AttachmentServiceTest.php +++ b/tests/Unit/Service/Attachment/AttachmentServiceTest.php @@ -25,6 +25,7 @@ use OCA\Mail\Service\Attachment\UploadedFile; use OCP\AppFramework\Db\DoesNotExistException; use OCP\Files\Folder; +use OCP\Files\IMimeTypeDetector; use OCP\Files\NotPermittedException; use OCP\ICacheFactory; use OCP\IURLGenerator; @@ -61,6 +62,8 @@ class AttachmentServiceTest extends TestCase { /** @var MockObject|IURLGenerator */ private $urlGenerator; + /** @var MockObject|IMimeTypeDetector */ + protected function setUp(): void { parent::setUp(); @@ -72,6 +75,7 @@ protected function setUp(): void { $this->cacheFactory = $this->createMock(ICacheFactory::class); $this->urlGenerator = $this->createMock(IURLGenerator::class); $this->logger = $this->createMock(LoggerInterface::class); + $this->mimeTypeDetector = $this->createMock(IMimeTypeDetector::class); $this->service = new AttachmentService( $this->userFolder, @@ -81,6 +85,7 @@ protected function setUp(): void { $this->messageMapper, $this->cacheFactory, $this->urlGenerator, + $this->mimeTypeDetector, $this->logger ); }