Closed hweihwang closed 6 months ago
Hello there, Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.
We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.
Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6
Thank you for contributing to Nextcloud and we hope to hear from you soon!
This PR introduces audit logging for critical operations in the Tables app, addressing issue #956. The goal is to enhance compliance measures by logging critical operations into a dedicated log file.
Changes
Introduced
AuditLogServiceInterface
, which outlines the contract for audit logging within the application. TheDefaultAuditLogService
is the default implementation that dispatchesCriticalActionPerformedEvent
to interact with the AuditLog App. This service is auto-resolved by registering it in the Dependency Injection ContainerApplication.php
. This design allows for future extensibility, such as integrating different logging methods or services for AuditLog.Developed event dispatchers for corresponding events to trigger audit logs (
TableDeletedEvent
=>WhenRowDeletedAuditLogListener
,ViewDeletedEvent
=>WhenViewDeletedAuditLogListener
, etc.). This is a standard event-driven approach that decouples auxiliary logic (logging, mail sending, etc.) from the core business logic, effectively handling side effects. Most of these operations can be executed asynchronously via a queue. Each Listener is encapsulated in its own class adhering to the Single Responsibility Principle. TheAuditLogServiceInterface
is injected into each listener to further promote decoupling.Testing
Unit tests have been added for the new service and listeners. These tests can be run by executing into the server container and running
composer test
.Potential Improvements
Implementing a separate background queue worker for all listeners could offload non-business logic from the main service logic, improving performance, especially when dealing with external API calls or IO intensive operations.
Applying Database Transactions: The TableService interacts with multiple tables simultaneously (Table, View, Row, Column). Implementing DB transactions and error handling mechanisms can ensure the integrity and reliability of operations.
Please review and provide your feedback, thank you @juliushaertl!