Skip to content

Conversation

@printminion-co
Copy link
Contributor

@printminion-co printminion-co commented Jan 13, 2026

Summary

This PR introduces a new event InstallationCompletedEvent that is dispatched after a successful Nextcloud installation. This allows apps and integrations to hook into the installation process and perform additional actions once the system is fully set up.

Changes

New Event Class

  • Added OCP\Install\Events\InstallationCompletedEvent - a typed event that provides:
    • Data directory path
    • Admin username (if created)
    • Admin email (if configured)
    • Helper method hasAdminUser() to check if an admin was created

Integration

  • Modified OC\Setup to dispatch the event after successful installation:
    • Added IEventDispatcher dependency
    • Event is dispatched after database setup, admin user creation, app installation, and background jobs configuration
    • Passes installation details (data directory, admin username, admin email) to event listeners

Tests

  • Comprehensive test suite for InstallationCompletedEvent (7 tests, 23 assertions)
    • Constructor parameter validation
    • Getter methods
    • Edge cases (null values, minimal parameters)
  • Extended SetupTest with integration tests (3 new tests)
    • Event dispatcher injection
    • Event parameter validation from install options
    • Handling of disabled admin user scenario

Use Cases

Apps can listen to this event to:

  • Send welcome/notification emails
  • Trigger external API integrations
  • Initialize app-specific data structures
  • Set up monitoring or logging systems
  • Configure third-party services
  • Report installation completion to management systems

Example Usage

<?php
namespace OCA\MyApp\Listeners;

use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Install\Events\InstallationCompletedEvent;

class InstallationCompletedListener implements IEventListener {
    public function handle(Event $event): void {
        if (!($event instanceof InstallationCompletedEvent)) {
            return;
        }

        $dataDir = $event->getDataDirectory();
        $adminUsername = $event->getAdminUsername();
        
        if ($event->hasAdminUser()) {
            // Perform actions with admin user info
            $this->sendWelcomeEmail($adminUsername, $event->getAdminEmail());
        }
        
        // Initialize app-specific data
        $this->initializeAppData($dataDir);
    }
}

Breaking Changes

None. This is a new event that doesn't modify any existing behavior.

API Version

@since 31.0.0

Testing

✅ All tests passing:

  • InstallationCompletedEventTest: 7/7 tests passed, 23 assertions
  • SetupTest: 21/21 tests passed, 47 assertions (including 3 new tests)
  • No regressions in existing test suite

Files Changed

  • lib/public/Install/Events/InstallationCompletedEvent.php (new, 79 lines)
  • lib/private/Setup.php (modified, +10 lines)
  • tests/lib/Install/Events/InstallationCompletedEventTest.php (new, 89 lines)
  • tests/lib/SetupTest.php (modified, +88 lines)

Total: 266 insertions, 1 deletion

Checklist

  • Event class follows Nextcloud event naming conventions
  • Comprehensive documentation in docblocks
  • Full test coverage for event class
  • Integration tests for event dispatching
  • No breaking changes to existing code
  • Event dispatched at the correct point in installation flow
  • Proper @since annotations

@printminion-co printminion-co requested a review from a team as a code owner January 13, 2026 15:07
@printminion-co printminion-co requested review from ArtificialOwl, icewind1991, salmart-dev and sorbaugh and removed request for a team January 13, 2026 15:07
@printminion-co printminion-co force-pushed the feature/add_postinstall_event branch from a4987a7 to eaea8ed Compare January 13, 2026 15:08
@printminion-co printminion-co changed the title add postinstall event Add InstallationCompletedEvent for post-installation actions Jan 13, 2026
@printminion-co printminion-co force-pushed the feature/add_postinstall_event branch from eaea8ed to 68ec825 Compare January 13, 2026 15:46
…ctions

Add InstallationCompletedEvent that is dispatched after successful
setup completion, providing installation details like data directory,
admin username, and admin email. This allows apps and modules to
perform actions after the installation is complete.

Signed-off-by: Misha M.-Kupriyanov <[email protected]>
…tion

Add event dispatcher injection to Setup class and dispatch
InstallationCompletedEvent with installation details (data directory,
admin username, and admin email) after successful installation.
Update SetupTest to mock the new IEventDispatcher dependency.

Signed-off-by: Misha M.-Kupriyanov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants