Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
0687119
Revert "Temporary disable SIP UI parts"
nickvergessen Oct 30, 2020
5437eb4
Make the version checks future proof
nickvergessen Oct 30, 2020
1bc3284
Add a comment why the last comment is not included for sip
nickvergessen Oct 30, 2020
25d8bac
Use $this->request to access header and add docs about the return value
nickvergessen Oct 30, 2020
ad0032a
Prevent concurrent promotion/demotion requests to revert by accident
nickvergessen Oct 30, 2020
cebc640
Add a comment about the session
nickvergessen Oct 30, 2020
89f3f35
Fix copyright year
nickvergessen Oct 30, 2020
459858a
Introduce constants for the actor types
nickvergessen Oct 30, 2020
384b4ba
Add a comment about the non-0 exit code of the talk:active-call command
nickvergessen Oct 30, 2020
3f6fe4f
Add method to get room by actorId / actorType.
fancycode Oct 30, 2020
d0e799b
Get room by actorId / actorType if given in request.
fancycode Oct 30, 2020
f3e6e56
Get the participant by actor
nickvergessen Oct 30, 2020
d5dbdeb
Store the session given by the HPB for the actor
nickvergessen Oct 30, 2020
59133fe
Increase the length of the session id column
nickvergessen Oct 30, 2020
12d1bf1
Fix CS and psalm
nickvergessen Nov 2, 2020
92efefe
Only generate a PIN and send it when configured
nickvergessen Nov 2, 2020
e65bee6
Only delete guests without a PIN
nickvergessen Nov 2, 2020
1c0c893
Only allow enabling SIP when the user can enable it
nickvergessen Nov 2, 2020
02aa765
Only delete users that are guests as actor type not participant type
nickvergessen Nov 3, 2020
f4d0368
Generate a PIN for users when they join a room with SIP enabled
nickvergessen Nov 3, 2020
10bda4f
Show pins to moderators
nickvergessen Nov 3, 2020
84b7597
Use the call flag when it was given by the HPB server
nickvergessen Nov 3, 2020
23aab9e
Show the dial-in info in the sidebar
nickvergessen Nov 3, 2020
758048f
Don't expose SIP data when SIP is not configured anymore
nickvergessen Nov 3, 2020
2b7ce7a
Ignore the exception that is unknown
nickvergessen Nov 3, 2020
8aa3e76
Add the participant to the join/start call message generation
nickvergessen Nov 4, 2020
6902bdf
Add missing alias when deleting a room in the background job
nickvergessen Nov 4, 2020
b05a602
The session object is modified nowadays so it's always disconnected i…
nickvergessen Nov 4, 2020
f9813a5
Dispatch leave call events when the user was in call while leaving th…
nickvergessen Nov 4, 2020
8687b5c
All parameters are lowercase
nickvergessen Nov 4, 2020
a22a889
Don't preload the user so we load it with the session later on
nickvergessen Nov 4, 2020
d708bc5
Load the participant by session as loading by actor is prefetched onl…
nickvergessen Nov 4, 2020
51c1afc
Add constants for SIP flags and pass on the event
nickvergessen Nov 11, 2020
954d960
Don't show the SIP connection as guest
nickvergessen Nov 11, 2020
2b052e8
Also load the session information when we load an attendee
nickvergessen Nov 11, 2020
1b4c42e
When the HPB provided a session id only join/leave with that session
nickvergessen Nov 13, 2020
8e03129
Update baseline
nickvergessen Nov 16, 2020
18e6072
Refresh the peer list and take the display name from there
nickvergessen Nov 16, 2020
c0a94ed
Use a new VideoBackground component when we get a userId
nickvergessen Nov 16, 2020
23a778b
Fix baseline
nickvergessen Nov 17, 2020
df69c33
Also check the room token when suggesting if SIP can be enabled
nickvergessen Nov 17, 2020
a655825
Simplify getting the participant
nickvergessen Nov 17, 2020
c287c0f
Update baseline
nickvergessen Nov 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ And in the works for the [coming versions](https://github.com/nextcloud/spreed/m

]]></description>

<version>11.0.0-dev.6</version>
<version>11.0.0-dev.7</version>
<licence>agpl</licence>

<author>Daniel Calviño Sánchez</author>
Expand Down
6 changes: 3 additions & 3 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
'url' => '/api/{apiVersion}/call/{token}',
'verb' => 'GET',
'requirements' => [
'apiVersion' => 'v1',
'apiVersion' => 'v(1|2|3)',
'token' => '^[a-z0-9]{4,30}$',
],
],
Expand All @@ -118,7 +118,7 @@
'url' => '/api/{apiVersion}/call/{token}',
'verb' => 'POST',
'requirements' => [
'apiVersion' => 'v1',
'apiVersion' => 'v(1|2|3)',
'token' => '^[a-z0-9]{4,30}$',
],
],
Expand All @@ -127,7 +127,7 @@
'url' => '/api/{apiVersion}/call/{token}',
'verb' => 'DELETE',
'requirements' => [
'apiVersion' => 'v1',
'apiVersion' => 'v(1|2|3)',
'token' => '^[a-z0-9]{4,30}$',
],
],
Expand Down
Binary file added img/phone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions lib/Activity/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use OCA\Talk\Events\AddParticipantsEvent;
use OCA\Talk\Events\ModifyParticipantEvent;
use OCA\Talk\Events\RoomEvent;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Room;
use OCA\Talk\Service\ParticipantService;
use OCP\Activity\IManager;
Expand Down Expand Up @@ -129,7 +130,7 @@ public function generateCallActivity(Room $room): bool {
}

$actorId = $userIds[0] ?? 'guests-only';
$actorType = $actorId !== 'guests-only' ? 'users' : 'guests';
$actorType = $actorId !== 'guests-only' ? Attendee::ACTOR_USERS : Attendee::ACTOR_GUESTS;
$this->chatManager->addSystemMessage($room, $actorType, $actorId, json_encode([
'message' => 'call_ended',
'parameters' => [
Expand Down Expand Up @@ -205,7 +206,7 @@ public function generateInvitationActivity(Room $room, array $participants): voi
}

foreach ($participants as $participant) {
if ($participant['actorType'] !== 'users') {
if ($participant['actorType'] !== Attendee::ACTOR_USERS) {
// No user => no activity
continue;
}
Expand Down
5 changes: 3 additions & 2 deletions lib/Chat/AutoComplete/SearchPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

use OCA\Talk\Files\Util;
use OCA\Talk\GuestManager;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Room;
use OCA\Talk\Service\ParticipantService;
use OCA\Talk\TalkSession;
Expand Down Expand Up @@ -102,9 +103,9 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
$participants = $this->participantService->getParticipantsForRoom($this->room);
foreach ($participants as $participant) {
$attendee = $participant->getAttendee();
if ($attendee->getActorType() === 'guests') {
if ($attendee->getActorType() === Attendee::ACTOR_GUESTS) {
$guestSessionHashes[] = $attendee->getActorId();
} elseif ($attendee->getActorType() === 'users') {
} elseif ($attendee->getActorType() === Attendee::ACTOR_USERS) {
$userIds[] = $attendee->getActorId();
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Chat/ChatManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use OC\Memcache\NullCache;
use OCA\Talk\Events\ChatEvent;
use OCA\Talk\Events\ChatParticipantEvent;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCA\Talk\Service\ParticipantService;
Expand Down Expand Up @@ -144,7 +145,7 @@ public function addSystemMessage(Room $chat, string $actorType, string $actorId,
* @return IComment
*/
public function addChangelogMessage(Room $chat, string $message): IComment {
$comment = $this->commentsManager->create('guests', 'changelog', 'chat', (string) $chat->getId());
$comment = $this->commentsManager->create(Attendee::ACTOR_GUESTS, 'changelog', 'chat', (string) $chat->getId());

$comment->setMessage($message, self::MAX_CHAT_LENGTH);
$comment->setCreationDateTime($this->timeFactory->getDateTime());
Expand Down
7 changes: 4 additions & 3 deletions lib/Chat/Command/Executor.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

use OCA\Talk\Chat\ChatManager;
use OCA\Talk\Events\CommandEvent;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Model\Command;
use OCA\Talk\Participant;
use OCA\Talk\Room;
Expand Down Expand Up @@ -90,7 +91,7 @@ public function exec(Room $room, IComment $message, Command $command, string $ar
try {
$command = $this->commandService->resolveAlias($command);
} catch (DoesNotExistException $e) {
$user = $message->getActorType() === 'users' ? $message->getActorId() : '';
$user = $message->getActorType() === Attendee::ACTOR_USERS ? $message->getActorId() : '';
$message->setMessage(json_encode([
'user' => $user,
'visibility' => $command->getResponse(),
Expand All @@ -109,7 +110,7 @@ public function exec(Room $room, IComment $message, Command $command, string $ar
$output = $this->execShell($room, $message, $command, $arguments);
}

$user = $message->getActorType() === 'users' ? $message->getActorId() : '';
$user = $message->getActorType() === Attendee::ACTOR_USERS ? $message->getActorId() : '';
$message->setMessage(json_encode([
'user' => $user,
'visibility' => $command->getResponse(),
Expand Down Expand Up @@ -205,7 +206,7 @@ public function execShell(Room $room, IComment $message, Command $command, strin
$command->getScript(),
$arguments,
$room->getToken(),
$message->getActorType() === 'users' ? $message->getActorId() : ''
$message->getActorType() === Attendee::ACTOR_USERS ? $message->getActorId() : ''
);
} catch (\InvalidArgumentException $e) {
$this->logger->error($e->getMessage(), ['exception' => $e]);
Expand Down
5 changes: 3 additions & 2 deletions lib/Chat/MessageParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use OCA\Talk\Events\ChatMessageEvent;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\GuestManager;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Model\Message;
use OCA\Talk\Participant;
use OCA\Talk\Room;
Expand Down Expand Up @@ -79,10 +80,10 @@ protected function setActor(Message $message): void {
$comment = $message->getComment();

$displayName = '';
if ($comment->getActorType() === 'users') {
if ($comment->getActorType() === Attendee::ACTOR_USERS) {
$user = $this->userManager->get($comment->getActorId());
$displayName = $user instanceof IUser ? $user->getDisplayName() : $comment->getActorId();
} elseif ($comment->getActorType() === 'guests') {
} elseif ($comment->getActorType() === Attendee::ACTOR_GUESTS) {
if (isset($guestNames[$comment->getActorId()])) {
$displayName = $this->guestNames[$comment->getActorId()];
} else {
Expand Down
11 changes: 6 additions & 5 deletions lib/Chat/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use OCA\Talk\Exceptions\RoomNotFoundException;
use OCA\Talk\Files\Util;
use OCA\Talk\Manager;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Model\Session;
use OCA\Talk\Participant;
use OCA\Talk\Room;
Expand Down Expand Up @@ -135,7 +136,7 @@ public function notifyMentionedUsers(Room $chat, IComment $comment, array $alrea
* @return string[] Users that were mentioned
*/
public function notifyReplyToAuthor(Room $chat, IComment $comment, IComment $replyTo): array {
if ($replyTo->getActorType() !== 'users') {
if ($replyTo->getActorType() !== Attendee::ACTOR_USERS) {
// No reply notification when the replyTo-author was not a user
return [];
}
Expand Down Expand Up @@ -308,7 +309,7 @@ protected function getDefaultGroupNotification(): int {
* @return bool
*/
protected function shouldMentionedUserBeNotified(string $userId, IComment $comment): bool {
if ($comment->getActorType() === 'users' && $userId === $comment->getActorId()) {
if ($comment->getActorType() === Attendee::ACTOR_USERS && $userId === $comment->getActorId()) {
// Do not notify the user if they mentioned themselves
return false;
}
Expand Down Expand Up @@ -341,7 +342,7 @@ protected function shouldMentionedUserBeNotified(string $userId, IComment $comme
// the notification can be parsed and links to an existing room,
// where they are a participant of.
$this->participantService->addUsers($room, [[
'actorType' => 'users',
'actorType' => Attendee::ACTOR_USERS,
'actorId' => $userId,
]]);
return true;
Expand All @@ -364,12 +365,12 @@ protected function shouldMentionedUserBeNotified(string $userId, IComment $comme
* @return bool
*/
protected function shouldParticipantBeNotified(Participant $participant, IComment $comment, array $alreadyNotifiedUsers): bool {
if ($participant->getAttendee()->getActorType() !== 'users') {
if ($participant->getAttendee()->getActorType() !== Attendee::ACTOR_USERS) {
return false;
}

$userId = $participant->getAttendee()->getActorId();
if ($comment->getActorType() === 'users' && $userId === $comment->getActorId()) {
if ($comment->getActorType() === Attendee::ACTOR_USERS && $userId === $comment->getActorId()) {
// Do not notify the author
return false;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Chat/Parser/Changelog.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

namespace OCA\Talk\Chat\Parser;

use OCA\Talk\Model\Attendee;
use OCA\Talk\Model\Message;

class Changelog {
Expand All @@ -32,7 +33,7 @@ class Changelog {
* @throws \OutOfBoundsException
*/
public function parseMessage(Message $chatMessage): void {
if ($chatMessage->getActorType() !== 'guests' ||
if ($chatMessage->getActorType() !== Attendee::ACTOR_GUESTS ||
$chatMessage->getActorId() !== 'changelog') {
throw new \OutOfBoundsException('Not a changelog');
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Chat/Parser/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

namespace OCA\Talk\Chat\Parser;

use OCA\Talk\Model\Attendee;
use OCA\Talk\Model\Message;

class Command {
Expand All @@ -44,7 +45,7 @@ public function parseMessage(Message $message): void {

$participant = $message->getParticipant();
if ($data['visibility'] !== \OCA\Talk\Model\Command::RESPONSE_ALL &&
($participant->getAttendee()->getActorType() !== 'users'
($participant->getAttendee()->getActorType() !== Attendee::ACTOR_USERS
|| $data['user'] !== $participant->getAttendee()->getActorId())) {
$message->setVisibility(false);
return;
Expand Down
5 changes: 3 additions & 2 deletions lib/Chat/Parser/SystemMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\GuestManager;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Model\Message;
use OCA\Talk\Participant;
use OCA\Talk\Share\RoomShareProvider;
Expand Down Expand Up @@ -94,7 +95,7 @@ public function parseMessage(Message $chatMessage): void {
if (!$participant->isGuest()) {
$currentActorId = $participant->getAttendee()->getActorId();
$currentUserIsActor = $parsedParameters['actor']['type'] === 'user' &&
$participant->getAttendee()->getActorType() === 'users' &&
$participant->getAttendee()->getActorType() === Attendee::ACTOR_USERS &&
$currentActorId === $parsedParameters['actor']['id'];
} else {
$currentActorId = $participant->getAttendee()->getActorId();
Expand Down Expand Up @@ -385,7 +386,7 @@ protected function getFileFromShare(Participant $participant, string $shareId):
}

protected function getActor(IComment $comment): array {
if ($comment->getActorType() === 'guests') {
if ($comment->getActorType() === Attendee::ACTOR_GUESTS) {
return $this->getGuest($comment->getActorId());
}

Expand Down
3 changes: 2 additions & 1 deletion lib/Chat/Parser/UserMention.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\GuestManager;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Model\Message;
use OCA\Talk\Room;
use OCP\Comments\ICommentsManager;
Expand Down Expand Up @@ -116,7 +117,7 @@ public function parseMessage(Message $chatMessage): void {

if ($mention['type'] === 'call') {
$userId = '';
if ($chatMessage->getParticipant()->getAttendee()->getActorType() === 'users') {
if ($chatMessage->getParticipant()->getAttendee()->getActorType() === Attendee::ACTOR_USERS) {
$userId = $chatMessage->getParticipant()->getAttendee()->getActorId();
}

Expand Down
13 changes: 7 additions & 6 deletions lib/Chat/SystemMessage/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use OCA\Talk\Events\RemoveUserEvent;
use OCA\Talk\Events\RoomEvent;
use OCA\Talk\Manager;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Model\Session;
use OCA\Talk\Participant;
use OCA\Talk\Room;
Expand Down Expand Up @@ -80,16 +81,16 @@ public static function register(IEventDispatcher $dispatcher): void {
$participantService = \OC::$server->query(ParticipantService::class);

if ($participantService->hasActiveSessionsInCall($room)) {
$listener->sendSystemMessage($room, 'call_joined');
$listener->sendSystemMessage($room, 'call_joined', [], $event->getParticipant());
} else {
$listener->sendSystemMessage($room, 'call_started');
$listener->sendSystemMessage($room, 'call_started', [], $event->getParticipant());
}
});
$dispatcher->addListener(Room::EVENT_AFTER_SESSION_LEAVE_CALL, static function (ModifyParticipantEvent $event) {
$room = $event->getRoom();

$session = $event->getParticipant()->getSession();
if (!$session instanceof Session || $session->getInCall() === Participant::FLAG_DISCONNECTED) {
if (!$session instanceof Session) {
// This happens in case the user was kicked/lobbied
return;
}
Expand Down Expand Up @@ -221,7 +222,7 @@ public static function register(IEventDispatcher $dispatcher): void {
$room = $event->getRoom();
$attendee = $event->getParticipant()->getAttendee();

if ($attendee->getActorType() !== 'users' && $attendee->getActorType() !== 'guests') {
if ($attendee->getActorType() !== Attendee::ACTOR_USERS && $attendee->getActorType() !== Attendee::ACTOR_GUESTS) {
return;
}

Expand Down Expand Up @@ -277,10 +278,10 @@ protected function sendSystemMessage(Room $room, string $message, array $paramet
$actorType = 'users';
$actorId = $user->getUID();
} elseif (\OC::$CLI) {
$actorType = 'guests';
$actorType = Attendee::ACTOR_GUESTS;
$actorId = 'cli';
} else {
$actorType = 'guests';
$actorType = Attendee::ACTOR_GUESTS;
$sessionId = $this->talkSession->getSessionForRoom($room->getToken());
$actorId = $sessionId ? sha1($sessionId) : 'failed-to-get-session';
}
Expand Down
5 changes: 3 additions & 2 deletions lib/Command/Room/TRoomCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Exceptions\RoomNotFoundException;
use OCA\Talk\Manager;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCA\Talk\Service\ParticipantService;
Expand Down Expand Up @@ -249,7 +250,7 @@ protected function addRoomParticipants(Room $room, array $userIds): void {
}

$participants[] = [
'actorType' => 'users',
'actorType' => Attendee::ACTOR_USERS,
'actorId' => $user->getUID(),
];
}
Expand Down Expand Up @@ -377,7 +378,7 @@ protected function completeParticipantValues(CompletionContext $context): array
$users = [];
$participants = $this->participantService->getParticipantsForRoom($room);
foreach ($participants as $participant) {
if ($participant->getAttendee()->getActorType() === 'users'
if ($participant->getAttendee()->getActorType() === Attendee::ACTOR_USERS
&& stripos($participant->getAttendee()->getActorId(), $context->getCurrentWord()) !== false) {
$users[] = $participant->getAttendee()->getActorId();
}
Expand Down
21 changes: 21 additions & 0 deletions lib/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class Config {
/** @var ISecureRandom */
private $secureRandom;

/** @var array */
protected $canEnableSIP = [];

public function __construct(IConfig $config,
ISecureRandom $secureRandom,
IGroupManager $groupManager,
Expand Down Expand Up @@ -84,6 +87,24 @@ public function getSIPSharedSecret(): string {
return $this->config->getAppValue('spreed', 'sip_bridge_shared_secret');
}

public function canUserEnableSIP(IUser $user): bool {
if (isset($this->canEnableSIP[$user->getUID()])) {
return $this->canEnableSIP[$user->getUID()];
}

$this->canEnableSIP[$user->getUID()] = false;

$allowedGroups = $this->getSIPGroups();
if (empty($allowedGroups)) {
$this->canEnableSIP[$user->getUID()] = true;
} else {
$userGroups = $this->groupManager->getUserGroupIds($user);
$this->canEnableSIP[$user->getUID()] = !empty(array_intersect($allowedGroups, $userGroups));
}

return $this->canEnableSIP[$user->getUID()];
}

public function isDisabledForUser(IUser $user): bool {
$allowedGroups = $this->getAllowedTalkGroupIds();
if (empty($allowedGroups)) {
Expand Down
Loading