summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-08-23 11:16:20 +0200
committerJoas Schilling <coding@schilljs.com>2023-09-26 16:32:02 +0200
commit39d185fe148665a7f89ec46384805ca3f05108db (patch)
tree6062b521965f7522c9bb54cb729269b248963007
parent49297fa6587c29614a5bd90a57825ede9371c7de (diff)
fix(capabilities): Fix capability issues with OpenAI integration providing too many translations
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--docs/capabilities.md3
-rw-r--r--lib/Capabilities.php3
-rw-r--r--tests/php/CapabilitiesTest.php18
3 files changed, 8 insertions, 16 deletions
diff --git a/docs/capabilities.md b/docs/capabilities.md
index 07f5868eb..9bcf87519 100644
--- a/docs/capabilities.md
+++ b/docs/capabilities.md
@@ -115,7 +115,7 @@
## 17
* `avatar` - Avatar of conversation
-* `config => chat => translations` - List of translations tuples, JSON encoded sample `{"from":"de","fromLabel":"German","to":"en","toLabel":"English"}`. Those tuples should be provided as options when translating chat messages.
+* ~~`config => chat => translations` - List of translations tuples, JSON encoded sample `{"from":"de","fromLabel":"German","to":"en","toLabel":"English"}`. Those tuples should be provided as options when translating chat messages.~~ Due to some providers the list was too big causing issues in various clients. So the capability was replaced by boolean `config => chat => has-translation-providers` in Talk 18.
* `config => call => predefined-backgrounds` - List of predefined virtual backgrounds. The files are in Talks img/ folder, accessible via the normal image path methods. The list is cached for 5 minutes.
* `config => call => can-upload-background` - Boolean flag whether the user can upload a custom virtual background (requires an account and non-zero quota). Uploads should be done to Talk/Backgrounds/ (respecting the user's attachment directory setting).
* `config => call => supported-reactions` - A list of emojis supported as call reactions. If the list is absent or empty, clients should not show the emoji reaction option in calls.
@@ -129,3 +129,4 @@
## 18
* `session-state` - Sessions can mark themselves as inactive, so the participant receives notifications again
+* `config => chat => has-translation-providers` - When true, translation tuples can be loaded from the [OCS Translation API](https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-translation-api.html#get-available-translation-options).
diff --git a/lib/Capabilities.php b/lib/Capabilities.php
index ec470790b..d852e3086 100644
--- a/lib/Capabilities.php
+++ b/lib/Capabilities.php
@@ -137,8 +137,7 @@ class Capabilities implements IPublicCapability {
'chat' => [
'max-length' => ChatManager::MAX_CHAT_LENGTH,
'read-privacy' => Participant::PRIVACY_PUBLIC,
- // Transform the JsonSerializable language tuples to arrays
- 'translations' => json_decode(json_encode($this->translationManager->getLanguages()), true),
+ 'has-translation-providers' => $this->translationManager->hasProviders(),
'typing-privacy' => Participant::PRIVACY_PUBLIC,
],
'conversations' => [
diff --git a/tests/php/CapabilitiesTest.php b/tests/php/CapabilitiesTest.php
index ad57bae8d..f73af9c78 100644
--- a/tests/php/CapabilitiesTest.php
+++ b/tests/php/CapabilitiesTest.php
@@ -38,7 +38,6 @@ use OCP\IConfig;
use OCP\IUser;
use OCP\IUserSession;
use OCP\Translation\ITranslationManager;
-use OCP\Translation\LanguageTuple;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
@@ -206,7 +205,7 @@ class CapabilitiesTest extends TestCase {
'chat' => [
'max-length' => 32000,
'read-privacy' => 0,
- 'translations' => [],
+ 'has-translation-providers' => false,
'typing-privacy' => 0,
],
'conversations' => [
@@ -330,7 +329,7 @@ class CapabilitiesTest extends TestCase {
'chat' => [
'max-length' => 32000,
'read-privacy' => $readPrivacy,
- 'translations' => [],
+ 'has-translation-providers' => false,
'typing-privacy' => 0,
],
'conversations' => [
@@ -447,17 +446,10 @@ class CapabilitiesTest extends TestCase {
$this->cacheFactory,
);
- $translations = [];
- $translations[] = new LanguageTuple('de', 'de Label', 'en', 'en Label');
- $translations[] = new LanguageTuple('de_DE', 'de_DE Label', 'en', 'en Label');
-
- $this->translationManager->method('getLanguages')
- ->willReturn($translations);
+ $this->translationManager->method('hasProviders')
+ ->willReturn(true);
$data = json_decode(json_encode($capabilities->getCapabilities(), JSON_THROW_ON_ERROR), true);
- $this->assertEquals([
- ['from' => 'de', 'fromLabel' => 'de Label', 'to' => 'en', 'toLabel' => 'en Label'],
- ['from' => 'de_DE', 'fromLabel' => 'de_DE Label', 'to' => 'en', 'toLabel' => 'en Label'],
- ], $data['spreed']['config']['chat']['translations']);
+ $this->assertEquals(true, $data['spreed']['config']['chat']['has-translation-providers']);
}
}