summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2024-05-08 12:57:52 +0200
committerJoas Schilling <coding@schilljs.com>2024-05-08 12:57:52 +0200
commitbf240be8cfd5a2f1ce5035e9266b0315ede3f9b5 (patch)
tree96649100e0ac0cb880bd7894066723f57c48ca37
parent519311588fe43f276f4a4b090596eb168e42e7ba (diff)
feat(capabilities): Expose which capabilities should be considered local vs federated
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--docs/capabilities.md36
-rw-r--r--lib/Capabilities.php188
-rw-r--r--lib/ResponseDefinitions.php2
-rw-r--r--openapi-administration.json17
-rw-r--r--openapi-backend-recording.json17
-rw-r--r--openapi-backend-signaling.json17
-rw-r--r--openapi-backend-sipbridge.json17
-rw-r--r--openapi-bots.json17
-rw-r--r--openapi-federation.json17
-rw-r--r--openapi-full.json17
-rw-r--r--openapi.json17
-rw-r--r--src/types/openapi/openapi-administration.ts4
-rw-r--r--src/types/openapi/openapi-backend-recording.ts4
-rw-r--r--src/types/openapi/openapi-backend-signaling.ts4
-rw-r--r--src/types/openapi/openapi-backend-sipbridge.ts4
-rw-r--r--src/types/openapi/openapi-bots.ts4
-rw-r--r--src/types/openapi/openapi-federation.ts4
-rw-r--r--src/types/openapi/openapi-full.ts4
-rw-r--r--src/types/openapi/openapi.ts4
-rw-r--r--tests/php/CapabilitiesTest.php110
20 files changed, 326 insertions, 178 deletions
diff --git a/docs/capabilities.md b/docs/capabilities.md
index 5aa9d9e17..454481748 100644
--- a/docs/capabilities.md
+++ b/docs/capabilities.md
@@ -15,7 +15,7 @@
* `chat-v2` - Chat messages are now [Rich Object Strings](https://github.com/nextcloud/server/issues/1706) and pagination is available, the previous `chat` is not available anymore.
## 4.0
-* `favorites` - Conversations can be marked as favorites which will pin them to the top of the conversation list.
+* `favorites` (local) - Conversations can be marked as favorites which will pin them to the top of the conversation list.
* `last-room-activity` - Conversations have the `lastActivity` attribute and should be sorted by that instead of the last ping of the user.
* `no-ping` - The ping endpoint has been removed. Ping is updated with a call to fetch the signaling or chat messages instead.
* `system-messages` - Chat messages have a `systemMessage` attribute and can be generated by the system
@@ -44,9 +44,9 @@
## 9.0
-* `config => attachments => allowed` - Whether the user can upload files into a chat
-* `config => attachments => folder` - User defined folder where items should be uploaded to
-* `config => conversations => can-create` - Whether the user can create public and group conversations, if not only one-to-one conversations are allowed
+* `config => attachments => allowed` (local) - Whether the user can upload files into a chat
+* `config => attachments => folder` (local) - User defined folder where items should be uploaded to
+* `config => conversations => can-create` (local) - Whether the user can create public and group conversations, if not only one-to-one conversations are allowed
* `force-mute` - "forceMute" signaling messages can be sent to mute other participants.
* `conversation-v2` - ~~The conversations API v2 is less load heavy and should be used by clients when available. Check the difference in the [Conversation API documentation](conversation.md).~~ Replaced by API v4 when `conversation-v4` is set.
* `chat-reference-id` - an optional referenceId can be sent with a chat message to be able to identify it in parallel get requests to earlier fade out a temporary message
@@ -56,19 +56,19 @@
* `sip-support` - Whether SIP can be configured and enabled by moderators. The conversations API will come with some new values `sipEnabled` which signals whether this conversation has SIP configured as well as `canEnableSIP` to see if a user can enable it. When it is enabled `attendeePin` will contain the unique dial-in code for this user.
## 11.0
-* `chat-read-status` - On conversation API v3 and the chat API the last common read message is exposed which can be used to update the "read status" flag of own chat messages. The info should be shown only when the user also shares their read status. The user's value can be found in `config => chat => read-privacy`.
-* `listable-rooms` - Conversations can searched for even when not joined. A "listable" attribute set on rooms defines the scope of who can find it.
-* `phonebook-search` - Is present when the server has the endpoint to search for phone numbers to find matches in the accounts list
+* `chat-read-status` (local) - On conversation API v3 and the chat API the last common read message is exposed which can be used to update the "read status" flag of own chat messages. The info should be shown only when the user also shares their read status. The user's value can be found in `config => chat => read-privacy`.
+* `listable-rooms` (local) - Conversations can searched for even when not joined. A "listable" attribute set on rooms defines the scope of who can find it.
+* `phonebook-search` (local) - Is present when the server has the endpoint to search for phone numbers to find matches in the accounts list
* `raise-hand` - Participants can raise or lower hand, the state change is sent through signaling messages.
* `room-description` - A description can be get and set for conversations.
-* `config => chat => read-privacy` - See `chat-read-status`
-* `config => previews => max-gif-size` - Maximum size in bytes below which a GIF can be embedded directly in the page at render time. Bigger files will be rendered statically using the preview endpoint instead. Can be set with `occ config:app:set spreed max-gif-size --value=X` where X is the new value in bytes. Defaults to 3 MB.
+* `config => chat => read-privacy` (local) - See `chat-read-status`
+* `config => previews => max-gif-size` (local) - Maximum size in bytes below which a GIF can be embedded directly in the page at render time. Bigger files will be rendered statically using the preview endpoint instead. Can be set with `occ config:app:set spreed max-gif-size --value=X` where X is the new value in bytes. Defaults to 3 MB.
## 11.1
* `delete-messages` - Allows to delete chat messages up to 6 hours for your own messages or when being a moderator. On deleting the message text will be replaced and a follow up system message will make sure clients and users update it in their cache and storage.
* `rich-object-sharing` - Rich objects can be shared to chats. See [OCP\RichObjectStrings\Definitions](https://github.com/nextcloud/server/blob/master/lib/public/RichObjectStrings/Definitions.php) for more details on supported rich objects and required data.
* `conversation-call-flags` - Whether the room api provides the `callFlag` to tell apart video and audio calls
-* `temp-user-avatar-api` - Whether a temporary api is available to allow users to upload an avatar to their profile via an OCS endpoint.
+* `temp-user-avatar-api` (local) - Whether a temporary api is available to allow users to upload an avatar to their profile via an OCS endpoint.
## 12.0
* `conversation-v4` - Whether conversations API v4 is available. This also means that v1, v2 and v3 are **not** available anymore. The changes on API v4 allow a user to have multiple sessions in the same conversation on different devices which is incompatible with the data structure that was used by the previous APIs.
@@ -92,7 +92,7 @@
* `rich-object-delete` - When the API allows to delete chat messages which are file or rich object shares
## 15
-* `unified-search` - When the extended attributes of unified search results are there
+* `unified-search` (local) - When the extended attributes of unified search results are there
* `chat-permission` - When permission 128 is required to post chat messages, reaction or share items to the conversation
* `silent-send` - Whether the chat API allows to send chat messages without triggering notifications
* `message-expiration` - Message expiration time for a conversation
@@ -114,26 +114,26 @@
* `chat-keep-notifications` - Whether messages can be retrieved without marking notifications as read
## 17
-* `avatar` - Avatar of conversation
+* `avatar` (local) - 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.~~ 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 => predefined-backgrounds` (local) - 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` (local) - 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.
-* `config => chat => typing-privacy` - User defined numeric value to enable 1 or disable 0 the typing indicator to other users
+* `config => chat => typing-privacy` (local) - User defined numeric value to enable 1 or disable 0 the typing indicator to other users
* `typing-privacy` - Support toggle typing privacy
## 17.1
-* `remind-me-later` - Support for "Remind me later" for chat messages exists
+* `remind-me-later` (local) - Support for "Remind me later" for chat messages exists
* `bots-v1` - Support of the first version for Bots and Webhooks is available
* `markdown-messages` - Chat messages support markdown and are rendered automatically
## 18
* `media-caption` - Whether media caption can be added to shared files
* `session-state` - Sessions can mark themselves as inactive, so the participant receives notifications again
-* `note-to-self` - Support for "Note-to-self" conversation exists
+* `note-to-self` (local) - Support for "Note-to-self" conversation exists
* `recording-consent` - Whether admins and moderators can require recording consent before joining a call
* `sip-support-dialout` - Whether admins can enable SIP dial-out
-* `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).
+* `config => chat => has-translation-providers` (local) - 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).
* `config => call => recording-consent` - Whether users need to consent into call recording before joining a call (see [constants list](constants.md#recording-consent-required))
* `config => call => sip-enabled` - Whether SIP is configured on the server allowing for SIP dial-in
* `config => call => sip-dialout-enabled` - Whether SIP dial-out is configured on the server, additionally requires `config => call => sip-enabled`
diff --git a/lib/Capabilities.php b/lib/Capabilities.php
index 8d3c5017e..58d44d58a 100644
--- a/lib/Capabilities.php
+++ b/lib/Capabilities.php
@@ -25,6 +25,116 @@ use OCP\Util;
* @psalm-import-type TalkCapabilities from ResponseDefinitions
*/
class Capabilities implements IPublicCapability {
+ public const FEATURES = [
+ 'audio',
+ 'video',
+ 'chat-v2',
+ 'conversation-v4',
+ 'guest-signaling',
+ 'empty-group-room',
+ 'guest-display-names',
+ 'multi-room-users',
+ 'favorites',
+ 'last-room-activity',
+ 'no-ping',
+ 'system-messages',
+ 'delete-messages',
+ 'mention-flag',
+ 'in-call-flags',
+ 'conversation-call-flags',
+ 'notification-levels',
+ 'invite-groups-and-mails',
+ 'locked-one-to-one-rooms',
+ 'read-only-rooms',
+ 'listable-rooms',
+ 'chat-read-marker',
+ 'chat-unread',
+ 'webinary-lobby',
+ 'start-call-flag',
+ 'chat-replies',
+ 'circles-support',
+ 'force-mute',
+ 'sip-support',
+ 'sip-support-nopin',
+ 'chat-read-status',
+ 'phonebook-search',
+ 'raise-hand',
+ 'room-description',
+ 'rich-object-sharing',
+ 'temp-user-avatar-api',
+ 'geo-location-sharing',
+ 'voice-message-sharing',
+ 'signaling-v3',
+ 'publishing-permissions',
+ 'clear-history',
+ 'direct-mention-flag',
+ 'notification-calls',
+ 'conversation-permissions',
+ 'rich-object-list-media',
+ 'rich-object-delete',
+ 'unified-search',
+ 'chat-permission',
+ 'silent-send',
+ 'silent-call',
+ 'send-call-notification',
+ 'talk-polls',
+ 'breakout-rooms-v1',
+ 'recording-v1',
+ 'avatar',
+ 'chat-get-context',
+ 'single-conversation-status',
+ 'chat-keep-notifications',
+ 'typing-privacy',
+ 'remind-me-later',
+ 'bots-v1',
+ 'markdown-messages',
+ 'media-caption',
+ 'session-state',
+ 'note-to-self',
+ 'recording-consent',
+ 'sip-support-dialout',
+ 'delete-messages-unlimited',
+ 'edit-messages',
+ 'silent-send-state',
+ 'chat-read-last',
+ 'federation-v1',
+ 'ban-v1',
+ ];
+
+ public const LOCAL_FEATURES = [
+ 'favorites',
+ 'chat-read-status',
+ 'listable-rooms',
+ 'phonebook-search',
+ 'temp-user-avatar-api',
+ 'unified-search',
+ 'avatar',
+ 'remind-me-later',
+ 'note-to-self',
+ ];
+
+ public const LOCAL_CONFIGS = [
+ 'attachments' => [
+ 'allowed',
+ 'folder',
+ ],
+ 'call' => [
+ 'predefined-backgrounds',
+ 'can-upload-background',
+ ],
+ 'chat' => [
+ 'read-privacy',
+ 'has-translation-providers',
+ 'typing-privacy',
+ ],
+ 'conversations' => [
+ 'can-create',
+ ],
+ 'previews' => [
+ 'max-gif-size',
+ ],
+ ];
+
protected ICache $talkCache;
public function __construct(
@@ -52,81 +162,8 @@ class Capabilities implements IPublicCapability {
}
$capabilities = [
- 'features' => [
- 'audio',
- 'video',
- 'chat-v2',
- 'conversation-v4',
- 'guest-signaling',
- 'empty-group-room',
- 'guest-display-names',
- 'multi-room-users',
- 'favorites',
- 'last-room-activity',
- 'no-ping',
- 'system-messages',
- 'delete-messages',
- 'mention-flag',
- 'in-call-flags',
- 'conversation-call-flags',
- 'notification-levels',
- 'invite-groups-and-mails',
- 'locked-one-to-one-rooms',
- 'read-only-rooms',
- 'listable-rooms',
- 'chat-read-marker',
- 'chat-unread',
- 'webinary-lobby',
- 'start-call-flag',
- 'chat-replies',
- 'circles-support',
- 'force-mute',
- 'sip-support',
- 'sip-support-nopin',
- 'chat-read-status',
- 'phonebook-search',
- 'raise-hand',
- 'room-description',
- 'rich-object-sharing',
- 'temp-user-avatar-api',
- 'geo-location-sharing',
- 'voice-message-sharing',
- 'signaling-v3',
- 'publishing-permissions',
- 'clear-history',
- 'direct-mention-flag',
- 'notification-calls',
- 'conversation-permissions',
- 'rich-object-list-media',
- 'rich-object-delete',
- 'unified-search',
- 'chat-permission',
- 'silent-send',
- 'silent-call',
- 'send-call-notification',
- 'talk-polls',
- 'breakout-rooms-v1',
- 'recording-v1',
- 'avatar',
- 'chat-get-context',
- 'single-conversation-status',
- 'chat-keep-notifications',
- 'typing-privacy',
- 'remind-me-later',
- 'bots-v1',
- 'markdown-messages',
- 'media-caption',
- 'session-state',
- 'note-to-self',
- 'recording-consent',
- 'sip-support-dialout',
- 'delete-messages-unlimited',
- 'edit-messages',
- 'silent-send-state',
- 'chat-read-last',
- 'federation-v1',
- 'ban-v1',
- ],
+ 'features' => self::FEATURES,
+ 'features-local' => self::LOCAL_FEATURES,
'config' => [
'attachments' => [
'allowed' => $user instanceof IUser,
@@ -162,6 +199,7 @@ class Capabilities implements IPublicCapability {
'session-ping-limit' => max(0, (int)$this->serverConfig->getAppValue('spreed', 'session-ping-limit', '200')),
],
],
+ 'config-local' => self::LOCAL_CONFIGS,
'version' => $this->appManager->getAppVersion('spreed'),
];
diff --git a/lib/ResponseDefinitions.php b/lib/ResponseDefinitions.php
index e2bd54ed8..0470af3e2 100644
--- a/lib/ResponseDefinitions.php
+++ b/lib/ResponseDefinitions.php
@@ -294,6 +294,7 @@ namespace OCA\Talk;
*
* @psalm-type TalkCapabilities = array{
* features: string[],
+ * features-local: string[],
* config: array{
* attachments: array{
* allowed: bool,
@@ -334,6 +335,7 @@ namespace OCA\Talk;
* hello-v2-token-key?: string,
* },
* },
+ * config-local: array<string, string[]>,
* version: string,
* }
*/
diff --git a/openapi-administration.json b/openapi-administration.json
index 0b27831ee..5278dd8a1 100644
--- a/openapi-administration.json
+++ b/openapi-administration.json
@@ -91,7 +91,9 @@
"type": "object",
"required": [
"features",
+ "features-local",
"config",
+ "config-local",
"version"
],
"properties": {
@@ -101,6 +103,12 @@
"type": "string"
}
},
+ "features-local": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
"config": {
"type": "object",
"required": [
@@ -270,6 +278,15 @@
}
}
},
+ "config-local": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
"version": {
"type": "string"
}
diff --git a/openapi-backend-recording.json b/openapi-backend-recording.json
index b91647546..9555d8bf6 100644
--- a/openapi-backend-recording.json
+++ b/openapi-backend-recording.json
@@ -24,7 +24,9 @@
"type": "object",
"required": [
"features",
+ "features-local",
"config",
+ "config-local",
"version"
],
"properties": {
@@ -34,6 +36,12 @@
"type": "string"
}
},
+ "features-local": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
"config": {
"type": "object",
"required": [
@@ -203,6 +211,15 @@
}
}
},
+ "config-local": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
"version": {
"type": "string"
}
diff --git a/openapi-backend-signaling.json b/openapi-backend-signaling.json
index bdf2bb70e..26e2c1101 100644
--- a/openapi-backend-signaling.json
+++ b/openapi-backend-signaling.json
@@ -24,7 +24,9 @@
"type": "object",
"required": [
"features",
+ "features-local",
"config",
+ "config-local",
"version"
],
"properties": {
@@ -34,6 +36,12 @@
"type": "string"
}
},
+ "features-local": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
"config": {
"type": "object",
"required": [
@@ -203,6 +211,15 @@
}
}
},
+ "config-local": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
"version": {
"type": "string"
}
diff --git a/openapi-backend-sipbridge.json b/openapi-backend-sipbridge.json
index 3fce16be8..5d0c6b6c4 100644
--- a/openapi-backend-sipbridge.json
+++ b/openapi-backend-sipbridge.json
@@ -67,7 +67,9 @@
"type": "object",
"required": [
"features",
+ "features-local",
"config",
+ "config-local",
"version"
],
"properties": {
@@ -77