Browse Source

OCP Talk backend by the spreed app

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/6858/head
Joas Schilling 4 years ago
parent
commit
102e8e7acc
No known key found for this signature in database GPG Key ID: 7076EA9751AACDDA
  1. 3
      lib/AppInfo/Application.php
  2. 22
      lib/OCP/Conversation.php
  3. 49
      lib/OCP/TalkBackend.php

3
lib/AppInfo/Application.php

@ -62,6 +62,7 @@ use OCA\Talk\Middleware\CanUseTalkMiddleware;
use OCA\Talk\Middleware\InjectionMiddleware;
use OCA\Talk\Notification\Listener as NotificationListener;
use OCA\Talk\Notification\Notifier;
use OCA\Talk\OCP\TalkBackend;
use OCA\Talk\Profile\TalkAction;
use OCA\Talk\PublicShare\TemplateLoader as PublicShareTemplateLoader;
use OCA\Talk\PublicShareAuth\Listener as PublicShareAuthListener;
@ -139,6 +140,8 @@ class Application extends App implements IBootstrap {
$context->registerDashboardWidget(TalkWidget::class);
$context->registerProfileLinkAction(TalkAction::class);
$context->registerTalkBackend(TalkBackend::class);
}
public function boot(IBootContext $context): void {

22
lib/OCP/Conversation.php

@ -0,0 +1,22 @@
<?php
namespace OCA\Talk\OCP;
use OCA\Talk\Room;
use OCP\IURLGenerator;
use OCP\Talk\IConversation;
class Conversation implements IConversation {
protected IURLGenerator $url;
protected Room $room;
public function __construct(IURLGenerator $url,
Room $room) {
$this->url = $url;
$this->room = $room;
}
public function getAbsoluteUrl(): string {
return $this->url->linkToRouteAbsolute('spreed.Page.showCall', ['token' => $this->room->getToken()]);
}
}

49
lib/OCP/TalkBackend.php

@ -0,0 +1,49 @@
<?php
namespace OCA\Talk\OCP;
use OCA\Talk\Manager;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCA\Talk\Service\ParticipantService;
use OCP\IURLGenerator;
use OCP\Talk\IConversation;
use OCP\Talk\IConversationOptions;
use OCP\Talk\ITalkBackend;
class TalkBackend implements ITalkBackend {
protected Manager $manager;
protected ParticipantService $participantService;
protected IURLGenerator $url;
public function __construct(Manager $manager,
ParticipantService $participantService,
IURLGenerator $url) {
$this->manager = $manager;
$this->participantService = $participantService;
$this->url = $url;
}
public function createConversation(string $name, array $moderators, IConversationOptions $options): IConversation {
$room = $this->manager->createRoom(
$options->isPublic() ? Room::TYPE_PUBLIC : Room::TYPE_GROUP,
$name
);
if (!empty($moderators)) {
$users = [];
foreach ($moderators as $moderator) {
$users[] = [
'actorType' => Attendee::ACTOR_USERS,
'actorId' => $moderator->getUID(),
'participantType' => Participant::MODERATOR,
];
}
$this->participantService->addUsers($room, $users);
}
return new Conversation($this->url, $room);
}
}
Loading…
Cancel
Save