Conditions | 4 |
Paths | 4 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
12 | public function __invoke(Request $request) |
||
13 | { |
||
14 | $channel = $this->channelManager->find($request->appId, $request->channelName); |
||
15 | |||
16 | if (is_null($channel)) { |
||
17 | throw new HttpException(404, 'Unknown channel "'.$request->channelName.'"'); |
||
18 | } |
||
19 | |||
20 | if (! $channel instanceof PresenceChannel) { |
||
21 | throw new HttpException(400, 'Invalid presence channel "'.$request->channelName.'"'); |
||
22 | } |
||
23 | |||
24 | $user = Collection::make($channel->getUsers())->filter(function($user) use ($request) { |
||
25 | return $user->user_id === (int) $request->userId; |
||
26 | })->first(); |
||
27 | |||
28 | if (is_null($user)) { |
||
29 | throw new HttpException(404, 'Unknown user "'.$request->userId.'"'); |
||
30 | } |
||
31 | |||
32 | $channel->updateUserInfo($user->user_id, (object) $request->info); |
||
33 | } |
||
34 | } |
||
35 |