@ -149,6 +149,7 @@ class Capabilities implements IPublicCapability {
],
],
'call' => [
'call' => [
'predefined-backgrounds' ,
'predefined-backgrounds' ,
'predefined-backgrounds-v2' ,
'can-upload-background' ,
'can-upload-background' ,
'start-without-media' ,
'start-without-media' ,
'blur-virtual-background' ,
'blur-virtual-background' ,
@ -222,6 +223,7 @@ class Capabilities implements IPublicCapability {
'recording-consent' => $this -> talkConfig -> recordingConsentRequired (),
'recording-consent' => $this -> talkConfig -> recordingConsentRequired (),
'supported-reactions' => [ '❤️' , '🎉' , '👏' , '👋' , '👍' , '👎' , '🔥' , '😂' , '🤩' , '🤔' , '😲' , '😥' ],
'supported-reactions' => [ '❤️' , '🎉' , '👏' , '👋' , '👍' , '👎' , '🔥' , '😂' , '🤩' , '🤔' , '😲' , '😥' ],
// 'predefined-backgrounds' => list<string>,
// 'predefined-backgrounds' => list<string>,
// 'predefined-backgrounds-v2' => list<string>,
'can-upload-background' => false ,
'can-upload-background' => false ,
'sip-enabled' => $this -> talkConfig -> isSIPConfigured (),
'sip-enabled' => $this -> talkConfig -> isSIPConfigured (),
'sip-dialout-enabled' => $this -> talkConfig -> isSIPDialOutEnabled (),
'sip-dialout-enabled' => $this -> talkConfig -> isSIPDialOutEnabled (),
@ -292,9 +294,63 @@ class Capabilities implements IPublicCapability {
$capabilities [ 'config' ][ 'signaling' ][ 'hello-v2-token-key' ] = $pubKey ;
$capabilities [ 'config' ][ 'signaling' ][ 'hello-v2-token-key' ] = $pubKey ;
}
}
$includeBrandedBackgrounds = $user instanceof IUser || $this -> appConfig -> getAppValueBool ( 'backgrounds_branded_for_guests' );
$includeDefaultBackgrounds = ! $user instanceof IUser || $this -> appConfig -> getAppValueBool ( 'backgrounds_default_for_users' , true );
$predefinedBackgrounds = [];
$defaultBackgrounds = $this -> getBackgroundsFromDirectory ( __DIR__ . '/../img/backgrounds' , '_default' );
if ( $includeBrandedBackgrounds ) {
$predefinedBackgrounds = $this -> getBackgroundsFromDirectory ( \OC :: $SERVERROOT . '/themes/talk-backgrounds' , '_branded' );
$predefinedBackgrounds = array_map ( static fn ( $fileName ) => '/themes/talk-backgrounds/' . $fileName , $predefinedBackgrounds );
}
if ( $includeDefaultBackgrounds ) {
$spreedWebPath = $this -> appManager -> getAppWebPath ( 'spreed' );
$prefixedDefaultBackgrounds = array_map ( static fn ( $fileName ) => $spreedWebPath . '/img/backgrounds/' . $fileName , $defaultBackgrounds );
$predefinedBackgrounds = array_merge ( $predefinedBackgrounds , $prefixedDefaultBackgrounds );
}
$capabilities [ 'config' ][ 'call' ][ 'predefined-backgrounds' ] = $defaultBackgrounds ;
$capabilities [ 'config' ][ 'call' ][ 'predefined-backgrounds-v2' ] = array_values ( $predefinedBackgrounds );
if ( $user instanceof IUser ) {
$userAllowedToUpload = $this -> appConfig -> getAppValueBool ( 'backgrounds_upload_users' , true );
if ( $userAllowedToUpload ) {
$quota = $user -> getQuota ();
if ( $quota !== 'none' ) {
$quota = Util :: computerFileSize ( $quota );
}
$capabilities [ 'config' ][ 'call' ][ 'can-upload-background' ] = $quota === 'none' || $quota > 0 ;
}
$capabilities [ 'config' ][ 'call' ][ 'can-enable-sip' ] = $this -> talkConfig -> canUserEnableSIP ( $user );
}
$supportedTaskTypes = $this -> taskProcessingManager -> getAvailableTaskTypes ();
if ( isset ( $supportedTaskTypes [ TextToTextSummary :: ID ])) {
$capabilities [ 'features' ][] = 'chat-summary-api' ;
}
if ( isset ( $supportedTaskTypes [ TextToTextTranslate :: ID ])) {
$capabilities [ 'config' ][ 'chat' ][ 'has-translation-task-providers' ] = true ;
}
if ( $this -> talkConfig -> getSignalingMode () === Config :: SIGNALING_EXTERNAL ) {
$capabilities [ 'features' ][] = 'call-end-to-end-encryption' ;
}
return [
'spreed' => $capabilities ,
];
}
/**
* @ return list < string >
*/
protected function getBackgroundsFromDirectory ( string $directory , string $cacheSuffix ) : array {
$cacheKey = 'predefined_backgrounds' . $cacheSuffix ;
/** @var ?list<string> $predefinedBackgrounds */
/** @var ?list<string> $predefinedBackgrounds */
$predefinedBackgrounds = null ;
$predefinedBackgrounds = null ;
$cachedPredefinedBackgrounds = $this -> talkCache -> get ( 'predefined_backgrounds' );
$cachedPredefinedBackgrounds = $this -> talkCache -> get ( $cacheKey );
if ( $cachedPredefinedBackgrounds !== null ) {
if ( $cachedPredefinedBackgrounds !== null ) {
// Try using cached value
// Try using cached value
/** @var list<string>|null $predefinedBackgrounds */
/** @var list<string>|null $predefinedBackgrounds */
@ -302,11 +358,8 @@ class Capabilities implements IPublicCapability {
}
}
if ( ! is_array ( $predefinedBackgrounds )) {
if ( ! is_array ( $predefinedBackgrounds )) {
// Cache was empty or invalid, regenerate
/** @var list<string> $predefinedBackgrounds */
$predefinedBackgrounds = [];
if ( file_exists ( __DIR__ . '/../img/backgrounds' )) {
$directoryIterator = new \DirectoryIterator ( __DIR__ . '/../img/backgrounds' );
if ( file_exists ( $directory ) && is_dir ( $directory )) {
$directoryIterator = new \DirectoryIterator ( $directory );
foreach ( $directoryIterator as $file ) {
foreach ( $directoryIterator as $file ) {
if ( ! $file -> isFile ()) {
if ( ! $file -> isFile ()) {
continue ;
continue ;
@ -322,33 +375,9 @@ class Capabilities implements IPublicCapability {
sort ( $predefinedBackgrounds );
sort ( $predefinedBackgrounds );
}
}
$this -> talkCache -> set ( 'predefined_backgrounds' , json_encode ( $predefinedBackgrounds ), 300 );
}
$capabilities [ 'config' ][ 'call' ][ 'predefined-backgrounds' ] = $predefinedBackgrounds ;
if ( $user instanceof IUser ) {
$quota = $user -> getQuota ();
if ( $quota !== 'none' ) {
$quota = Util :: computerFileSize ( $quota );
}
$capabilities [ 'config' ][ 'call' ][ 'can-upload-background' ] = $quota === 'none' || $quota > 0 ;
$capabilities [ 'config' ][ 'call' ][ 'can-enable-sip' ] = $this -> talkConfig -> canUserEnableSIP ( $user );
}
$supportedTaskTypes = $this -> taskProcessingManager -> getAvailableTaskTypes ();
if ( isset ( $supportedTaskTypes [ TextToTextSummary :: ID ])) {
$capabilities [ 'features' ][] = 'chat-summary-api' ;
}
if ( isset ( $supportedTaskTypes [ TextToTextTranslate :: ID ])) {
$capabilities [ 'config' ][ 'chat' ][ 'has-translation-task-providers' ] = true ;
$this -> talkCache -> set ( $cacheKey , json_encode ( $predefinedBackgrounds ), 300 );
}
}
if ( $this -> talkConfig -> getSignalingMode () === Config :: SIGNALING_EXTERNAL ) {
$capabilities [ 'features' ][] = 'call-end-to-end-encryption' ;
}
return [
'spreed' => $capabilities ,
];
return $predefinedBackgrounds ? ? [];
}
}
}
}