|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/** |
| 6 | + * @copyright 2024 Christopher Ng <chrng8@gmail.com> |
| 7 | + * |
| 8 | + * @author Christopher Ng <chrng8@gmail.com> |
| 9 | + * |
| 10 | + * @license GNU AGPL version 3 or any later version |
| 11 | + * |
| 12 | + * This program is free software: you can redistribute it and/or modify |
| 13 | + * it under the terms of the GNU Affero General Public License as |
| 14 | + * published by the Free Software Foundation, either version 3 of the |
| 15 | + * License, or (at your option) any later version. |
| 16 | + * |
| 17 | + * This program is distributed in the hope that it will be useful, |
| 18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | + * GNU Affero General Public License for more details. |
| 21 | + * |
| 22 | + * You should have received a copy of the GNU Affero General Public License |
| 23 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 24 | + * |
| 25 | + */ |
| 26 | + |
| 27 | +namespace OCA\Settings\WellKnown; |
| 28 | + |
| 29 | +use OCP\AppFramework\Http\JSONResponse; |
| 30 | +use OCP\Http\WellKnown\GenericResponse; |
| 31 | +use OCP\Http\WellKnown\IHandler; |
| 32 | +use OCP\Http\WellKnown\IRequestContext; |
| 33 | +use OCP\Http\WellKnown\IResponse; |
| 34 | +use OCP\IConfig; |
| 35 | + |
| 36 | +class AssetLinksHandler implements IHandler { |
| 37 | + |
| 38 | + public function __construct( |
| 39 | + private IConfig $config, |
| 40 | + ) { |
| 41 | + } |
| 42 | + |
| 43 | + public function handle(string $service, IRequestContext $context, ?IResponse $previousResponse): ?IResponse { |
| 44 | + if ($service !== 'assetlinks.json') { |
| 45 | + return $previousResponse; |
| 46 | + } |
| 47 | + |
| 48 | + $data = json_decode(file_get_contents(__DIR__ . '/../../data/assetlinks-template.json'), true); |
| 49 | + $data[0]['target']['package_name'] = $this->config->getSystemValueString('assetlinks_package_name', 'com.nextcloud.client'); |
| 50 | + $data[0]['target']['sha256_cert_fingerprints'] = $this->config->getSystemValue( |
| 51 | + 'assetlinks_sha256_cert_fingerprints', |
| 52 | + [ |
| 53 | + '59:BF:BB:8A:5C:17:53:D6:69:AE:C0:D8:CC:D0:DA:82:76:FE:8E:AC:81:A4:45:22:AE:68:0E:A7:74:81:A3:32', |
| 54 | + ], |
| 55 | + ); |
| 56 | + return new GenericResponse(new JSONResponse($data)); |
| 57 | + } |
| 58 | +} |
0 commit comments