2014-05-28 17:13:07 +00:00
|
|
|
<?php
|
2025-02-13 09:35:13 +00:00
|
|
|
|
2014-05-28 17:13:07 +00:00
|
|
|
/**
|
2024-05-27 08:08:53 +00:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2014-05-28 17:13:07 +00:00
|
|
|
*/
|
2014-08-22 16:16:55 +00:00
|
|
|
namespace OC\Core;
|
2014-05-28 17:13:07 +00:00
|
|
|
|
2019-05-28 15:56:01 +00:00
|
|
|
use OC\Authentication\Events\RemoteWipeFinished;
|
|
|
|
use OC\Authentication\Events\RemoteWipeStarted;
|
|
|
|
use OC\Authentication\Listeners\RemoteWipeActivityListener;
|
2019-07-02 12:58:48 +00:00
|
|
|
use OC\Authentication\Listeners\RemoteWipeEmailListener;
|
2019-05-28 15:56:01 +00:00
|
|
|
use OC\Authentication\Listeners\RemoteWipeNotificationsListener;
|
2021-04-27 13:43:34 +00:00
|
|
|
use OC\Authentication\Listeners\UserDeletedFilesCleanupListener;
|
2020-01-08 09:51:44 +00:00
|
|
|
use OC\Authentication\Listeners\UserDeletedStoreCleanupListener;
|
2020-06-15 14:09:39 +00:00
|
|
|
use OC\Authentication\Listeners\UserDeletedTokenCleanupListener;
|
2021-06-16 15:03:33 +00:00
|
|
|
use OC\Authentication\Listeners\UserDeletedWebAuthnCleanupListener;
|
2019-04-03 14:00:46 +00:00
|
|
|
use OC\Authentication\Notifications\Notifier as AuthenticationNotifier;
|
2022-10-22 10:49:11 +00:00
|
|
|
use OC\Core\Listener\BeforeTemplateRenderedListener;
|
2020-12-02 09:07:34 +00:00
|
|
|
use OC\Core\Notification\CoreNotifier;
|
2022-04-19 11:05:38 +00:00
|
|
|
use OC\TagManager;
|
2016-04-25 12:10:55 +00:00
|
|
|
use OCP\AppFramework\App;
|
2023-08-14 15:47:10 +00:00
|
|
|
use OCP\AppFramework\Http\Events\BeforeLoginTemplateRenderedEvent;
|
2022-10-22 10:49:11 +00:00
|
|
|
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
|
2023-07-19 21:48:11 +00:00
|
|
|
use OCP\DB\Events\AddMissingIndicesEvent;
|
2023-07-19 21:10:13 +00:00
|
|
|
use OCP\DB\Events\AddMissingPrimaryKeyEvent;
|
2019-05-28 15:56:01 +00:00
|
|
|
use OCP\EventDispatcher\IEventDispatcher;
|
2023-08-29 22:12:25 +00:00
|
|
|
use OCP\Notification\IManager as INotificationManager;
|
2021-04-27 13:43:34 +00:00
|
|
|
use OCP\User\Events\BeforeUserDeletedEvent;
|
2020-01-08 09:51:44 +00:00
|
|
|
use OCP\User\Events\UserDeletedEvent;
|
2016-04-25 12:10:55 +00:00
|
|
|
use OCP\Util;
|
2014-05-28 17:13:07 +00:00
|
|
|
|
2014-10-20 17:05:48 +00:00
|
|
|
/**
|
|
|
|
* Class Application
|
|
|
|
*
|
|
|
|
* @package OC\Core
|
|
|
|
*/
|
2014-05-28 17:13:07 +00:00
|
|
|
class Application extends App {
|
2016-09-29 14:38:29 +00:00
|
|
|
public function __construct() {
|
|
|
|
parent::__construct('core');
|
2014-05-28 17:13:07 +00:00
|
|
|
|
|
|
|
$container = $this->getContainer();
|
2016-08-28 12:22:29 +00:00
|
|
|
|
2016-11-17 16:35:14 +00:00
|
|
|
$container->registerService('defaultMailAddress', function () {
|
2014-10-20 17:05:48 +00:00
|
|
|
return Util::getDefaultEmailAddress('lostpassword-noreply');
|
|
|
|
});
|
2018-06-04 14:20:01 +00:00
|
|
|
|
|
|
|
$server = $container->getServer();
|
2019-05-28 15:56:01 +00:00
|
|
|
/** @var IEventDispatcher $eventDispatcher */
|
2022-04-19 11:05:38 +00:00
|
|
|
$eventDispatcher = $server->get(IEventDispatcher::class);
|
2018-06-04 14:20:01 +00:00
|
|
|
|
2023-08-29 22:12:25 +00:00
|
|
|
$notificationManager = $server->get(INotificationManager::class);
|
2020-12-02 09:07:34 +00:00
|
|
|
$notificationManager->registerNotifierService(CoreNotifier::class);
|
2019-07-16 09:36:32 +00:00
|
|
|
$notificationManager->registerNotifierService(AuthenticationNotifier::class);
|
2019-04-15 19:19:32 +00:00
|
|
|
|
2023-07-19 21:48:11 +00:00
|
|
|
$eventDispatcher->addListener(AddMissingIndicesEvent::class, function (AddMissingIndicesEvent $event) {
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'share',
|
|
|
|
'share_with_index',
|
|
|
|
['share_with']
|
|
|
|
);
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'share',
|
|
|
|
'parent_index',
|
|
|
|
['parent']
|
|
|
|
);
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'share',
|
|
|
|
'owner_index',
|
|
|
|
['uid_owner']
|
|
|
|
);
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'share',
|
|
|
|
'initiator_index',
|
|
|
|
['uid_initiator']
|
|
|
|
);
|
|
|
|
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'filecache',
|
|
|
|
'fs_mtime',
|
|
|
|
['mtime']
|
|
|
|
);
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'filecache',
|
|
|
|
'fs_size',
|
|
|
|
['size']
|
|
|
|
);
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'filecache',
|
|
|
|
'fs_storage_path_prefix',
|
|
|
|
['storage', 'path'],
|
|
|
|
['lengths' => [null, 64]]
|
|
|
|
);
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'filecache',
|
|
|
|
'fs_parent',
|
|
|
|
['parent']
|
|
|
|
);
|
2024-03-30 19:14:27 +00:00
|
|
|
$event->addMissingIndex(
|
|
|
|
'filecache',
|
|
|
|
'fs_name_hash',
|
|
|
|
['name']
|
|
|
|
);
|
2023-07-19 21:48:11 +00:00
|
|
|
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'twofactor_providers',
|
|
|
|
'twofactor_providers_uid',
|
|
|
|
['uid']
|
|
|
|
);
|
|
|
|
|
|
|
|
$event->addMissingUniqueIndex(
|
|
|
|
'login_flow_v2',
|
|
|
|
'poll_token',
|
|
|
|
['poll_token'],
|
|
|
|
[],
|
|
|
|
true
|
|
|
|
);
|
|
|
|
$event->addMissingUniqueIndex(
|
|
|
|
'login_flow_v2',
|
|
|
|
'login_token',
|
|
|
|
['login_token'],
|
|
|
|
[],
|
|
|
|
true
|
|
|
|
);
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'login_flow_v2',
|
|
|
|
'timestamp',
|
|
|
|
['timestamp'],
|
|
|
|
[],
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'whats_new',
|
|
|
|
'version',
|
|
|
|
['version'],
|
|
|
|
[],
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'cards',
|
|
|
|
'cards_abiduri',
|
|
|
|
['addressbookid', 'uri'],
|
|
|
|
[],
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'cards_properties',
|
|
|
|
'cards_prop_abid',
|
|
|
|
['addressbookid'],
|
|
|
|
[],
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'calendarobjects_props',
|
|
|
|
'calendarobject_calid_index',
|
|
|
|
['calendarid', 'calendartype']
|
|
|
|
);
|
|
|
|
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'schedulingobjects',
|
|
|
|
'schedulobj_principuri_index',
|
|
|
|
['principaluri']
|
|
|
|
);
|
|
|
|
|
2024-05-08 18:38:51 +00:00
|
|
|
$event->addMissingIndex(
|
|
|
|
'schedulingobjects',
|
|
|
|
'schedulobj_lastmodified_idx',
|
|
|
|
['lastmodified']
|
|
|
|
);
|
|
|
|
|
2023-07-19 21:48:11 +00:00
|
|
|
$event->addMissingIndex(
|
|
|
|
'properties',
|
|
|
|
'properties_path_index',
|
|
|
|
['userid', 'propertypath']
|
|
|
|
);
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'properties',
|
|
|
|
'properties_pathonly_index',
|
|
|
|
['propertypath']
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'jobs',
|
|
|
|
'job_lastcheck_reserved',
|
|
|
|
['last_checked', 'reserved_at']
|
|
|
|
);
|
|
|
|
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'direct_edit',
|
|
|
|
'direct_edit_timestamp',
|
|
|
|
['timestamp']
|
|
|
|
);
|
|
|
|
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'preferences',
|
2025-01-15 10:25:18 +00:00
|
|
|
'prefs_uid_lazy_i',
|
|
|
|
['userid', 'lazy']
|
|
|
|
);
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'preferences',
|
|
|
|
'prefs_app_key_ind_fl_i',
|
|
|
|
['appid', 'configkey', 'indexed', 'flags']
|
2023-07-19 21:48:11 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'mounts',
|
|
|
|
'mounts_class_index',
|
|
|
|
['mount_provider_class']
|
|
|
|
);
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'mounts',
|
|
|
|
'mounts_user_root_path_index',
|
|
|
|
['user_id', 'root_id', 'mount_point'],
|
|
|
|
['lengths' => [null, null, 128]]
|
|
|
|
);
|
|
|
|
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'systemtag_object_mapping',
|
|
|
|
'systag_by_tagid',
|
|
|
|
['systemtagid', 'objecttype']
|
|
|
|
);
|
2024-05-14 10:12:29 +00:00
|
|
|
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'systemtag_object_mapping',
|
|
|
|
'systag_by_objectid',
|
|
|
|
['objectid']
|
|
|
|
);
|
2025-01-15 15:57:45 +00:00
|
|
|
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'systemtag_object_mapping',
|
|
|
|
'systag_objecttype',
|
|
|
|
['objecttype']
|
|
|
|
);
|
2023-07-19 21:48:11 +00:00
|
|
|
});
|
2019-05-28 15:56:01 +00:00
|
|
|
|
2023-07-19 21:10:13 +00:00
|
|
|
$eventDispatcher->addListener(AddMissingPrimaryKeyEvent::class, function (AddMissingPrimaryKeyEvent $event) {
|
|
|
|
$event->addMissingPrimaryKey(
|
|
|
|
'federated_reshares',
|
|
|
|
'federated_res_pk',
|
|
|
|
['share_id'],
|
|
|
|
'share_id_index'
|
|
|
|
);
|
|
|
|
|
|
|
|
$event->addMissingPrimaryKey(
|
|
|
|
'systemtag_object_mapping',
|
|
|
|
'som_pk',
|
|
|
|
['objecttype', 'objectid', 'systemtagid'],
|
|
|
|
'mapping'
|
|
|
|
);
|
|
|
|
|
|
|
|
$event->addMissingPrimaryKey(
|
|
|
|
'comments_read_markers',
|
|
|
|
'crm_pk',
|
|
|
|
['user_id', 'object_type', 'object_id'],
|
|
|
|
'comments_marker_index'
|
|
|
|
);
|
|
|
|
|
|
|
|
$event->addMissingPrimaryKey(
|
|
|
|
'collres_resources',
|
|
|
|
'crr_pk',
|
|
|
|
['collection_id', 'resource_type', 'resource_id'],
|
|
|
|
'collres_unique_res'
|
|
|
|
);
|
|
|
|
|
|
|
|
$event->addMissingPrimaryKey(
|
|
|
|
'collres_accesscache',
|
|
|
|
'cra_pk',
|
|
|
|
['user_id', 'collection_id', 'resource_type', 'resource_id'],
|
|
|
|
'collres_unique_user'
|
|
|
|
);
|
|
|
|
|
|
|
|
$event->addMissingPrimaryKey(
|
|
|
|
'filecache_extended',
|
|
|
|
'fce_pk',
|
|
|
|
['fileid'],
|
|
|
|
'fce_fileid_idx'
|
|
|
|
);
|
|
|
|
});
|
2020-11-10 08:34:57 +00:00
|
|
|
|
2022-10-22 10:49:11 +00:00
|
|
|
$eventDispatcher->addServiceListener(BeforeTemplateRenderedEvent::class, BeforeTemplateRenderedListener::class);
|
2023-08-14 15:47:10 +00:00
|
|
|
$eventDispatcher->addServiceListener(BeforeLoginTemplateRenderedEvent::class, BeforeTemplateRenderedListener::class);
|
2019-05-28 15:56:01 +00:00
|
|
|
$eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeActivityListener::class);
|
|
|
|
$eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeNotificationsListener::class);
|
2019-07-02 12:58:48 +00:00
|
|
|
$eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeEmailListener::class);
|
2019-05-28 15:56:01 +00:00
|
|
|
$eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeActivityListener::class);
|
|
|
|
$eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeNotificationsListener::class);
|
2019-07-02 12:58:48 +00:00
|
|
|
$eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeEmailListener::class);
|
2020-01-08 09:51:44 +00:00
|
|
|
$eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedStoreCleanupListener::class);
|
2020-06-15 14:09:39 +00:00
|
|
|
$eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedTokenCleanupListener::class);
|
2021-04-27 13:43:34 +00:00
|
|
|
$eventDispatcher->addServiceListener(BeforeUserDeletedEvent::class, UserDeletedFilesCleanupListener::class);
|
|
|
|
$eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedFilesCleanupListener::class);
|
2021-06-16 15:03:33 +00:00
|
|
|
$eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedWebAuthnCleanupListener::class);
|
2022-04-04 21:15:00 +00:00
|
|
|
|
2022-04-19 11:05:38 +00:00
|
|
|
// Tags
|
|
|
|
$eventDispatcher->addServiceListener(UserDeletedEvent::class, TagManager::class);
|
2014-10-20 17:05:48 +00:00
|
|
|
}
|
2014-05-28 17:13:07 +00:00
|
|
|
}
|