Populate the canStartCall value and add a capability

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2019-09-13 18:51:33 +02:00
Родитель 940a9351aa
Коммит 5da475f4c0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7076EA9751AACDDA
5 изменённых файлов: 20 добавлений и 0 удалений

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

@ -36,3 +36,4 @@ title: Capabilities
## 7.0
* `chat-read-marker` - The chat can be optionally marked read by clients manually, independent from the loading of the chat messages.
* `webinary-lobby` - See [Webinary management](webinary.md) for technical details.
* `start-call-flag` - Only moderators or users might be able to start calls.

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

@ -59,6 +59,7 @@ Base endpoint is: `/ocs/v2.php/apps/spreed/api/v1`
`sessionId` | string | `'0'` if not connected, otherwise a 512 character long string
`hasPassword` | bool | Flag if the conversation has a password
`hasCall` | bool | Flag if the conversation has an active call
`canStartCall` | bool | Flag if the user can start a new call in this conversation (joining is always possible) (only available with `start-call-flag` capability)
`lastActivity` | int | Timestamp of the last activity in the conversation, in seconds and UTC time zone
`isFavorite` | bool | Flag if the conversation is favorited by the user
`notificationLevel` | int | The notification level for the user (one of `Participant::NOTIFY_*` (1-3))

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

@ -80,6 +80,7 @@ class Capabilities implements IPublicCapability {
'read-only-rooms',
'chat-read-marker',
'webinary-lobby',
'start-call-flag',
],
'config' => [
'chat' => [

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

@ -42,6 +42,7 @@ use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Comments\IComment;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IUser;
@ -54,6 +55,8 @@ use Symfony\Component\EventDispatcher\GenericEvent;
class RoomController extends AEnvironmentAwareController {
/** @var string|null */
private $userId;
/** @var IConfig */
private $config;
/** @var TalkSession */
private $session;
/** @var IUserManager */
@ -78,6 +81,7 @@ class RoomController extends AEnvironmentAwareController {
public function __construct(string $appName,
?string $UserId,
IRequest $request,
IConfig $config,
TalkSession $session,
IUserManager $userManager,
IGroupManager $groupManager,
@ -89,6 +93,7 @@ class RoomController extends AEnvironmentAwareController {
ITimeFactory $timeFactory,
IL10N $l10n) {
parent::__construct($appName, $request);
$this->config = $config;
$this->session = $session;
$this->userId = $UserId;
$this->userManager = $userManager;
@ -177,6 +182,7 @@ class RoomController extends AEnvironmentAwareController {
'count' => 0,
'hasPassword' => $room->hasPassword(),
'hasCall' => false,
'canStartCall' => false,
'lastActivity' => 0,
'lastReadMessage' => 0,
'unreadMessages' => 0,
@ -244,6 +250,15 @@ class RoomController extends AEnvironmentAwareController {
return $roomData;
}
$defaultStartCall = (int) $this->config->getAppValue('spreed', 'start_calls', '0');
if ($defaultStartCall === 0) {
$roomData['canStartCall'] = true;
} else if ($defaultStartCall === 1 && (!$currentParticipant->isGuest() || $currentParticipant->hasModeratorPermissions())) {
$roomData['canStartCall'] = true;
} else if ($defaultStartCall === 2 && $currentParticipant->hasModeratorPermissions()) {
$roomData['canStartCall'] = true;
}
$currentUser = $this->userManager->get($currentParticipant->getUser());
if ($currentUser instanceof IUser) {
$lastReadMessage = $currentParticipant->getLastReadMessage();

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

@ -91,6 +91,7 @@ class CapabilitiesTest extends TestCase {
'read-only-rooms',
'chat-read-marker',
'webinary-lobby',
'start-call-flag',
],
'config' => [
'chat' => [
@ -146,6 +147,7 @@ class CapabilitiesTest extends TestCase {
'read-only-rooms',
'chat-read-marker',
'webinary-lobby',
'start-call-flag',
],
'config' => [
'chat' => [