Only send the capability when the config is set

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2020-05-14 11:27:17 +02:00
Родитель 05881c5ab2
Коммит 923a49268e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7076EA9751AACDDA
3 изменённых файлов: 53 добавлений и 58 удалений

Просмотреть файл

@ -54,59 +54,57 @@ class Capabilities implements IPublicCapability {
return [];
}
$maxChatLength = 1000;
if (version_compare($this->serverConfig->getSystemValueString('version', '0.0.0'), '16.0.2', '>=')) {
$maxChatLength = ChatManager::MAX_CHAT_LENGTH;
}
$attachments = [
'allowed' => $user instanceof IUser,
$capabilities = [
'features' => [
'audio',
'video',
'chat-v2',
'conversation-v2',
'guest-signaling',
'empty-group-room',
'guest-display-names',
'multi-room-users',
'favorites',
'last-room-activity',
'no-ping',
'system-messages',
'mention-flag',
'in-call-flags',
'notification-levels',
'invite-groups-and-mails',
'locked-one-to-one-rooms',
'read-only-rooms',
'chat-read-marker',
'webinary-lobby',
'start-call-flag',
'chat-replies',
'circles-support',
'force-mute',
],
'config' => [
'attachments' => [
'allowed' => $user instanceof IUser,
],
'chat' => [
'max-length' => ChatManager::MAX_CHAT_LENGTH,
],
'conversations' => [],
],
];
if ($user instanceof IUser) {
$attachments['folder'] = $this->talkConfig->getAttachmentFolder($user->getUID());
$capabilities['config']['attachments']['folder'] = $this->talkConfig->getAttachmentFolder($user->getUID());
}
$conversations = [
'can-create' => $user instanceof IUser && !$this->talkConfig->isNotAllowedToCreateConversations($user),
];
$capabilities['config']['conversations']['can-create'] = $user instanceof IUser && !$this->talkConfig->isNotAllowedToCreateConversations($user);
if ($this->serverConfig->getAppValue('spreed', 'has_reference_id', 'no') === 'yes') {
$capabilities['features'][] = 'chat-reference-id';
}
return [
'spreed' => [
'features' => [
'audio',
'video',
'chat-v2',
'conversation-v2',
'guest-signaling',
'empty-group-room',
'guest-display-names',
'multi-room-users',
'favorites',
'last-room-activity',
'no-ping',
'system-messages',
'mention-flag',
'in-call-flags',
'notification-levels',
'invite-groups-and-mails',
'locked-one-to-one-rooms',
'read-only-rooms',
'chat-read-marker',
'webinary-lobby',
'start-call-flag',
'chat-replies',
'circles-support',
'force-mute',
'chat-reference-id',
],
'config' => [
'attachments' => $attachments,
'chat' => [
'max-length' => $maxChatLength,
],
'conversations' => $conversations,
],
],
'spreed' => $capabilities,
];
}
}

Просмотреть файл

@ -133,6 +133,7 @@ class RoomController extends AEnvironmentAwareController {
$this->config->getAppValue('spreed', 'signaling_mode', '') . '#' .
$this->config->getAppValue('spreed', 'allowed_groups', '') . '#' .
$this->config->getAppValue('spreed', 'start_conversations', '') . '#' .
$this->config->getAppValue('spreed', 'has_reference_id', '') . '#' .
$this->config->getAppValue('theming', 'cachebuster', '1')
)];
}

Просмотреть файл

@ -65,9 +65,9 @@ class CapabilitiesTest extends TestCase {
->method('isDisabledForUser');
$this->serverConfig->expects($this->once())
->method('getSystemValueString')
->with('version', '0.0.0')
->willReturn('16.0.1');
->method('getAppValue')
->with('spreed', 'has_reference_id', 'no')
->willReturn('no');
$this->assertInstanceOf(IPublicCapability::class, $capabilities);
$this->assertSame([
@ -97,14 +97,13 @@ class CapabilitiesTest extends TestCase {
'chat-replies',
'circles-support',
'force-mute',
'chat-reference-id',
],
'config' => [
'attachments' => [
'allowed' => false,
],
'chat' => [
'max-length' => 1000,
'max-length' => 32000,
],
'conversations' => [
'can-create' => false,
@ -157,9 +156,9 @@ class CapabilitiesTest extends TestCase {
->willReturn($isNotAllowed);
$this->serverConfig->expects($this->once())
->method('getSystemValueString')
->with('version', '0.0.0')
->willReturn('16.0.2');
->method('getAppValue')
->with('spreed', 'has_reference_id', 'no')
->willReturn('yes');
$this->assertInstanceOf(IPublicCapability::class, $capabilities);
$this->assertSame([
@ -224,9 +223,6 @@ class CapabilitiesTest extends TestCase {
->with($user)
->willReturn(true);
$this->serverConfig->expects($this->never())
->method('getSystemValueString');
$this->assertInstanceOf(IPublicCapability::class, $capabilities);
$this->assertSame([], $capabilities->getCapabilities());
}