forked from ProcessMaker/processmaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchannels.php
More file actions
52 lines (41 loc) · 1.51 KB
/
channels.php
File metadata and controls
52 lines (41 loc) · 1.51 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
<?php
/*
|--------------------------------------------------------------------------
| Broadcast Channels
|--------------------------------------------------------------------------
|
| Here you may register all of the event broadcasting channels that your
| application supports. The given channel authorization callbacks are
| used to check if an authenticated user can listen to the channel.
|
*/
use ProcessMaker\Models\ProcessRequest;
use ProcessMaker\Models\ProcessRequestToken;
Broadcast::channel('ProcessMaker.Models.User.{id}', function ($user, $id) {
return (int) $user->id === (int) $id;
});
Broadcast::channel('ProcessMaker.Models.ProcessRequest.{id}', function ($user, $id) {
if ($id === 'undefined' || $user === 'undefined') {
return;
}
if ($user->is_administrator) {
return true;
}
$request = ProcessRequest::find($id);
return $request->user_id === $user->id
|| !empty($request->participants()->where('users.id', $user->getKey())->first())
|| $request->process?->manager_id === $user->id;
});
Broadcast::channel('ProcessMaker.Models.ProcessRequestToken.{id}', function ($user, $id) {
if ($user->is_administrator) {
return true;
}
$token = ProcessRequestToken::find($id);
return $user->getKey() === $token->user_id;
});
Broadcast::channel('test.status', function ($user) {
return true;
});
Broadcast::channel('ProcessMaker.Models.Process.{processId}.Language.{language}', function ($user, $processId, $language) {
return true;
});