aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/Listener/AddMissingIndicesListener.php
blob: d3a1cf4b224ecc1ba77e0a9b09ceaa06248bb4a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php

declare(strict_types=1);
/**
 * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
namespace OCA\DAV\Listener;

use OCP\DB\Events\AddMissingIndicesEvent;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;

/**
 * @template-implements IEventListener<Event|AddMissingIndicesEvent>
 */
class AddMissingIndicesListener implements IEventListener {

	public function handle(Event $event): void {
		if (!($event instanceof AddMissingIndicesEvent)) {
			return;
		}
		$event->addMissingIndex(
			'dav_shares',
			'dav_shares_resourceid_type',
			['resourceid', 'type']
		);
		$event->addMissingIndex(
			'dav_shares',
			'dav_shares_resourceid_access',
			['resourceid', 'access']
		);
		$event->addMissingIndex(
			'calendarobjects',
			'calobjects_by_uid_index',
			['calendarid', 'calendartype', 'uid']
		);
	}

}