Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

💬 Configure a contact person to directly start a chat with (requires [Nextcloud Talk](https://apps.nextcloud.com/apps/spreed) to be installed)
]]></description>
<version>1.4.0</version>
<version>2.0.0</version>
<licence>agpl</licence>
<author>Julien Veyssier</author>
<namespace>Welcome</namespace>
Expand All @@ -35,7 +35,7 @@
<bugs>https://github.com/nextcloud/welcome/issues</bugs>
<screenshot>https://github.com/nextcloud/welcome/raw/main/img/screenshot1.jpg</screenshot>
<dependencies>
<nextcloud min-version="26" max-version="33"/>
<nextcloud min-version="29" max-version="34"/>
</dependencies>
<settings>
<admin>OCA\Welcome\Settings\Admin</admin>
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
}
],
"require": {
"php": "^8.0 || ^8.1 || ^8.2 || ^8.3 || ^8.4",
"php": "^8.0 || ^8.1 || ^8.2 || ^8.3 || ^8.4 || ^8.5",
"bamarni/composer-bin-plugin": "^1.8"
},
"require-dev": {
"nextcloud/ocp": "dev-stable26"
"nextcloud/ocp": "dev-stable29"
},
"scripts": {
"lint": "find . -name \\*.php -not -path './vendor*' -print0 | xargs -0 -n1 php -l",
Expand Down
110 changes: 82 additions & 28 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,25 @@
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\Services\IAppConfig;
use OCP\IConfig;
use OCP\Security\CSP\AddContentSecurityPolicyEvent;

class Application extends App implements IBootstrap {
public const APP_ID = 'welcome';
private IConfig $config;
private IAppConfig $appConfig;

public function __construct(array $urlParams = []) {
parent::__construct(self::APP_ID, $urlParams);

$container = $this->getContainer();
$this->config = $container->get(IConfig::class);
$this->appConfig = $container->get(IAppConfig::class);
}

public function register(IRegistrationContext $context): void {
$filePath = $this->config->getAppValue(self::APP_ID, 'filePath', '');
$filePath = $this->appConfig->getAppValueString('filePath', '');
if ($filePath) {
$context->registerDashboardWidget(WelcomeWidget::class);
$context->registerEventListener(AddContentSecurityPolicyEvent::class, CSPListener::class);
Expand Down
10 changes: 8 additions & 2 deletions lib/Controller/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
namespace OCA\Welcome\Controller;

use OC\User\NoUserException;
use OCA\Welcome\AppInfo\Application;
use OCA\Welcome\Service\FileService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataDisplayResponse;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Services\IAppConfig;
use OCP\Files\InvalidPathException;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
Expand All @@ -29,6 +29,7 @@ public function __construct(
string $appName,
IRequest $request,
private IConfig $config,
private IAppConfig $appConfig,
private FileService $fileService,
private IUserManager $userManager,
) {
Expand All @@ -43,7 +44,12 @@ public function __construct(
*/
public function setAdminConfig(array $values): DataResponse {
foreach ($values as $key => $value) {
$this->config->setAppValue(Application::APP_ID, $key, $value);
if ($key == 'filePath') {
// do not lazy store filePath as it is needed for dashboard registration
$this->appConfig->setAppValueString($key, $value);
} else {
$this->appConfig->setAppValueString($key, $value, lazy: true);
}
}
return new DataResponse(1);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Dashboard/WelcomeWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
namespace OCA\Welcome\Dashboard;

use OCA\Welcome\AppInfo\Application;
use OCP\AppFramework\Services\IAppConfig;
use OCP\Dashboard\IWidget;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\Util;
Expand All @@ -19,7 +19,7 @@ class WelcomeWidget implements IWidget {
public function __construct(
private IL10N $l10n,
private IURLGenerator $url,
private IConfig $config,
private IAppConfig $appConfig,
) {
}

Expand All @@ -34,7 +34,7 @@ public function getId(): string {
* @inheritDoc
*/
public function getTitle(): string {
$widgetTitle = $this->config->getAppValue(Application::APP_ID, 'widgetTitle', $this->l10n->t('Welcome'));
$widgetTitle = $this->appConfig->getAppValueString('widgetTitle', $this->l10n->t('Welcome'), lazy: true);
return $widgetTitle ?: $this->l10n->t('Welcome');
}

Expand Down
51 changes: 51 additions & 0 deletions lib/Migration/Version020000Date20260206141127.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Welcome\Migration;

use Closure;
use OCP\AppFramework\Services\IAppConfig;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
use Override;

class Version020000Date20260206141127 extends SimpleMigrationStep {
private static array $configKeys = [
'widgetTitle',
'userName',
'userId',
'supportUserName',
'supportUserId',
'supportText',
]; // do not lazy store filePath as it is needed for dashboard registration
public function __construct(
private IAppConfig $appConfig,
) {
}

/**
* @param IOutput $output
* @param Closure(): ISchemaWrapper $schemaClosure
* @param array $options
*/
#[Override]
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
$allSetKeys = $this->appConfig->getAppKeys();

foreach (self::$configKeys as $key) {
// skip if not already set
if (!in_array($key, $allSetKeys)) {
continue;
}
$value = $this->appConfig->getAppValueString($key);
$this->appConfig->setAppValueString($key, $value, lazy: true);
}
}
}
Loading