зеркало из https://github.com/nextcloud/spreed.git
Merge pull request #914 from nextcloud/in-call-flags
Change "inCall" state to contain bit flags (#911).
This commit is contained in:
Коммит
71bb925c01
|
@ -17,7 +17,7 @@ And in the works for the [coming versions](https://github.com/nextcloud/spreed/m
|
|||
|
||||
]]></description>
|
||||
|
||||
<version>3.99.10</version>
|
||||
<version>3.99.11</version>
|
||||
<licence>agpl</licence>
|
||||
|
||||
<author>Daniel Calviño Sánchez</author>
|
||||
|
|
|
@ -74,6 +74,7 @@ Base endpoint is: `/ocs/v2.php/apps/spreed/api/v1`
|
|||
* `no-ping` - The ping endpoint has been removed. Ping is updated with a call to fetch the signaling or chat messages instead.
|
||||
* `system-messages` - Chat messages have a `systemMessage` attribute and can be generated by the system
|
||||
* `mention-flag` - The room list populates the boolean `unreadMention` when the user was mentioned since their last visit
|
||||
* `in-call-flags` - A new flag `participantFlags` has been introduced and is replacing the `participantInCall` boolean.
|
||||
|
||||
## Room management
|
||||
|
||||
|
@ -125,7 +126,8 @@ Base endpoint is: `/ocs/v2.php/apps/spreed/api/v1`
|
|||
`name` | string | Name of the room (can also be empty)
|
||||
`displayName` | string | `name` if non empty, otherwise it falls back to a list of participants
|
||||
`participantType` | int | Permissions level of the current user
|
||||
`participantInCall` | bool | Flag if the current user is in the call
|
||||
`participantInCall` | bool | Flag if the current user is in the call (deprecated, use `participantFlags` instead)
|
||||
`participantFlags` | int | Flags of the current user (only available with `in-call-flags` capability)
|
||||
`count` | int | Number of active users
|
||||
`numGuests` | int | Number of active guests
|
||||
`lastPing` | int | Timestamp of the last ping of the current user (should be used for sorting)
|
||||
|
|
22
js/app.js
22
js/app.js
|
@ -34,6 +34,12 @@
|
|||
GUEST: 4,
|
||||
USERSELFJOINED: 5,
|
||||
|
||||
/* Must stay in sync with values in "lib/Room.php". */
|
||||
FLAG_DISCONNECTED: 0,
|
||||
FLAG_IN_CALL: 1,
|
||||
FLAG_WITH_AUDIO: 2,
|
||||
FLAG_WITH_VIDEO: 4,
|
||||
|
||||
/** @property {OCA.SpreedMe.Models.Room} activeRoom */
|
||||
activeRoom: null,
|
||||
|
||||
|
@ -397,7 +403,7 @@
|
|||
var self = this;
|
||||
this.signaling.syncRooms()
|
||||
.then(function() {
|
||||
self.stopListening(self.activeRoom, 'change:participantInCall');
|
||||
self.stopListening(self.activeRoom, 'change:participantFlags');
|
||||
|
||||
var participants;
|
||||
if (OC.getCurrentUser().uid) {
|
||||
|
@ -423,7 +429,7 @@
|
|||
self.setPageTitle(self.activeRoom.get('displayName'));
|
||||
|
||||
self.updateContentsLayout();
|
||||
self.listenTo(self.activeRoom, 'change:participantInCall', self.updateContentsLayout);
|
||||
self.listenTo(self.activeRoom, 'change:participantFlags', self.updateContentsLayout);
|
||||
|
||||
self.updateSidebarWithActiveRoom();
|
||||
});
|
||||
|
@ -434,7 +440,9 @@
|
|||
return;
|
||||
}
|
||||
|
||||
if (this.activeRoom.get('participantInCall') && this._chatViewInMainView === true) {
|
||||
var flags = this.activeRoom.get('participantFlags') || 0;
|
||||
var inCall = flags & OCA.SpreedMe.app.FLAG_IN_CALL !== 0;
|
||||
if (inCall && this._chatViewInMainView === true) {
|
||||
this._chatView.saveScrollPosition();
|
||||
this._chatView.$el.detach();
|
||||
this._sidebarView.addTab('chat', { label: t('spreed', 'Chat'), icon: 'icon-comment', priority: 100 }, this._chatView);
|
||||
|
@ -442,7 +450,7 @@
|
|||
this._chatView.restoreScrollPosition();
|
||||
this._chatView.setTooltipContainer(this._chatView.$el);
|
||||
this._chatViewInMainView = false;
|
||||
} else if (!this.activeRoom.get('participantInCall') && !this._chatViewInMainView) {
|
||||
} else if (!inCall && !this._chatViewInMainView) {
|
||||
this._chatView.saveScrollPosition();
|
||||
this._sidebarView.removeTab('chat');
|
||||
this._chatView.$el.prependTo('#app-content-wrapper');
|
||||
|
@ -452,7 +460,7 @@
|
|||
this._chatViewInMainView = true;
|
||||
}
|
||||
|
||||
if (this.activeRoom.get('participantInCall')) {
|
||||
if (inCall) {
|
||||
$('#video-speaking').show();
|
||||
$('#videos').show();
|
||||
$('#screens').show();
|
||||
|
@ -655,7 +663,7 @@
|
|||
},
|
||||
startLocalMedia: function(configuration) {
|
||||
if (this.callbackAfterMedia) {
|
||||
this.callbackAfterMedia();
|
||||
this.callbackAfterMedia(configuration);
|
||||
this.callbackAfterMedia = null;
|
||||
}
|
||||
|
||||
|
@ -665,7 +673,7 @@
|
|||
},
|
||||
startWithoutLocalMedia: function(isAudioEnabled, isVideoEnabled) {
|
||||
if (this.callbackAfterMedia) {
|
||||
this.callbackAfterMedia();
|
||||
this.callbackAfterMedia(null);
|
||||
this.callbackAfterMedia = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -109,8 +109,17 @@
|
|||
}
|
||||
|
||||
var self = this;
|
||||
this.app.callbackAfterMedia = function() {
|
||||
self.app.signaling.joinCall(token);
|
||||
this.app.callbackAfterMedia = function(configuration) {
|
||||
var flags = OCA.SpreedMe.app.FLAG_IN_CALL;
|
||||
if (configuration) {
|
||||
if (configuration.audio) {
|
||||
flags |= OCA.SpreedMe.app.FLAG_WITH_AUDIO;
|
||||
}
|
||||
if (configuration.video) {
|
||||
flags |= OCA.SpreedMe.app.FLAG_WITH_VIDEO;
|
||||
}
|
||||
}
|
||||
self.app.signaling.joinCall(token, flags);
|
||||
self.app.signaling.syncRooms();
|
||||
};
|
||||
|
||||
|
|
|
@ -253,10 +253,13 @@
|
|||
// Override in subclasses if necessary.
|
||||
};
|
||||
|
||||
OCA.Talk.Signaling.Base.prototype.joinCall = function(token) {
|
||||
OCA.Talk.Signaling.Base.prototype.joinCall = function(token, flags) {
|
||||
$.ajax({
|
||||
url: OC.linkToOCS('apps/spreed/api/v1/call', 2) + token,
|
||||
type: 'POST',
|
||||
data: {
|
||||
flags: flags
|
||||
},
|
||||
beforeSend: function (request) {
|
||||
request.setRequestHeader('Accept', 'application/json');
|
||||
},
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
'<div class="room-name"></div>' +
|
||||
'<div class="call-controls-container">' +
|
||||
' <div class="call-button">' +
|
||||
' {{#if participantInCall}}' +
|
||||
' {{#if isInCall}}' +
|
||||
' <button class="leave-call primary">' + t('spreed', 'Leave call') + '</button>' +
|
||||
' {{else}}' +
|
||||
' {{#if hasCall}}' +
|
||||
|
@ -86,6 +86,7 @@
|
|||
var canModerate = this._canModerate();
|
||||
return $.extend(this.model.toJSON(), {
|
||||
isGuest: this.model.get('participantType') === 4,
|
||||
isInCall: this.model.get('participantFlags') & OCA.SpreedMe.app.FLAG_IN_CALL !== 0,
|
||||
canModerate: canModerate,
|
||||
isPublic: this.model.get('type') === 3,
|
||||
showShareLink: !canModerate && this.model.get('type') === 3,
|
||||
|
@ -134,7 +135,7 @@
|
|||
'change:hasCall': function() {
|
||||
this.renderWhenInactive();
|
||||
},
|
||||
'change:participantInCall': function() {
|
||||
'change:participantFlags': function() {
|
||||
this.renderWhenInactive();
|
||||
},
|
||||
'change:participantType': function() {
|
||||
|
|
|
@ -107,7 +107,7 @@
|
|||
'change:hasCall': function() {
|
||||
this.render();
|
||||
},
|
||||
'change:participantInCall': function() {
|
||||
'change:participantFlags': function() {
|
||||
this.render();
|
||||
},
|
||||
'change:participantType': function() {
|
||||
|
|
24
js/webrtc.js
24
js/webrtc.js
|
@ -16,6 +16,7 @@ var spreedPeerConnectionTable = [];
|
|||
var ownPeer = null;
|
||||
var ownScreenPeer = null;
|
||||
var hasLocalMedia = false;
|
||||
var selfInCall = 0; // OCA.SpreedMe.app.FLAG_DISCONNECTED, not available yet.
|
||||
|
||||
function updateParticipantsUI(currentUsersNo) {
|
||||
'use strict';
|
||||
|
@ -130,6 +131,16 @@ var spreedPeerConnectionTable = [];
|
|||
ownPeer.start();
|
||||
}
|
||||
|
||||
function userHasStreams(user) {
|
||||
var flags = user;
|
||||
if (flags.hasOwnProperty('inCall')) {
|
||||
flags = flags.inCall;
|
||||
}
|
||||
flags = flags || OCA.SpreedMe.app.FLAG_DISCONNECTED;
|
||||
var REQUIRED_FLAGS = OCA.SpreedMe.app.FLAG_WITH_AUDIO | OCA.SpreedMe.app.FLAG_WITH_VIDEO;
|
||||
return (flags & REQUIRED_FLAGS) !== 0;
|
||||
}
|
||||
|
||||
function usersChanged(signaling, newUsers, disconnectedSessionIds) {
|
||||
'use strict';
|
||||
var currentSessionId = signaling.getSessionid();
|
||||
|
@ -164,7 +175,7 @@ var spreedPeerConnectionTable = [];
|
|||
if (useMcu) {
|
||||
// TODO(jojo): Already create peer object to avoid duplicate offers.
|
||||
webrtc.connection.requestOffer(user, "video");
|
||||
} else if (sessionId < currentSessionId) {
|
||||
} else if (userHasStreams(selfInCall) && (!userHasStreams(user) || sessionId < currentSessionId)) {
|
||||
// To avoid overloading the user joining a room (who previously called
|
||||
// all the other participants), we decide who calls who by comparing
|
||||
// the session ids of the users: "larger" ids call "smaller" ones.
|
||||
|
@ -208,7 +219,7 @@ var spreedPeerConnectionTable = [];
|
|||
var currentSessionId = signaling.getSessionid();
|
||||
var currentUsersInRoom = [];
|
||||
var userMapping = {};
|
||||
var selfInCall = false;
|
||||
selfInCall = OCA.SpreedMe.app.FLAG_DISCONNECTED;
|
||||
var sessionId;
|
||||
for (sessionId in users) {
|
||||
if (!users.hasOwnProperty(sessionId)) {
|
||||
|
@ -220,7 +231,7 @@ var spreedPeerConnectionTable = [];
|
|||
}
|
||||
|
||||
if (sessionId === currentSessionId) {
|
||||
selfInCall = true;
|
||||
selfInCall = user.inCall;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -348,6 +359,13 @@ var spreedPeerConnectionTable = [];
|
|||
if (!(typeof id === 'string' || id instanceof String)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var user = usersInCallMapping[id];
|
||||
if (user && !userHasStreams(user)) {
|
||||
console.log("User has no stream", id);
|
||||
return;
|
||||
}
|
||||
|
||||
// Indicator for username
|
||||
var userIndicator = document.createElement('div');
|
||||
userIndicator.className = 'nameIndicator';
|
||||
|
|
|
@ -188,7 +188,8 @@ class Application extends App {
|
|||
|
||||
$room = $event->getSubject();
|
||||
$sessionId = $event->getArgument('sessionId');
|
||||
$notifier->roomInCallChanged($room, true, [$sessionId]);
|
||||
$flags = $event->getArgument('flags');
|
||||
$notifier->roomInCallChanged($room, $flags, [$sessionId]);
|
||||
});
|
||||
$dispatcher->addListener(Room::class . '::postSessionLeaveCall', function(GenericEvent $event) {
|
||||
/** @var BackendNotifier $notifier */
|
||||
|
@ -196,7 +197,7 @@ class Application extends App {
|
|||
|
||||
$room = $event->getSubject();
|
||||
$sessionId = $event->getArgument('sessionId');
|
||||
$notifier->roomInCallChanged($room, false, [$sessionId]);
|
||||
$notifier->roomInCallChanged($room, Participant::FLAG_DISCONNECTED, [$sessionId]);
|
||||
});
|
||||
$dispatcher->addListener(Room::class . '::postRemoveBySession', function(GenericEvent $event) {
|
||||
/** @var BackendNotifier $notifier */
|
||||
|
|
|
@ -44,6 +44,7 @@ class Capabilities implements IPublicCapability {
|
|||
'no-ping',
|
||||
'system-messages',
|
||||
'mention-flag',
|
||||
'in-call-flags',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace OCA\Spreed\Controller;
|
|||
use OCA\Spreed\Exceptions\ParticipantNotFoundException;
|
||||
use OCA\Spreed\Exceptions\RoomNotFoundException;
|
||||
use OCA\Spreed\Manager;
|
||||
use OCA\Spreed\Participant;
|
||||
use OCA\Spreed\TalkSession;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
|
@ -69,7 +70,7 @@ class CallController extends OCSController {
|
|||
* @param string $token
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function getPeersForCall($token) {
|
||||
public function getPeersForCall(string $token): DataResponse {
|
||||
try {
|
||||
$room = $this->manager->getRoomForSession($this->userId, $this->session->getSessionForRoom($token));
|
||||
} catch (RoomNotFoundException $e) {
|
||||
|
@ -131,9 +132,10 @@ class CallController extends OCSController {
|
|||
* @UseSession
|
||||
*
|
||||
* @param string $token
|
||||
* @param int|null $flags
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function joinCall($token) {
|
||||
public function joinCall(string $token, $flags): DataResponse {
|
||||
try {
|
||||
$room = $this->manager->getRoomForParticipantByToken($token, $this->userId);
|
||||
} catch (RoomNotFoundException $e) {
|
||||
|
@ -163,7 +165,12 @@ class CallController extends OCSController {
|
|||
return new DataResponse([], Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
$room->changeInCall($sessionId, true);
|
||||
if ($flags === null) {
|
||||
// Default flags: user is in room with audio/video.
|
||||
$flags = Participant::FLAG_IN_CALL | Participant::FLAG_WITH_AUDIO | Participant::FLAG_WITH_VIDEO;
|
||||
}
|
||||
|
||||
$room->changeInCall($sessionId, $flags);
|
||||
|
||||
return new DataResponse();
|
||||
}
|
||||
|
@ -175,7 +182,7 @@ class CallController extends OCSController {
|
|||
* @param string $token
|
||||
* @return DataResponse
|
||||
*/
|
||||
public function leaveCall($token) {
|
||||
public function leaveCall(string $token): DataResponse {
|
||||
try {
|
||||
$room = $this->manager->getRoomForParticipantByToken($token, $this->userId);
|
||||
} catch (RoomNotFoundException $e) {
|
||||
|
@ -205,7 +212,7 @@ class CallController extends OCSController {
|
|||
return new DataResponse([], Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
$room->changeInCall($sessionId, false);
|
||||
$room->changeInCall($sessionId, Participant::FLAG_DISCONNECTED);
|
||||
|
||||
return new DataResponse();
|
||||
}
|
||||
|
|
|
@ -166,12 +166,14 @@ class RoomController extends OCSController {
|
|||
|
||||
if ($participant instanceof Participant) {
|
||||
$participantType = $participant->getParticipantType();
|
||||
$participantInCall = $participant->isInCall();
|
||||
$participantFlags = $participant->getInCallFlags();
|
||||
$favorite = $participant->isFavorite();
|
||||
} else {
|
||||
$participantType = Participant::GUEST;
|
||||
$participantInCall = $favorite = false;
|
||||
$participantFlags = Participant::FLAG_DISCONNECTED;
|
||||
$favorite = false;
|
||||
}
|
||||
$participantInCall = $participantFlags & Participant::FLAG_IN_CALL !== 0;
|
||||
|
||||
$lastActivity = $room->getLastActivity();
|
||||
if ($lastActivity instanceof \DateTimeInterface) {
|
||||
|
@ -189,7 +191,9 @@ class RoomController extends OCSController {
|
|||
'objectType' => $room->getObjectType(),
|
||||
'objectId' => $room->getObjectId(),
|
||||
'participantType' => $participantType,
|
||||
// Deprecated, use participantFlags instead.
|
||||
'participantInCall' => $participantInCall,
|
||||
'participantFlags' => $participantFlags,
|
||||
'count' => $room->getNumberOfParticipants(false, time() - 30),
|
||||
'hasPassword' => $room->hasPassword(),
|
||||
'hasCall' => $room->getActiveSince() instanceof \DateTimeInterface,
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Joachim Bauch <bauch@struktur.de>
|
||||
*
|
||||
* @author Joachim Bauch <bauch@struktur.de>
|
||||
*
|
||||
* @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\Spreed\Migration;
|
||||
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use OCP\Migration\IOutput;
|
||||
|
||||
class Version3003Date20180722152733 extends SimpleMigrationStep {
|
||||
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
||||
$table = $schema->getTable('talk_participants');
|
||||
$table->dropColumn('in_call');
|
||||
|
||||
return $schema;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Joachim Bauch <bauch@struktur.de>
|
||||
*
|
||||
* @author Joachim Bauch <bauch@struktur.de>
|
||||
*
|
||||
* @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\Spreed\Migration;
|
||||
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use OCP\Migration\IOutput;
|
||||
|
||||
class Version3003Date20180722152849 extends SimpleMigrationStep {
|
||||
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
||||
$table = $schema->getTable('talk_participants');
|
||||
$table->addColumn('in_call', Type::INTEGER, [
|
||||
'default' => 0,
|
||||
]);
|
||||
|
||||
return $schema;
|
||||
}
|
||||
}
|
|
@ -33,6 +33,11 @@ class Participant {
|
|||
const GUEST = 4;
|
||||
const USER_SELF_JOINED = 5;
|
||||
|
||||
const FLAG_DISCONNECTED = 0;
|
||||
const FLAG_IN_CALL = 1;
|
||||
const FLAG_WITH_AUDIO = 2;
|
||||
const FLAG_WITH_VIDEO = 4;
|
||||
|
||||
/** @var IDBConnection */
|
||||
protected $db;
|
||||
/** @var Room */
|
||||
|
@ -91,7 +96,7 @@ class Participant {
|
|||
return $this->sessionId;
|
||||
}
|
||||
|
||||
public function isInCall() {
|
||||
public function getInCallFlags() {
|
||||
return $this->inCall;
|
||||
}
|
||||
|
||||
|
|
20
lib/Room.php
20
lib/Room.php
|
@ -678,14 +678,11 @@ class Room {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $sessionId
|
||||
* @param bool $active
|
||||
*/
|
||||
public function changeInCall($sessionId, $active) {
|
||||
if ($active) {
|
||||
public function changeInCall(string $sessionId, int $flags) {
|
||||
if ($flags !== Participant::FLAG_DISCONNECTED) {
|
||||
$this->dispatcher->dispatch(self::class . '::preSessionJoinCall', new GenericEvent($this, [
|
||||
'sessionId' => $sessionId,
|
||||
'flags' => $flags,
|
||||
]));
|
||||
} else {
|
||||
$this->dispatcher->dispatch(self::class . '::preSessionLeaveCall', new GenericEvent($this, [
|
||||
|
@ -695,14 +692,15 @@ class Room {
|
|||
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->update('talk_participants')
|
||||
->set('in_call', $query->createNamedParameter((int) $active, IQueryBuilder::PARAM_INT))
|
||||
->set('in_call', $query->createNamedParameter($flags, IQueryBuilder::PARAM_INT))
|
||||
->where($query->expr()->eq('session_id', $query->createNamedParameter($sessionId)))
|
||||
->andWhere($query->expr()->eq('room_id', $query->createNamedParameter($this->getId(), IQueryBuilder::PARAM_INT)));
|
||||
$query->execute();
|
||||
|
||||
if ($active) {
|
||||
if ($flags !== Participant::FLAG_DISCONNECTED) {
|
||||
$this->dispatcher->dispatch(self::class . '::postSessionJoinCall', new GenericEvent($this, [
|
||||
'sessionId' => $sessionId,
|
||||
'flags' => $flags,
|
||||
]));
|
||||
} else {
|
||||
$this->dispatcher->dispatch(self::class . '::postSessionLeaveCall', new GenericEvent($this, [
|
||||
|
@ -784,14 +782,14 @@ class Room {
|
|||
while ($row = $result->fetch()) {
|
||||
if ($row['user_id'] !== '' && $row['user_id'] !== null) {
|
||||
$users[$row['user_id']] = [
|
||||
'inCall' => (bool) $row['in_call'],
|
||||
'inCall' => (int) $row['in_call'],
|
||||
'lastPing' => (int) $row['last_ping'],
|
||||
'sessionId' => $row['session_id'],
|
||||
'participantType' => (int) $row['participant_type'],
|
||||
];
|
||||
} else {
|
||||
$guests[] = [
|
||||
'inCall' => (bool) $row['in_call'],
|
||||
'inCall' => (int) $row['in_call'],
|
||||
'lastPing' => (int) $row['last_ping'],
|
||||
'sessionId' => $row['session_id'],
|
||||
];
|
||||
|
@ -855,7 +853,7 @@ class Room {
|
|||
$query->select('session_id')
|
||||
->from('talk_participants')
|
||||
->where($query->expr()->eq('room_id', $query->createNamedParameter($this->getId(), IQueryBuilder::PARAM_INT)))
|
||||
->andWhere($query->expr()->eq('in_call', $query->createNamedParameter(1, IQueryBuilder::PARAM_INT)))
|
||||
->andWhere($query->expr()->neq('in_call', $query->createNamedParameter(Participant::FLAG_DISCONNECTED, IQueryBuilder::PARAM_INT)))
|
||||
->setMaxResults(1);
|
||||
$result = $query->execute();
|
||||
$row = $result->fetch();
|
||||
|
|
|
@ -276,18 +276,18 @@ class BackendNotifier{
|
|||
* The "in-call" status of the given session ids has changed..
|
||||
*
|
||||
* @param Room $room
|
||||
* @param bool $inCall
|
||||
* @param int $flags
|
||||
* @param array $sessionids
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function roomInCallChanged($room, $inCall, $sessionIds) {
|
||||
$this->logger->info('Room in-call status changed: ' . $room->getToken() . ' ' . $inCall . ' ' . print_r($sessionIds, true), ['app' => 'spreed']);
|
||||
public function roomInCallChanged($room, $flags, $sessionIds) {
|
||||
$this->logger->info('Room in-call status changed: ' . $room->getToken() . ' ' . $flags . ' ' . print_r($sessionIds, true), ['app' => 'spreed']);
|
||||
$changed = [];
|
||||
$users = [];
|
||||
$participants = $room->getParticipants();
|
||||
foreach ($participants['users'] as $userId => $participant) {
|
||||
$participant['userId'] = $userId;
|
||||
if ($participant['inCall']) {
|
||||
if ($participant['inCall'] !== Participant::FLAG_DISCONNECTED) {
|
||||
$users[] = $participant;
|
||||
}
|
||||
if (in_array($participant['sessionId'], $sessionIds)) {
|
||||
|
@ -298,7 +298,7 @@ class BackendNotifier{
|
|||
if (!isset($participant['participantType'])) {
|
||||
$participant['participantType'] = Participant::GUEST;
|
||||
}
|
||||
if ($participant['inCall']) {
|
||||
if ($participant['inCall'] !== Participant::FLAG_DISCONNECTED) {
|
||||
$users[] = $participant;
|
||||
}
|
||||
if (in_array($participant['sessionId'], $sessionIds)) {
|
||||
|
@ -309,7 +309,7 @@ class BackendNotifier{
|
|||
$this->backendRequest('/api/v1/room/' . $room->getToken(), [
|
||||
'type' => 'incall',
|
||||
'incall' => [
|
||||
'incall' => $inCall,
|
||||
'incall' => $flags,
|
||||
'changed' => $changed,
|
||||
'users' => $users
|
||||
],
|
||||
|
|
|
@ -48,6 +48,7 @@ class CapabilitiesTest extends TestCase {
|
|||
'no-ping',
|
||||
'system-messages',
|
||||
'mention-flag',
|
||||
'in-call-flags',
|
||||
],
|
||||
],
|
||||
], $capabilities->getCapabilities());
|
||||
|
|
|
@ -27,6 +27,7 @@ use OCA\Spreed\Chat\CommentsManager;
|
|||
use OCA\Spreed\Config;
|
||||
use OCA\Spreed\Manager;
|
||||
use OCA\Spreed\Participant;
|
||||
use OCA\Spreed\Room;
|
||||
use OCA\Spreed\Signaling\BackendNotifier;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\Http\Client\IClientService;
|
||||
|
@ -263,7 +264,7 @@ class BackendNotifierTest extends \Test\TestCase {
|
|||
'userId' => $this->userId,
|
||||
'sessionId' => $userSession,
|
||||
]);
|
||||
$room->changeInCall($userSession, true);
|
||||
$room->changeInCall($userSession, Participant::FLAG_IN_CALL | Participant::FLAG_WITH_AUDIO | Participant::FLAG_WITH_VIDEO);
|
||||
|
||||
$requests = $this->controller->getRequests();
|
||||
$bodies = array_map(function($request) use ($room) {
|
||||
|
@ -272,10 +273,10 @@ class BackendNotifierTest extends \Test\TestCase {
|
|||
$this->assertContains([
|
||||
'type' => 'incall',
|
||||
'incall' => [
|
||||
'incall' => true,
|
||||
'incall' => 7,
|
||||
'changed' => [
|
||||
[
|
||||
'inCall' => true,
|
||||
'inCall' => 7,
|
||||
'lastPing' => 0,
|
||||
'sessionId' => $userSession,
|
||||
'participantType' => Participant::USER,
|
||||
|
@ -284,7 +285,7 @@ class BackendNotifierTest extends \Test\TestCase {
|
|||
],
|
||||
'users' => [
|
||||
[
|
||||
'inCall' => true,
|
||||
'inCall' => 7,
|
||||
'lastPing' => 0,
|
||||
'sessionId' => $userSession,
|
||||
'participantType' => Participant::USER,
|
||||
|
@ -296,7 +297,7 @@ class BackendNotifierTest extends \Test\TestCase {
|
|||
|
||||
$this->controller->clearRequests();
|
||||
$guestSession = $room->joinRoomGuest('');
|
||||
$room->changeInCall($guestSession, true);
|
||||
$room->changeInCall($guestSession, Participant::FLAG_IN_CALL);
|
||||
|
||||
$requests = $this->controller->getRequests();
|
||||
$bodies = array_map(function($request) use ($room) {
|
||||
|
@ -305,10 +306,10 @@ class BackendNotifierTest extends \Test\TestCase {
|
|||
$this->assertContains([
|
||||
'type' => 'incall',
|
||||
'incall' => [
|
||||
'incall' => true,
|
||||
'incall' => 1,
|
||||
'changed' => [
|
||||
[
|
||||
'inCall' => true,
|
||||
'inCall' => 1,
|
||||
'lastPing' => 0,
|
||||
'sessionId' => $guestSession,
|
||||
'participantType' => Participant::GUEST,
|
||||
|
@ -316,14 +317,14 @@ class BackendNotifierTest extends \Test\TestCase {
|
|||
],
|
||||
'users' => [
|
||||
[
|
||||
'inCall' => true,
|
||||
'inCall' => 7,
|
||||
'lastPing' => 0,
|
||||
'sessionId' => $userSession,
|
||||
'participantType' => Participant::USER,
|
||||
'userId' => $this->userId,
|
||||
],
|
||||
[
|
||||
'inCall' => true,
|
||||
'inCall' => 1,
|
||||
'lastPing' => 0,
|
||||
'sessionId' => $guestSession,
|
||||
'participantType' => Participant::GUEST,
|
||||
|
@ -333,7 +334,7 @@ class BackendNotifierTest extends \Test\TestCase {
|
|||
], $bodies);
|
||||
|
||||
$this->controller->clearRequests();
|
||||
$room->changeInCall($userSession, false);
|
||||
$room->changeInCall($userSession, Participant::FLAG_DISCONNECTED);
|
||||
|
||||
$requests = $this->controller->getRequests();
|
||||
$bodies = array_map(function($request) use ($room) {
|
||||
|
@ -342,10 +343,10 @@ class BackendNotifierTest extends \Test\TestCase {
|
|||
$this->assertContains([
|
||||
'type' => 'incall',
|
||||
'incall' => [
|
||||
'incall' => false,
|
||||
'incall' => 0,
|
||||
'changed' => [
|
||||
[
|
||||
'inCall' => false,
|
||||
'inCall' => 0,
|
||||
'lastPing' => 0,
|
||||
'sessionId' => $userSession,
|
||||
'participantType' => Participant::USER,
|
||||
|
@ -354,7 +355,7 @@ class BackendNotifierTest extends \Test\TestCase {
|
|||
],
|
||||
'users' => [
|
||||
[
|
||||
'inCall' => true,
|
||||
'inCall' => 1,
|
||||
'lastPing' => 0,
|
||||
'sessionId' => $guestSession,
|
||||
'participantType' => Participant::GUEST,
|
||||
|
|
Загрузка…
Ссылка в новой задаче