-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat: show the id of last author in versions metadata #44049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
88b40bb
feat: added metadata event listener
emoral435 b2c8554
feat: added backend metadata interface, allows JSON storage
emoral435 4cf4fdc
feat: exposed metadata column to frontend
emoral435 a8844d4
fix(files_version): deprecated INameableVersion
emoral435 c5d1fda
fix: fixed stylistic errors
emoral435 5c6be88
chore(assets): build autoloader
emoral435 bfacc6d
chore(assets): compile assets
emoral435 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
feat: added metadata event listener
Signed-off-by: Eduardo Morales <[email protected]>
- Loading branch information
commit 88b40bb392a2a35d84ef30b2fc7a893aac83fc7c
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * @author Eduardo Morales [email protected]> | ||
| * | ||
| * @license AGPL-3.0 | ||
artonge marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * | ||
| * This code is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License, version 3, | ||
| * as published by the Free Software Foundation. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License, version 3, | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/> | ||
| * | ||
| */ | ||
| namespace OCA\Files_Versions\Listener; | ||
|
|
||
| use OC\Files\Node\Folder; | ||
| use OCA\Files_Versions\Versions\IMetadataVersionBackend; | ||
| use OCA\Files_Versions\Versions\IVersionManager; | ||
| use OCP\EventDispatcher\Event; | ||
| use OCP\EventDispatcher\IEventListener; | ||
| use OCP\Files\Events\Node\NodeWrittenEvent; | ||
| use OCP\Files\Node; | ||
| use OCP\IUserSession; | ||
|
|
||
| /** @template-implements IEventListener<NodeWrittenEvent> */ | ||
| class MetadataFileEvents implements IEventListener { | ||
| public function __construct( | ||
| private IVersionManager $versionManager, | ||
| private IUserSession $userSession, | ||
| ) { | ||
| } | ||
|
|
||
| /** | ||
| * @abstract handles events from a nodes version being changed | ||
| * @param Event $event the event that triggered this listener to activate | ||
| */ | ||
| public function handle(Event $event): void { | ||
| if ($event instanceof NodeWrittenEvent) { | ||
| $this->post_write_hook($event->getNode()); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @abstract handles the NodeWrittenEvent, and sets the metadata for the associated node | ||
| * @param Node $node the node that is currently being written | ||
| */ | ||
| public function post_write_hook(Node $node): void { | ||
| // Do not handle folders or users that we cannot get metadata from | ||
| if ($node instanceof Folder || is_null($this->userSession->getUser())) { | ||
| return; | ||
| } | ||
| // check if our version manager supports setting the metadata | ||
| if ($this->versionManager instanceof IMetadataVersionBackend) { | ||
| $author = $this->userSession->getUser()->getDisplayName() ?? ''; | ||
|
||
| $this->versionManager->setMetadataValue($node, "author", $author); | ||
artonge marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.