Add size to system message from shared file

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
This commit is contained in:
Vincent Petry 2020-10-26 20:10:42 +01:00
Родитель 7083bbc04f
Коммит 805b1cfc93
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E055D6A4D513575C
2 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@ -323,6 +323,7 @@ class SystemMessage {
$share = $this->shareProvider->getShareById($shareId);
$node = $share->getNode();
$name = $node->getName();
$size = $node->getSize();
$path = $name;
if (!$participant->isGuest()) {
@ -349,6 +350,7 @@ class SystemMessage {
$fullPath = $userNode->getPath();
$pathSegments = explode('/', $fullPath, 4);
$name = $userNode->getName();
$size = $userNode->getSize();
$path = $pathSegments[3] ?? $path;
}
} else {
@ -370,6 +372,7 @@ class SystemMessage {
'type' => 'file',
'id' => (string) $node->getId(),
'name' => $name,
'size' => $size,
'path' => $path,
'link' => $url,
'mimetype' => $node->getMimeType(),

Просмотреть файл

@ -433,6 +433,9 @@ class SystemMessageTest extends TestCase {
$node->expects($this->once())
->method('getMimeType')
->willReturn('text/plain');
$node->expects($this->once())
->method('getSize')
->willReturn(65530);
$share = $this->createMock(IShare::class);
$share->expects($this->once())
@ -469,6 +472,7 @@ class SystemMessageTest extends TestCase {
'type' => 'file',
'id' => '54',
'name' => 'name',
'size' => 65530,
'path' => 'name',
'link' => 'absolute-link',
'mimetype' => 'text/plain',
@ -490,6 +494,9 @@ class SystemMessageTest extends TestCase {
$node->expects($this->once())
->method('getMimeType')
->willReturn('httpd/unix-directory');
$node->expects($this->once())
->method('getSize')
->willReturn(65520);
$share = $this->createMock(IShare::class);
$share->expects($this->once())
@ -529,6 +536,7 @@ class SystemMessageTest extends TestCase {
'type' => 'file',
'id' => '54',
'name' => 'name',
'size' => 65520,
'path' => 'path/to/file/name',
'link' => 'absolute-link-owner',
'mimetype' => 'httpd/unix-directory',
@ -547,6 +555,9 @@ class SystemMessageTest extends TestCase {
$node->expects($this->once())
->method('getMimeType')
->willReturn('application/octet-stream');
$node->expects($this->once())
->method('getSize')
->willReturn(65510);
$share = $this->createMock(IShare::class);
$share->expects($this->once())
@ -573,6 +584,9 @@ class SystemMessageTest extends TestCase {
$file->expects($this->once())
->method('getPath')
->willReturn('/user/files/Shared/different');
$file->expects($this->once())
->method('getSize')
->willReturn(65515);
$userFolder = $this->createMock(Folder::class);
$userFolder->expects($this->once())
@ -602,6 +616,7 @@ class SystemMessageTest extends TestCase {
'type' => 'file',
'id' => '54',
'name' => 'different',
'size' => 65515,
'path' => 'Shared/different',
'link' => 'absolute-link-owner',
'mimetype' => 'application/octet-stream',