2014-05-28 17:13:07 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 15:07:57 +00:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
2016-09-29 14:38:29 +00:00
|
|
|
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
|
2016-07-21 15:07:57 +00:00
|
|
|
*
|
2019-12-03 18:57:53 +00:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2016-07-21 15:07:57 +00:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2022-10-22 10:49:11 +00:00
|
|
|
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
2020-12-16 13:54:15 +00:00
|
|
|
* @author Julius Härtl <jus@bitgrid.net>
|
2016-05-26 17:56:05 +00:00
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
2020-08-24 12:54:25 +00:00
|
|
|
* @author Mario Danic <mario@lovelyhq.com>
|
2015-03-26 10:44:34 +00:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2019-12-03 18:57:53 +00:00
|
|
|
* @author Robin Appelman <robin@icewind.nl>
|
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2020-03-31 08:49:10 +00:00
|
|
|
* @author Thomas Citharel <nextcloud@tcit.fr>
|
2015-03-26 10:44:34 +00:00
|
|
|
* @author Victor Dubiniuk <dubiniuk@owncloud.com>
|
|
|
|
*
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* 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,
|
2019-12-03 18:57:53 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
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;
|
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
|
|
|
|
2019-04-15 19:19:32 +00:00
|
|
|
$notificationManager = $server->getNotificationManager();
|
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_id_storage_size',
|
|
|
|
['fileid', 'storage', 'size']
|
|
|
|
);
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'filecache',
|
|
|
|
'fs_storage_path_prefix',
|
|
|
|
['storage', 'path'],
|
|
|
|
['lengths' => [null, 64]]
|
|
|
|
);
|
|
|
|
$event->addMissingIndex(
|
|
|
|
'filecache',
|
|
|
|
'fs_parent',
|
|
|
|
['parent']
|
|
|
|
);
|
|
|
|
|
|
|
|
$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',
|
|
|
|
'preferences_app_key',
|
|
|
|
['appid', 'configkey']
|
|
|
|
);
|
|
|
|
|
|
|
|
$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']
|
|
|
|
);
|
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
|
|
|
}
|