зеркало из https://github.com/nextcloud/spreed.git
Populate the canStartCall value and add a capability
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Родитель
940a9351aa
Коммит
5da475f4c0
|
@ -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' => [
|
||||
|
|
Загрузка…
Ссылка в новой задаче