Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/Service/Attachment/AttachmentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -72,6 +73,7 @@ public function __construct(
MessageMapper $imapMessageMapper,
ICacheFactory $cacheFactory,
private IURLGenerator $urlGenerator,
private IMimeTypeDetector $mimeTypeDetector,
LoggerInterface $logger,
) {
$this->mapper = $mapper;
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 11 additions & 3 deletions src/components/AttachmentTag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
-->
<template>
<div class="attachment-tag" :class="{ 'attachment-tag--remaing': remaining > 0 }" @click="$emit('open')">
<FileIcon v-if="remaining === 0" :file-name="fileName" :mime-type="mimeType" />
<img v-if="remaining === 0" class="attachment-tag__icon" :src="mimeUrl">
<p class="attachment-tag__filename">
{{ remaining > 0 ? `+${remaining}` : fileName }}
</p>
</div>
</template>

<script>
import FileIcon from './icons/FileIcon.vue'

export default {
name: 'AttachmentTag',
components: { FileIcon },
props: {
fileName: {
type: String,
Expand All @@ -31,6 +30,11 @@ export default {
type: Number,
default: 0,
},

mimeUrl: {
type: String,
default: '',
},
},
}
</script>
Expand All @@ -54,6 +58,10 @@ export default {
text-overflow: ellipsis;
overflow: hidden;
}

&__icon{
width: 16px;
}
}

.attachment-tag--remaing{
Expand Down
1 change: 1 addition & 0 deletions src/components/Envelope.vue
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@
<AttachmentTag
:file-name="attachment.fileName"
:mime-type="attachment.mime"
:mime-url="attachment.mimeUrl"
@open="showViewer(fileInfos[idx])" />
</div>
<AttachmentTag v-if="remainingAttachements > 0" :remaining="remainingAttachements" />
Expand Down
107 changes: 0 additions & 107 deletions src/components/icons/FileIcon.vue

This file was deleted.

3 changes: 0 additions & 3 deletions src/store/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']
2 changes: 2 additions & 0 deletions tests/Integration/Service/DraftServiceIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions tests/Integration/Service/OutboxServiceIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions tests/Unit/Service/Attachment/AttachmentServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -61,6 +62,8 @@ class AttachmentServiceTest extends TestCase {
/** @var MockObject|IURLGenerator */
private $urlGenerator;

/** @var MockObject|IMimeTypeDetector */

protected function setUp(): void {
parent::setUp();

Expand All @@ -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,
Expand All @@ -81,6 +85,7 @@ protected function setUp(): void {
$this->messageMapper,
$this->cacheFactory,
$this->urlGenerator,
$this->mimeTypeDetector,
$this->logger
);
}
Expand Down
Loading