Skip to content

Commit 3a2eb8c

Browse files
committed
feat: in progress...
Signed-off-by: Eduardo Morales <emoral435@gmail.com>
1 parent 75c489c commit 3a2eb8c

3 files changed

Lines changed: 47 additions & 1 deletion

File tree

apps/files_versions/lib/Listener/FileEventsListener.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ public function post_write_hook(Node $node): void {
238238
'timestamp' => $node->getMTime(),
239239
'size' => $node->getSize(),
240240
'mimetype' => $this->mimeTypeLoader->getId($node->getMimetype()),
241+
'metadata' => [json_encode(array('owner' => $node->getOwner()->getDisplayName(),
242+
'message' => null))],
241243
],
242244
);
243245
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* @copyright Copyright (c) 2024 Eduardo Morales <emoral435@gmail.com>
7+
*
8+
* @license GNU AGPL version 3 or any later version
9+
*
10+
* This program is free software: you can redistribute it and/or modify
11+
* it under the terms of the GNU Affero General Public License as
12+
* published by the Free Software Foundation, either version 3 of the
13+
* License, or (at your option) any later version.
14+
*
15+
* This program is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
* GNU Affero General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU Affero General Public License
21+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22+
*
23+
*/
24+
namespace OCA\Files_Versions\Versions;
25+
26+
use OCP\Files\File;
27+
28+
/**
29+
* This interface edits the metadata column of a node.
30+
* Each column of the metadata has a key => value mapping.
31+
* @since 29.0.0
32+
*/
33+
interface IStoreMetadataBackend {
34+
/**
35+
* Stores the Owner of the last change of the version wihin the metadata column as a blob string.
36+
*
37+
* @since 29.0.0
38+
*/
39+
public function setVersionOwner(File $file): void;
40+
}

apps/files_versions/lib/Versions/LegacyVersionsBackend.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public function createVersionEntity(File $file): void {
268268
$versionEntity->setTimestamp($file->getMTime());
269269
$versionEntity->setSize($file->getSize());
270270
$versionEntity->setMimetype($this->mimeTypeLoader->getId($file->getMimetype()));
271-
$versionEntity->setMetadata([]);
271+
$versionEntity->setMetadata([json_encode(array('owner' => $file->getOwner()->getDisplayName()))]);
272272
$this->versionsMapper->insert($versionEntity);
273273
}
274274

@@ -287,6 +287,10 @@ public function updateVersionEntity(File $sourceFile, int $revision, array $prop
287287
$versionEntity->setMimetype($properties['mimetype']);
288288
}
289289

290+
if (isset($properties['metadata'])) {
291+
$versionEntity->setMetadata($properties['metadata']);
292+
}
293+
290294
$this->versionsMapper->update($versionEntity);
291295
}
292296

0 commit comments

Comments
 (0)