1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
PushService.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Message\Send;
4
5use Bitrix\Im\V2\Message\PushFormat;
6use Bitrix\Im\V2\Message;
7use Bitrix\Im\V2\Common\ContextCustomer;
8
9abstract class PushService
10{
11 use ContextCustomer;
12
16 protected Message $message;
17
22 {
23 if ($sendingConfig === null)
24 {
26 }
27 $this->sendingConfig = $sendingConfig;
28 $this->message = $message;
29 $this->pushFormatter = new PushFormat($message);
31 }
32
33 public function isPullEnable(): bool
34 {
35 static $enable;
36 if ($enable === null)
37 {
38 $enable = \Bitrix\Main\Loader::includeModule('pull');
39 }
40 return $enable;
41 }
42
43
44 //region Push Private chat
45
46 abstract public function sendPush(array $counters = []): void;
47
48 //endregion
49
50
51 //region Push in Group Chat
52
53 public static function getEventGroups(array $event, array $userIds, int $chatId): array
54 {
55 $counters = (new Message\CounterService())->getByChatForEachUsers($chatId, $userIds, 100);
56
57 return self::getEventGroupsByCounters($event, $counters);
58 }
59
61 {
62 $events = [];
63
64 foreach ($counters as $userId => $counter)
65 {
66 $eventForUser = $event;
67 $eventForUser['groupId'] = 'im_chat_' . $event['params']['chatId'] . $event['params']['message']['id'] . $counter;
68 $eventForUser['params']['counter'] = $counter;
69 $events[$userId] = $eventForUser;
70 }
71
72 return self::getEventByCounterGroup($events, 100);
73 }
74
80 public static function getEventByCounterGroup(array $events, int $maxUserInGroup = 100): array
81 {
82 $groups = [];
83 foreach ($events as $userId => $event)
84 {
85 $eventCode = $event['groupId'];
86 if (!isset($groups[$eventCode]))
87 {
88 $groups[$eventCode]['event'] = $event;
89 }
90 $groups[$eventCode]['users'][] = $userId;
91 $groups[$eventCode]['count'] = count($groups[$eventCode]['users']);
92 }
93
95
96 $count = 0;
97 $finalGroup = [];
98 foreach ($groups as $eventCode => $event)
99 {
100 if ($count >= $maxUserInGroup)
101 {
102 if (isset($finalGroup['other']))
103 {
104 $finalGroup['other']['users'] = array_unique(array_merge($finalGroup['other']['users'], $event['users']));
105 }
106 else
107 {
108 $finalGroup['other'] = $event;
109 $finalGroup['other']['event']['params']['counter'] = 100;
110 }
111 }
112 else
113 {
114 $finalGroup[$eventCode] = $event;
115 }
116 $count++;
117 }
118
119 \Bitrix\Main\Type\Collection::sortByColumn($finalGroup, ['count' => \SORT_ASC]);
120
121 return $finalGroup;
122 }
123
124
125 //endregion
126
127
128 //region Notification Push
129
130
131 //endregion
132}
$count
Определения admin_tab.php:4
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getEventGroupsByCounters(array $event, array $counters)
Определения PushService.php:60
SendingConfig $sendingConfig
Определения PushService.php:13
static getEventByCounterGroup(array $events, int $maxUserInGroup=100)
Определения PushService.php:80
PushFormat $pushFormatter
Определения PushService.php:14
Message Send Push MobilePush $mobilePush
Определения PushService.php:15
__construct(Message $message, ?SendingConfig $sendingConfig=null)
Определения PushService.php:21
static getEventGroups(array $event, array $userIds, int $chatId)
Определения PushService.php:53
static includeModule($moduleName)
Определения loader.php:67
static sortByColumn(array &$array, $columns, $callbacks='', $defaultValueIfNotSetValue=null, $preserveKeys=false)
Определения collection.php:24
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$groups
Определения options.php:30
Определения Uuid.php:3
$counter
Определения options.php:5
$event
Определения prolog_after.php:141
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$counters
Определения options.php:100