Skip to content

Commit

Permalink
fix config value types for some bools and ints we store
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <[email protected]>
  • Loading branch information
julien-nc committed Jan 20, 2025
1 parent fe1ff6b commit 775c59c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Known providers:
More details on how to set this up in the [admin docs](https://docs.nextcloud.com/server/latest/admin_manual/ai/index.html)
]]> </description>
<version>2.2.0</version>
<version>2.2.1</version>
<licence>agpl</licence>
<author>Julien Veyssier</author>
<namespace>Assistant</namespace>
Expand Down
49 changes: 49 additions & 0 deletions lib/Migration/Version020201Date20250120174409.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Assistant\Migration;

use Closure;
use OCA\Assistant\AppInfo\Application;
use OCP\IAppConfig;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version020201Date20250120174409 extends SimpleMigrationStep {

public function __construct(
private IAppConfig $appConfig,
) {
}

/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return void
*/
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
// some app values were types as INT
// https://github.com/nextcloud/assistant/issues/174
$keysToFix = [
'assistant_enabled',
'chat_last_n_messages',
'free_prompt_picker_enabled',
'speech_to_text_picker_enabled',
'text_to_image_picker_enabled',
];
foreach ($keysToFix as $key) {
if ($this->appConfig->hasKey(Application::APP_ID, $key)
&& $this->appConfig->getValueType(Application::APP_ID, $key) === IAppConfig::VALUE_INT) {
$value = $this->appConfig->getValueInt(Application::APP_ID, $key);
$this->appConfig->deleteKey(Application::APP_ID, $key);
$this->appConfig->setValueString(Application::APP_ID, $key, (string)$value);
}
}
}
}

0 comments on commit 775c59c

Please sign in to comment.