Skip to content

Commit

Permalink
fix(capabilities): Mark federation and signaling capabilities as local
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed May 10, 2024
1 parent bf240be commit fb8a73c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
12 changes: 6 additions & 6 deletions docs/capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
* `silent-call` - Allow to start calls without sending notification
* `talk-polls` - Polls feature is available to use in the chat
* `config => call => enabled` - Whether calling is enabled on the instance or not
* `config => signaling => session-ping-limit` - Number of sessions the HPB is allowed to ping in the same request
* `config => signaling => hello-v2-token-key` - Public key to use when verifying JWT auth tokens for hello V2.
* `config => signaling => session-ping-limit` (local) - Number of sessions the HPB is allowed to ping in the same request
* `config => signaling => hello-v2-token-key` (local) - Public key to use when verifying JWT auth tokens for hello V2.

## 16
* `breakout-rooms-v1` - Whether breakout-rooms API v1 is available
Expand Down Expand Up @@ -145,10 +145,10 @@
* `silent-send-state` - Whether messages contain a flag that they were sent silently
* `chat-read-last` - Whether chat can be marked read without giving a message ID (will fall back to the conversations last message ID)
* `federation-v1` - Whether basic chatting is possible with federation
* `config => federation => enabled` - Boolean, whether federation is enabled on instance
* `config => federation => incoming-enabled` - Boolean, whether users are allowed to be invited into federated conversations on other servers
* `config => federation => outgoing-enabled` - Boolean, whether users are allowed to invited federated users of other servers into conversations
* `config => federation => only-trusted-servers` - Boolean, whether federation invites are limited to trusted servers
* `config => federation => enabled` (local) - Boolean, whether federation is enabled on instance
* `config => federation => incoming-enabled` (local) - Boolean, whether users are allowed to be invited into federated conversations on other servers
* `config => federation => outgoing-enabled` (local) - Boolean, whether users are allowed to invited federated users of other servers into conversations
* `config => federation => only-trusted-servers` (local) - Boolean, whether federation invites are limited to trusted servers

## 20
* `ban-v1` - Whether the API to ban attendees is available
18 changes: 15 additions & 3 deletions lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,19 @@ class Capabilities implements IPublicCapability {
'conversations' => [
'can-create',
],
'federation' => [
'enabled',
'incoming-enabled',
'outgoing-enabled',
'only-trusted-servers',
],
'previews' => [
'max-gif-size',
],
'signaling' => [
'session-ping-limit',
'hello-v2-token-key',
],
];

protected ICache $talkCache;
Expand Down Expand Up @@ -167,15 +177,19 @@ public function getCapabilities(): array {
'config' => [
'attachments' => [
'allowed' => $user instanceof IUser,
// 'folder' => string,
],
'call' => [
'enabled' => ((int) $this->serverConfig->getAppValue('spreed', 'start_calls', (string) Room::START_CALL_EVERYONE)) !== Room::START_CALL_NOONE,
'breakout-rooms' => $this->talkConfig->isBreakoutRoomsEnabled(),
'recording' => $this->talkConfig->isRecordingEnabled(),
'recording-consent' => $this->talkConfig->recordingConsentRequired(),
'supported-reactions' => ['❀️', 'πŸŽ‰', 'πŸ‘', 'πŸ‘', 'πŸ‘Ž', 'πŸ˜‚', '🀩', 'πŸ€”', '😲', 'πŸ˜₯'],
// 'predefined-backgrounds' => list<string>,
'can-upload-background' => false,
'sip-enabled' => $this->talkConfig->isSIPConfigured(),
'sip-dialout-enabled' => $this->talkConfig->isSIPDialOutEnabled(),
'can-enable-sip' => false,
],
'chat' => [
'max-length' => ChatManager::MAX_CHAT_LENGTH,
Expand All @@ -197,6 +211,7 @@ public function getCapabilities(): array {
],
'signaling' => [
'session-ping-limit' => max(0, (int)$this->serverConfig->getAppValue('spreed', 'session-ping-limit', '200')),
// 'hello-v2-token-key' => string,
],
],
'config-local' => self::LOCAL_CONFIGS,
Expand Down Expand Up @@ -277,9 +292,6 @@ public function getCapabilities(): array {
}
$capabilities['config']['call']['can-upload-background'] = $quota === 'none' || $quota > 0;
$capabilities['config']['call']['can-enable-sip'] = $this->talkConfig->canUserEnableSIP($user);
} else {
$capabilities['config']['call']['can-upload-background'] = false;
$capabilities['config']['call']['can-enable-sip'] = false;
}

return [
Expand Down
8 changes: 4 additions & 4 deletions tests/php/CapabilitiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ public function testGetCapabilitiesGuest(): void {
'recording' => false,
'recording-consent' => 0,
'supported-reactions' => ['❀️', 'πŸŽ‰', 'πŸ‘', 'πŸ‘', 'πŸ‘Ž', 'πŸ˜‚', '🀩', 'πŸ€”', '😲', 'πŸ˜₯'],
'can-upload-background' => false,
'sip-enabled' => false,
'sip-dialout-enabled' => false,
'can-enable-sip' => false,
'predefined-backgrounds' => [
'1_office.jpg',
'2_home.jpg',
Expand All @@ -127,8 +129,6 @@ public function testGetCapabilitiesGuest(): void {
'7_library.jpg',
'8_space_station.jpg',
],
'can-upload-background' => false,
'can-enable-sip' => false,
],
'chat' => [
'max-length' => 32000,
Expand Down Expand Up @@ -249,8 +249,10 @@ public function testGetCapabilitiesUserAllowed(bool $isNotAllowed, bool $canCrea
'recording' => false,
'recording-consent' => 0,
'supported-reactions' => ['❀️', 'πŸŽ‰', 'πŸ‘', 'πŸ‘', 'πŸ‘Ž', 'πŸ˜‚', '🀩', 'πŸ€”', '😲', 'πŸ˜₯'],
'can-upload-background' => $canUpload,
'sip-enabled' => false,
'sip-dialout-enabled' => false,
'can-enable-sip' => false,
'predefined-backgrounds' => [
'1_office.jpg',
'2_home.jpg',
Expand All @@ -261,8 +263,6 @@ public function testGetCapabilitiesUserAllowed(bool $isNotAllowed, bool $canCrea
'7_library.jpg',
'8_space_station.jpg',
],
'can-upload-background' => $canUpload,
'can-enable-sip' => false,
],
'chat' => [
'max-length' => 32000,
Expand Down

0 comments on commit fb8a73c

Please sign in to comment.