1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
immessageconnector.php
См. документацию.
1<?php
2
3namespace Bitrix\Vote\Attachment;
4
5use Bitrix\Vote\Attach;
6use Bitrix\Im\V2\Message;
7use Bitrix\Main\Loader;
8use Bitrix\Vote\Integration\Im\ImVoteStopEventHandler;
9
10final class ImMessageConnector extends Connector
11{
12
13 public function canRead($userId): bool
14 {
15 $userId = (int)$userId;
16 if ($userId <= 0)
17 {
18 return false;
19 }
20
21 if ($this->entityId === null)
22 {
23 return true;
24 }
25
26 if (!Loader::includeModule('im'))
27 {
28 return false;
29 }
30
31 $message = new Message($this->entityId);
32
33 return $message
34 ->getChat()
35 ->checkAccess($userId)
36 ->isSuccess()
37 ;
38 }
39
40 public function canEdit($userId): bool
41 {
42 $userId = (int)$userId;
43 if ($userId <= 0)
44 {
45 return false;
46 }
47
48 if ($this->entityId === null)
49 {
50 return true;
51 }
52
53 if (!Loader::includeModule('im'))
54 {
55 return false;
56 }
57
58 $message = new Message($this->entityId);
59
60 return $message->getAuthorId() === $userId
61 && $message
62 ->getChat()
63 ->checkAccess($userId)
64 ->isSuccess()
65 ;
66 }
67
68 public function onVoteStop(Attach $attach): void
69 {
70 $handler = new ImVoteStopEventHandler((int)$attach->getVoteId(), (int)$attach->getEntityId());
71 $handler->handle();
72 }
73}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static includeModule($moduleName)
Определения loader.php:67
getEntityId()
Определения attach.php:587
getVoteId()
Определения attach.php:563
Определения Uuid.php:3
$message
Определения payment.php:8