Provide information for incoming call screens

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-02-11 13:48:55 +01:00
Родитель dd0e81c274
Коммит bf5f69cded
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7076EA9751AACDDA
10 изменённых файлов: 107 добавлений и 8 удалений

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

@ -16,7 +16,7 @@ And in the works for the [coming versions](https://github.com/nextcloud/spreed/m
]]></description>
<version>12.0.0-dev.2</version>
<version>12.0.0-dev.3</version>
<licence>agpl</licence>
<author>Daniel Calviño Sánchez</author>

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

@ -28,6 +28,7 @@ use OCA\Talk\Events\AddParticipantsEvent;
use OCA\Talk\Events\ModifyParticipantEvent;
use OCA\Talk\Events\RoomEvent;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCA\Talk\Service\ParticipantService;
use OCP\Activity\IManager;
@ -75,7 +76,7 @@ class Listener {
$listener = static function (ModifyParticipantEvent $event) {
/** @var self $listener */
$listener = \OC::$server->query(self::class);
$listener->setActive($event->getRoom());
$listener->setActive($event->getRoom(), $event->getParticipant());
};
$dispatcher->addListener(Room::EVENT_AFTER_SESSION_JOIN_CALL, $listener);
@ -97,8 +98,12 @@ class Listener {
$dispatcher->addListener(Room::EVENT_AFTER_USERS_ADD, $listener);
}
public function setActive(Room $room): void {
$room->setActiveSince($this->timeFactory->getDateTime(), !$this->userSession->isLoggedIn());
public function setActive(Room $room, Participant $participant): void {
$room->setActiveSince(
$this->timeFactory->getDateTime(),
$participant->getSession() ? $participant->getSession()->getInCall() : Participant::FLAG_DISCONNECTED,
$participant->getAttendee()->getActorType() !== Attendee::ACTOR_USERS
);
}
/**

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

@ -586,6 +586,7 @@ class RoomController extends AEnvironmentAwareController {
'description' => '',
'lastCommonReadMessage' => 0,
'listable' => Room::LISTABLE_NONE,
'callFlag' => Participant::FLAG_DISCONNECTED,
]);
}
@ -614,6 +615,7 @@ class RoomController extends AEnvironmentAwareController {
'readOnly' => $room->getReadOnly(),
'hasCall' => $room->getActiveSince() instanceof \DateTimeInterface,
'lastActivity' => $lastActivity,
'callFlag' => $room->getCallFlag(),
'lobbyState' => $room->getLobbyState(),
'lobbyTimer' => $lobbyTimer,
'sipEnabled' => $room->getSIPEnabled(),
@ -637,6 +639,7 @@ class RoomController extends AEnvironmentAwareController {
'readOnly' => $room->getReadOnly(),
'hasCall' => $room->getActiveSince() instanceof \DateTimeInterface,
'lastActivity' => $lastActivity,
'callFlag' => $room->getCallFlag(),
'isFavorite' => $attendee->isFavorite(),
'notificationLevel' => $attendee->getNotificationLevel(),
'lobbyState' => $room->getLobbyState(),

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

@ -187,6 +187,7 @@ class Manager {
(string) $row['description'],
(string) $row['password'],
(int) $row['active_guests'],
(int) $row['call_flag'],
$activeSince,
$lastActivity,
(int) $row['last_message'],

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

@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2021, Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk\Migration;
use Closure;
use Doctrine\DBAL\Types\Types;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version11001Date20210211111527 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('talk_rooms');
if (!$table->hasColumn('call_flag')) {
$table->addColumn('call_flag', Types::INTEGER, [
'default' => 0,
]);
return $schema;
}
return null;
}
}

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

@ -42,6 +42,7 @@ class SelectHelper {
->addSelect($alias . 'password')
->addSelect($alias . 'active_guests')
->addSelect($alias . 'active_since')
->addSelect($alias . 'call_flag')
->addSelect($alias . 'last_activity')
->addSelect($alias . 'last_message')
->addSelect($alias . 'lobby_timer')

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

@ -168,6 +168,8 @@ class Room {
private $password;
/** @var int */
private $activeGuests;
/** @var int */
private $callFlag;
/** @var \DateTime|null */
private $activeSince;
/** @var \DateTime|null */
@ -204,6 +206,7 @@ class Room {
string $description,
string $password,
int $activeGuests,
int $callFlag,
\DateTime $activeSince = null,
\DateTime $lastActivity = null,
int $lastMessageId,
@ -229,6 +232,7 @@ class Room {
$this->description = $description;
$this->password = $password;
$this->activeGuests = $activeGuests;
$this->callFlag = $callFlag;
$this->activeSince = $activeSince;
$this->lastActivity = $lastActivity;
$this->lastMessageId = $lastMessageId;
@ -318,6 +322,10 @@ class Room {
return $this->activeGuests;
}
public function getCallFlag(): int {
return $this->callFlag;
}
public function getActiveSince(): ?\DateTime {
return $this->activeSince;
}
@ -662,18 +670,32 @@ class Room {
/**
* @param \DateTime $since
* @param int $callFlag
* @param bool $isGuest
* @return bool
*/
public function setActiveSince(\DateTime $since, bool $isGuest): bool {
public function setActiveSince(\DateTime $since, int $callFlag, bool $isGuest): bool {
if ($isGuest && $this->getType() === self::PUBLIC_CALL) {
$query = $this->db->getQueryBuilder();
$query->update('talk_rooms')
->set('active_guests', $query->createFunction($query->getColumnName('active_guests') . ' + 1'))
->set(
'call_flag',
$query->expr()->bitwiseOr('call_flag', $callFlag)
)
->where($query->expr()->eq('id', $query->createNamedParameter($this->getId(), IQueryBuilder::PARAM_INT)));
$query->execute();
$this->activeGuests++;
} elseif (!$isGuest) {
$query = $this->db->getQueryBuilder();
$query->update('talk_rooms')
->set(
'call_flag',
$query->expr()->bitwiseOr('call_flag', $callFlag)
)
->where($query->expr()->eq('id', $query->createNamedParameter($this->getId(), IQueryBuilder::PARAM_INT)));
$query->execute();
}
if ($this->activeSince instanceof \DateTime) {
@ -682,7 +704,7 @@ class Room {
$query = $this->db->getQueryBuilder();
$query->update('talk_rooms')
->set('active_since', $query->createNamedParameter($since, 'datetime'))
->set('active_since', $query->createNamedParameter($since, IQueryBuilder::PARAM_DATE))
->where($query->expr()->eq('id', $query->createNamedParameter($this->getId(), IQueryBuilder::PARAM_INT)))
->andWhere($query->expr()->isNull('active_since'));
$query->execute();
@ -703,8 +725,9 @@ class Room {
public function resetActiveSince(): bool {
$query = $this->db->getQueryBuilder();
$query->update('talk_rooms')
->set('active_guests', $query->createNamedParameter(0))
->set('active_since', $query->createNamedParameter(null, 'datetime'))
->set('active_guests', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT))
->set('active_since', $query->createNamedParameter(null, IQueryBuilder::PARAM_DATE))
->set('call_flag', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT))
->where($query->expr()->eq('id', $query->createNamedParameter($this->getId(), IQueryBuilder::PARAM_INT)))
->andWhere($query->expr()->isNotNull('active_since'));

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

@ -270,6 +270,9 @@ class FeatureContext implements Context, SnippetAcceptingContext {
if (isset($expectedRoom['sipEnabled'])) {
$data['sipEnabled'] = (string) $room['sipEnabled'];
}
if (isset($expectedRoom['callFlag'])) {
$data['callFlag'] = (int) $room['callFlag'];
}
if (isset($expectedRoom['attendeePin'])) {
$data['attendeePin'] = $room['attendeePin'] ? '**PIN**' : '';
}

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

@ -23,14 +23,21 @@ Feature: callapi/group
Then user "participant1" sees 0 peers in call "room" with 200
And user "participant2" sees 0 peers in call "room" with 200
Then user "participant1" joins call "room" with 200
| flags | 1 |
Then user "participant1" sees 1 peers in call "room" with 200
And user "participant2" sees 1 peers in call "room" with 200
Then user "participant1" is participant of the following rooms (v3)
| id | type | callFlag |
| room | 2 | 1 |
Then user "participant2" joins room "room" with 200
Then user "participant1" sees 1 peers in call "room" with 200
And user "participant2" sees 1 peers in call "room" with 200
And user "participant2" joins call "room" with 200
Then user "participant1" sees 2 peers in call "room" with 200
And user "participant2" sees 2 peers in call "room" with 200
Then user "participant1" is participant of the following rooms (v3)
| id | type | callFlag |
| room | 2 | 7 |
Then user "participant1" leaves call "room" with 200
Then user "participant1" sees 1 peers in call "room" with 200
And user "participant2" sees 1 peers in call "room" with 200

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

@ -25,6 +25,7 @@ namespace OCA\Talk\Tests\php;
use OC\EventDispatcher\EventDispatcher;
use OCA\Talk\Events\VerifyRoomPasswordEvent;
use OCA\Talk\Manager;
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCA\Talk\Webinary;
use OCP\AppFramework\Utility\ITimeFactory;
@ -72,6 +73,7 @@ class RoomTest extends TestCase {
'description',
'passy',
0,
Participant::FLAG_DISCONNECTED,
null,
null,
0