Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add size to system message from shared file
Signed-off-by: Vincent Petry <[email protected]>
  • Loading branch information
PVince81 committed Oct 28, 2020
commit 805b1cfc93cfc60247a26fcbece61ffe6804cb61
3 changes: 3 additions & 0 deletions lib/Chat/Parser/SystemMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ protected function getFileFromShare(Participant $participant, string $shareId):
$share = $this->shareProvider->getShareById($shareId);
$node = $share->getNode();
$name = $node->getName();
$size = $node->getSize();
$path = $name;

if (!$participant->isGuest()) {
Expand All @@ -349,6 +350,7 @@ protected function getFileFromShare(Participant $participant, string $shareId):
$fullPath = $userNode->getPath();
$pathSegments = explode('/', $fullPath, 4);
$name = $userNode->getName();
$size = $userNode->getSize();
$path = $pathSegments[3] ?? $path;
}
} else {
Expand All @@ -370,6 +372,7 @@ protected function getFileFromShare(Participant $participant, string $shareId):
'type' => 'file',
'id' => (string) $node->getId(),
'name' => $name,
'size' => $size,
'path' => $path,
'link' => $url,
'mimetype' => $node->getMimeType(),
Expand Down
15 changes: 15 additions & 0 deletions tests/php/Chat/Parser/SystemMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,9 @@ public function testGetFileFromShareForGuest() {
$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())
Expand Down Expand Up @@ -469,6 +472,7 @@ public function testGetFileFromShareForGuest() {
'type' => 'file',
'id' => '54',
'name' => 'name',
'size' => 65530,
'path' => 'name',
'link' => 'absolute-link',
'mimetype' => 'text/plain',
Expand All @@ -490,6 +494,9 @@ public function testGetFileFromShareForOwner() {
$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())
Expand Down Expand Up @@ -529,6 +536,7 @@ public function testGetFileFromShareForOwner() {
'type' => 'file',
'id' => '54',
'name' => 'name',
'size' => 65520,
'path' => 'path/to/file/name',
'link' => 'absolute-link-owner',
'mimetype' => 'httpd/unix-directory',
Expand All @@ -547,6 +555,9 @@ public function testGetFileFromShareForRecipient() {
$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())
Expand All @@ -573,6 +584,9 @@ public function testGetFileFromShareForRecipient() {
$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())
Expand Down Expand Up @@ -602,6 +616,7 @@ public function testGetFileFromShareForRecipient() {
'type' => 'file',
'id' => '54',
'name' => 'different',
'size' => 65515,
'path' => 'Shared/different',
'link' => 'absolute-link-owner',
'mimetype' => 'application/octet-stream',
Expand Down