-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathHookController.php
More file actions
99 lines (79 loc) · 2.13 KB
/
Copy pathHookController.php
File metadata and controls
99 lines (79 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
namespace OCA\BigBlueButton\Controller;
use OCA\BigBlueButton\AvatarRepository;
use OCA\BigBlueButton\Db\Room;
use OCA\BigBlueButton\Event\MeetingEndedEvent;
use OCA\BigBlueButton\Event\RecordingReadyEvent;
use OCA\BigBlueButton\Service\RoomService;
use OCP\IConfig;
use OCP\AppFramework\Controller;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IRequest;
class HookController extends Controller {
/** @var string */
protected $token;
/** @var Room|null */
protected $room;
/** @var RoomService */
private $service;
/** @var AvatarRepository */
private $avatarRepository;
/** @var IEventDispatcher */
private $eventDispatcher;
/** @var IConfig */
private $config;
public function __construct(
string $appName,
IRequest $request,
RoomService $service,
AvatarRepository $avatarRepository,
IEventDispatcher $eventDispatcher,
IConfig $config
) {
parent::__construct($appName, $request);
$this->service = $service;
$this->avatarRepository = $avatarRepository;
$this->eventDispatcher = $eventDispatcher;
$this->config = $config;
}
public function setToken(string $token): void {
$this->token = $token;
$this->room = null;
}
public function isValidToken(): bool {
$room = $this->getRoom();
return $room !== null;
}
/**
* @PublicPage
*
* @NoCSRFRequired
*
* @return void
*/
public function meetingEnded($recordingmarks = false): void {
$recordingmarks = \boolval($recordingmarks);
$room = $this->getRoom();
$this->service->updateRunning($room->getId(), false);
if ($this->config->getAppValue('bbb', 'avatar.enabled', 'true') === 'true') {
$this->avatarRepository->clearRoom($room->uid);
}
$this->eventDispatcher->dispatch(MeetingEndedEvent::class, new MeetingEndedEvent($room, $recordingmarks));
}
/**
* @PublicPage
*
* @NoCSRFRequired
*
* @return void
*/
public function recordingReady(): void {
$this->eventDispatcher->dispatch(RecordingReadyEvent::class, new RecordingReadyEvent($this->getRoom()));
}
private function getRoom(): ?Room {
if ($this->room === null) {
$this->room = $this->service->findByUid($this->token);
}
return $this->room;
}
}