Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force call ends after X - API Follow ups #13491

Merged
merged 3 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,4 @@
## 20.1
* `archived-conversations` (local) - Conversations can be marked as archived which will hide them from the conversation list by default
* `config => call => start-without-media` (local) - Boolean, whether media should be disabled when starting or joining a conversation
* `config => call => max-duration` - Integer, maximum call duration in seconds. Please note that this should only be used with system cron and with a reasonable high value, due to the expended duration until the background job ran.
2 changes: 2 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
use OCA\Talk\Settings\BeforePreferenceSetEventListener;
use OCA\Talk\Settings\Personal;
use OCA\Talk\SetupCheck\BackgroundBlurLoading;
use OCA\Talk\SetupCheck\Configuration;
use OCA\Talk\SetupCheck\FederationLockCache;
use OCA\Talk\SetupCheck\HighPerformanceBackend;
use OCA\Talk\SetupCheck\RecordingBackend;
Expand Down Expand Up @@ -341,6 +342,7 @@ public function register(IRegistrationContext $context): void {

$context->registerTeamResourceProvider(TalkTeamResourceProvider::class);

$context->registerSetupCheck(Configuration::class);
$context->registerSetupCheck(HighPerformanceBackend::class);
$context->registerSetupCheck(FederationLockCache::class);
$context->registerSetupCheck(RecordingBackend::class);
Expand Down
1 change: 1 addition & 0 deletions lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ public function getCapabilities(): array {
'sip-dialout-enabled' => $this->talkConfig->isSIPDialOutEnabled(),
'can-enable-sip' => false,
'start-without-media' => $this->talkConfig->getCallsStartWithoutMedia($user?->getUID()),
'max-duration' => $this->appConfig->getAppValueInt('max_call_duration'),
],
'chat' => [
'max-length' => ChatManager::MAX_CHAT_LENGTH,
Expand Down
40 changes: 31 additions & 9 deletions lib/Chat/Parser/SystemMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,13 @@ protected function parseCall(Room $room, string $message, array $parameters, arr

switch ($numUsers) {
case 0:
if ($message === 'call_ended' || $actorIsSystem) {
if ($actorIsSystem) {
$subject = $this->l->n(
'Call with %n guest was ended, as it reached the maximum call duration (Duration {duration})',
'Call with %n guests was ended, as it reached the maximum call duration (Duration {duration})',
$parameters['guests']
);
} elseif ($message === 'call_ended') {
$subject = $this->l->n(
'Call with %n guest ended (Duration {duration})',
'Call with %n guests ended (Duration {duration})',
Expand All @@ -1127,7 +1133,9 @@ protected function parseCall(Room $room, string $message, array $parameters, arr
}
break;
case 1:
if ($message === 'call_ended' || $actorIsSystem) {
if ($actorIsSystem) {
$subject = $this->l->t('Call with {user1} and {user2} was ended, as it reached the maximum call duration (Duration {duration})');
} elseif ($message === 'call_ended') {
$subject = $this->l->t('Call with {user1} and {user2} ended (Duration {duration})');
} else {
if ($parameters['guests'] === 0) {
Expand All @@ -1140,13 +1148,17 @@ protected function parseCall(Room $room, string $message, array $parameters, arr
break;
case 2:
if ($parameters['guests'] === 0) {
if ($message === 'call_ended' || $actorIsSystem) {
if ($actorIsSystem) {
$subject = $this->l->t('Call with {user1} and {user2} was ended, as it reached the maximum call duration (Duration {duration})');
} elseif ($message === 'call_ended') {
$subject = $this->l->t('Call with {user1} and {user2} ended (Duration {duration})');
} else {
$subject = $this->l->t('{actor} ended the call with {user1} and {user2} (Duration {duration})');
}
} else {
if ($message === 'call_ended' || $actorIsSystem) {
if ($actorIsSystem) {
$subject = $this->l->t('Call with {user1}, {user2} and {user3} was ended, as it reached the maximum call duration (Duration {duration})');
} elseif ($message === 'call_ended') {
$subject = $this->l->t('Call with {user1}, {user2} and {user3} ended (Duration {duration})');
} else {
$subject = $this->l->t('{actor} ended the call with {user1}, {user2} and {user3} (Duration {duration})');
Expand All @@ -1156,13 +1168,17 @@ protected function parseCall(Room $room, string $message, array $parameters, arr
break;
case 3:
if ($parameters['guests'] === 0) {
if ($message === 'call_ended' || $actorIsSystem) {
if ($actorIsSystem) {
$subject = $this->l->t('Call with {user1}, {user2} and {user3} was ended, as it reached the maximum call duration (Duration {duration})');
} elseif ($message === 'call_ended') {
$subject = $this->l->t('Call with {user1}, {user2} and {user3} ended (Duration {duration})');
} else {
$subject = $this->l->t('{actor} ended the call with {user1}, {user2} and {user3} (Duration {duration})');
}
} else {
if ($message === 'call_ended' || $actorIsSystem) {
if ($actorIsSystem) {
$subject = $this->l->t('Call with {user1}, {user2}, {user3} and {user4} was ended, as it reached the maximum call duration (Duration {duration})');
} elseif ($message === 'call_ended') {
$subject = $this->l->t('Call with {user1}, {user2}, {user3} and {user4} ended (Duration {duration})');
} else {
$subject = $this->l->t('{actor} ended the call with {user1}, {user2}, {user3} and {user4} (Duration {duration})');
Expand All @@ -1172,13 +1188,17 @@ protected function parseCall(Room $room, string $message, array $parameters, arr
break;
case 4:
if ($parameters['guests'] === 0) {
if ($message === 'call_ended' || $actorIsSystem) {
if ($actorIsSystem) {
$subject = $this->l->t('Call with {user1}, {user2}, {user3} and {user4} was ended, as it reached the maximum call duration (Duration {duration})');
} elseif ($message === 'call_ended') {
$subject = $this->l->t('Call with {user1}, {user2}, {user3} and {user4} ended (Duration {duration})');
} else {
$subject = $this->l->t('{actor} ended the call with {user1}, {user2}, {user3} and {user4} (Duration {duration})');
}
} else {
if ($message === 'call_ended' || $actorIsSystem) {
if ($actorIsSystem) {
$subject = $this->l->t('Call with {user1}, {user2}, {user3}, {user4} and {user5} was ended, as it reached the maximum call duration (Duration {duration})');
} elseif ($message === 'call_ended') {
$subject = $this->l->t('Call with {user1}, {user2}, {user3}, {user4} and {user5} ended (Duration {duration})');
} else {
$subject = $this->l->t('{actor} ended the call with {user1}, {user2}, {user3}, {user4} and {user5} (Duration {duration})');
Expand All @@ -1188,7 +1208,9 @@ protected function parseCall(Room $room, string $message, array $parameters, arr
break;
case 5:
default:
if ($message === 'call_ended' || $actorIsSystem) {
if ($actorIsSystem) {
$subject = $this->l->t('Call with {user1}, {user2}, {user3}, {user4} and {user5} was ended, as it reached the maximum call duration (Duration {duration})');
} elseif ($message === 'call_ended') {
$subject = $this->l->t('Call with {user1}, {user2}, {user3}, {user4} and {user5} ended (Duration {duration})');
} else {
$subject = $this->l->t('{actor} ended the call with {user1}, {user2}, {user3}, {user4} and {user5} (Duration {duration})');
Expand Down
1 change: 1 addition & 0 deletions lib/ResponseDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
* sip-dialout-enabled: bool,
* can-enable-sip: bool,
* start-without-media: bool,
* max-duration: int,
* },
* chat: array{
* max-length: int,
Expand Down
55 changes: 55 additions & 0 deletions lib/SetupCheck/Configuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Talk\SetupCheck;

use OCP\AppFramework\Services\IAppConfig;
use OCP\IConfig;
use OCP\IL10N;
use OCP\SetupCheck\ISetupCheck;
use OCP\SetupCheck\SetupResult;

/**
* Check app configs and their dependencies
*/
class Configuration implements ISetupCheck {
public function __construct(
protected IL10N $l10n,
protected IConfig $config,
protected IAppConfig $appConfig,
) {
}

public function getCategory(): string {
return 'talk';
}

public function getName(): string {
return $this->l10n->t('Talk configuration');
}

public function run(): SetupResult {
$errors = $warnings = [];
$maxCallDuration = $this->appConfig->getAppValueInt('max_call_duration');
if ($maxCallDuration > 0) {
if ($this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax') !== 'cron') {
$errors[] = $this->l10n->t('Forcing a call duration is only supported with system cron. Please enable system cron or remove the `max_call_duration` configuration.');
} elseif ($maxCallDuration < 3600) {
$warnings[] = $this->l10n->t('Small `max_call_duration` values (currently set to %d) are not enforceable due to technical limitations. The background job is only executed every 5 minutes, so use at own risk.', [$maxCallDuration]);
}
}

if (!empty($errors)) {
return SetupResult::error(implode("\n", $errors));
}
if (!empty($warnings)) {
return SetupResult::warning(implode("\n", $warnings));
}
return SetupResult::success();
}
}
7 changes: 6 additions & 1 deletion openapi-administration.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@
"sip-enabled",
"sip-dialout-enabled",
"can-enable-sip",
"start-without-media"
"start-without-media",
"max-duration"
],
"properties": {
"enabled": {
Expand Down Expand Up @@ -190,6 +191,10 @@
},
"start-without-media": {
"type": "boolean"
},
"max-duration": {
"type": "integer",
"format": "int64"
}
}
},
Expand Down
7 changes: 6 additions & 1 deletion openapi-backend-recording.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
"sip-enabled",
"sip-dialout-enabled",
"can-enable-sip",
"start-without-media"
"start-without-media",
"max-duration"
],
"properties": {
"enabled": {
Expand Down Expand Up @@ -123,6 +124,10 @@
},
"start-without-media": {
"type": "boolean"
},
"max-duration": {
"type": "integer",
"format": "int64"
}
}
},
Expand Down
7 changes: 6 additions & 1 deletion openapi-backend-signaling.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
"sip-enabled",
"sip-dialout-enabled",
"can-enable-sip",
"start-without-media"
"start-without-media",
"max-duration"
],
"properties": {
"enabled": {
Expand Down Expand Up @@ -123,6 +124,10 @@
},
"start-without-media": {
"type": "boolean"
},
"max-duration": {
"type": "integer",
"format": "int64"
}
}
},
Expand Down
7 changes: 6 additions & 1 deletion openapi-backend-sipbridge.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@
"sip-enabled",
"sip-dialout-enabled",
"can-enable-sip",
"start-without-media"
"start-without-media",
"max-duration"
],
"properties": {
"enabled": {
Expand Down Expand Up @@ -166,6 +167,10 @@
},
"start-without-media": {
"type": "boolean"
},
"max-duration": {
"type": "integer",
"format": "int64"
}
}
},
Expand Down
7 changes: 6 additions & 1 deletion openapi-bots.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
"sip-enabled",
"sip-dialout-enabled",
"can-enable-sip",
"start-without-media"
"start-without-media",
"max-duration"
],
"properties": {
"enabled": {
Expand Down Expand Up @@ -123,6 +124,10 @@
},
"start-without-media": {
"type": "boolean"
},
"max-duration": {
"type": "integer",
"format": "int64"
}
}
},
Expand Down
7 changes: 6 additions & 1 deletion openapi-federation.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@
"sip-enabled",
"sip-dialout-enabled",
"can-enable-sip",
"start-without-media"
"start-without-media",
"max-duration"
],
"properties": {
"enabled": {
Expand Down Expand Up @@ -166,6 +167,10 @@
},
"start-without-media": {
"type": "boolean"
},
"max-duration": {
"type": "integer",
"format": "int64"
}
}
},
Expand Down
7 changes: 6 additions & 1 deletion openapi-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@
"sip-enabled",
"sip-dialout-enabled",
"can-enable-sip",
"start-without-media"
"start-without-media",
"max-duration"
],
"properties": {
"enabled": {
Expand Down Expand Up @@ -328,6 +329,10 @@
},
"start-without-media": {
"type": "boolean"
},
"max-duration": {
"type": "integer",
"format": "int64"
}
}
},
Expand Down
7 changes: 6 additions & 1 deletion openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@
"sip-enabled",
"sip-dialout-enabled",
"can-enable-sip",
"start-without-media"
"start-without-media",
"max-duration"
],
"properties": {
"enabled": {
Expand Down Expand Up @@ -269,6 +270,10 @@
},
"start-without-media": {
"type": "boolean"
},
"max-duration": {
"type": "integer",
"format": "int64"
}
}
},
Expand Down
1 change: 1 addition & 0 deletions src/__mocks__/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export const mockedCapabilities: Capabilities = {
'sip-dialout-enabled': true,
'can-enable-sip': true,
'start-without-media': false,
'max-duration': 0,
},
chat: {
'max-length': 32000,
Expand Down
2 changes: 2 additions & 0 deletions src/types/openapi/openapi-administration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ export type components = {
"sip-dialout-enabled": boolean;
"can-enable-sip": boolean;
"start-without-media": boolean;
/** Format: int64 */
"max-duration": number;
};
chat: {
/** Format: int64 */
Expand Down
2 changes: 2 additions & 0 deletions src/types/openapi/openapi-backend-recording.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ export type components = {
"sip-dialout-enabled": boolean;
"can-enable-sip": boolean;
"start-without-media": boolean;
/** Format: int64 */
"max-duration": number;
};
chat: {
/** Format: int64 */
Expand Down
2 changes: 2 additions & 0 deletions src/types/openapi/openapi-backend-signaling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export type components = {
"sip-dialout-enabled": boolean;
"can-enable-sip": boolean;
"start-without-media": boolean;
/** Format: int64 */
"max-duration": number;
};
chat: {
/** Format: int64 */
Expand Down
Loading
Loading