-
Notifications
You must be signed in to change notification settings - Fork 448
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
Standalone signaling support #366
Conversation
Codecov Report
@@ Coverage Diff @@
## master #366 +/- ##
=========================================
Coverage ? 10.32%
Complexity ? 394
=========================================
Files ? 23
Lines ? 1975
Branches ? 0
=========================================
Hits ? 204
Misses ? 1771
Partials ? 0
Continue to review full report at Codecov.
|
03a5bb1
to
efd0986
Compare
@nickvergessen @Ivansss this is now ready for some testing 😃 |
@nickvergessen @Ivansss this is now pending for quite some time - would be great to get some feedback... |
I will have a look on monday/tuesday, sorry conf was too busy |
if (!filter_var($server, FILTER_VALIDATE_URL)) { | ||
return array('data' => | ||
array('message' => | ||
(string) $this->l10n->t('Invalid signaling server url.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cast is not required anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency I would rather keep this aligned with surrounding code and remove the cast here and in other locations in a follow-up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, same as in the comment below, just ignore for now ;)
$servers = explode('\n', $signaling_server); | ||
foreach($servers as $server) { | ||
if (!filter_var($server, FILTER_VALIDATE_URL)) { | ||
return array('data' => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use the short array syntax [ ]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, just saw you only copy pasted, so okay
@@ -55,8 +55,11 @@ public function __construct($appName, | |||
* @param string $stun_server | |||
* @param string $turn_server | |||
* @param string $turn_server_secret | |||
* @param string $signaling_server | |||
* @param string $signaling_secret | |||
* @param string $signaling_skip_verify_cert |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
order is mixed up
can you also add $turn_server_protocols
to the docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
} | ||
|
||
$currentSignalingSkipVerifyCert = $this->config->getAppValue('spreed', 'signaling_skip_verify_cert', ''); | ||
if ($signaling_skip_verify_cert === null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$signaling_skip_verify_cert = (string) $signaling_skip_verify_cert;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't understand what you want to have changed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You set the variable to an empty string when it is null, so you can also just cast it to string, getting rid of the if-block. Should have the same result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
php magic 🙈
lib/Controller/RoomController.php
Outdated
@@ -305,6 +310,11 @@ protected function createOneToOneRoom($targetUserName) { | |||
$room->addParticipant($targetUser->getUID(), Participant::OWNER); | |||
$this->createNotification($currentUser, $targetUser, $room); | |||
|
|||
$this->backend->roomInvited($room, [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would move this into the methods of the Room
class.
For better decoupling we could also trigger a hook? This would allow any app to listen to those events and provide a signaling backend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now updated to use events in the latest commit.
@@ -76,6 +82,11 @@ public function __construct($appName, | |||
* @return JSONResponse | |||
*/ | |||
public function signalling($messages) { | |||
$signaling = $this->config->getSignalingServer(); | |||
if (!empty($signaling)) { | |||
throw new \Exception('Internal signaling disabled.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should return new JSONResponse('Internal signaling disabled.', Http::STATUS_BAD_REQUEST);
instead of throwing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
* @return JSONResponse | ||
*/ | ||
public function backend() { | ||
$json = file_get_contents('php://input'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't you use $this->request
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->request
is a OCP\IRequest
which only provides access to the request variables / -headers but I need the body of the request. Maybe there is a better way to get that - if so I didn't find it ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you post a json body to the server using parameters instead of the body? ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean sending a body body=the-json-object
and then using the value of variable body
? That sounds hackish ;-)
lib/Controller/BackendController.php
Outdated
use OCP\IRequest; | ||
use OCP\Security\ISecureRandom; | ||
|
||
class BackendController extends Controller { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This controller has no routes, drop it?
Or you forgot to commit something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer a controller now.
lib/Controller/BackendController.php
Outdated
* @param Room $room | ||
* @param array $userIds | ||
*/ | ||
public function roomInvited($room, $userIds) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is only reachable for admins, right?
The main question is at which point the things should be decoupled. |
lib/Room.php
Outdated
'type' => $participantType, | ||
'sessionId' => $sessionId, | ||
])); | ||
foreach ($participants as &$participant) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the reference &
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/Room.php
Outdated
'sessionId' => $sessionId, | ||
])); | ||
foreach ($participants as &$participant) { | ||
$query = $this->db->getQueryBuilder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create this outside of the foreach
, use $query->createParameter('userId')
and so on, and inside the loop just call setParameter('userId', $participant)->setParameter(....); $query->execute();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
lib/AppInfo/Application.php
Outdated
$notifier = $this->getContainer()->query(BackendNotifier::class); | ||
|
||
$dispatcher = $this->getContainer()->getServer()->getEventDispatcher(); | ||
$dispatcher->addListener('\OCA\Spreed\Room::postAddParticipants', function($event) use ($notifier) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use ->addListener(Room::class . '::postAddParticipants')
like we do in other places as well already
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed. I based my code on the dav
app, where the complete strings are used - using the classes makes more sense though!
lib/Room.php
Outdated
@@ -146,6 +152,8 @@ public function getParticipant($userId) { | |||
} | |||
|
|||
public function deleteRoom() { | |||
$this->dispatcher->dispatch('\OCA\Spreed\Room::preDeleteRoom', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self::class . '::preDeleteRoom'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
eced7a5
to
8f912a7
Compare
Rebased to current master. |
Signed-off-by: Joachim Bauch <bauch@struktur.de>
Signed-off-by: Joachim Bauch <bauch@struktur.de>
Signed-off-by: Joachim Bauch <bauch@struktur.de>
Signed-off-by: Joachim Bauch <bauch@struktur.de>
Signed-off-by: Joachim Bauch <bauch@struktur.de>
Signed-off-by: Joachim Bauch <bauch@struktur.de>
…s disabled. Signed-off-by: Joachim Bauch <bauch@struktur.de>
Signed-off-by: Joachim Bauch <bauch@struktur.de>
Signed-off-by: Joachim Bauch <bauch@struktur.de>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joachim Bauch <bauch@struktur.de>
Signed-off-by: Joachim Bauch <bauch@struktur.de>
…date users. Signed-off-by: Joachim Bauch <bauch@struktur.de>
Signed-off-by: Joachim Bauch <bauch@struktur.de>
Signed-off-by: Joachim Bauch <bauch@struktur.de>
Signed-off-by: Joachim Bauch <bauch@struktur.de>
This is necessary so the post-handlers can perform actions on the users that were previously invited (but that already have been removed from the DB) Signed-off-by: Joachim Bauch <bauch@struktur.de>
Signed-off-by: Joachim Bauch <bauch@struktur.de>
Signed-off-by: Joachim Bauch <bauch@struktur.de>
Signed-off-by: Joachim Bauch <bauch@struktur.de>
Signed-off-by: Joachim Bauch <bauch@struktur.de>
0b285f6
to
6d13722
Compare
Rebased again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normal signaling still works
Linting fail is unrelated |
Signed-off-by: Joas Schilling <coding@schilljs.com>
Only increased the version to trigger update of the settings again. Merging |
This PR adds support for using a standalone signaling server.
See https://github.com/nextcloud/spreed/wiki/Spreed-Signaling-API for the documentation of message formats. In a follow-up PR, the same messages will be implemented for the PHP backend, so there is only one API that clients need to implement.
@nickvergessen @Ivansss