Skip to content

Commit

Permalink
feat(capabilities): Expose which capabilities should be considered lo…
Browse files Browse the repository at this point in the history
…cal vs federated

Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed May 8, 2024
1 parent 5193115 commit bf240be
Show file tree
Hide file tree
Showing 20 changed files with 326 additions and 178 deletions.
36 changes: 18 additions & 18 deletions docs/capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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`
Expand Down
188 changes: 113 additions & 75 deletions lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,116 @@
* @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(
Expand Down Expand Up @@ -52,81 +162,8 @@ public function getCapabilities(): array {
}

$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,
Expand Down Expand Up @@ -162,6 +199,7 @@ public function getCapabilities(): array {
'session-ping-limit' => max(0, (int)$this->serverConfig->getAppValue('spreed', 'session-ping-limit', '200')),
],
],
'config-local' => self::LOCAL_CONFIGS,
'version' => $this->appManager->getAppVersion('spreed'),
];

Expand Down
2 changes: 2 additions & 0 deletions lib/ResponseDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@
*
* @psalm-type TalkCapabilities = array{
* features: string[],
* features-local: string[],
* config: array{
* attachments: array{
* allowed: bool,
Expand Down Expand Up @@ -334,6 +335,7 @@
* hello-v2-token-key?: string,
* },
* },
* config-local: array<string, string[]>,
* version: string,
* }
*/
Expand Down
17 changes: 17 additions & 0 deletions openapi-administration.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@
"type": "object",
"required": [
"features",
"features-local",
"config",
"config-local",
"version"
],
"properties": {
Expand All @@ -101,6 +103,12 @@
"type": "string"
}
},
"features-local": {
"type": "array",
"items": {
"type": "string"
}
},
"config": {
"type": "object",
"required": [
Expand Down Expand Up @@ -270,6 +278,15 @@
}
}
},
"config-local": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
},
"version": {
"type": "string"
}
Expand Down
17 changes: 17 additions & 0 deletions openapi-backend-recording.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"type": "object",
"required": [
"features",
"features-local",
"config",
"config-local",
"version"
],
"properties": {
Expand All @@ -34,6 +36,12 @@
"type": "string"
}
},
"features-local": {
"type": "array",
"items": {
"type": "string"
}
},
"config": {
"type": "object",
"required": [
Expand Down Expand Up @@ -203,6 +211,15 @@
}
}
},
"config-local": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
},
"version": {
"type": "string"
}
Expand Down
Loading

0 comments on commit bf240be

Please sign in to comment.