1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
PushService.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Im\V2\Message\Send;
4
5
use Bitrix\Im\V2\Message\PushFormat;
6
use Bitrix\Im\V2\Message;
7
use Bitrix\Im\V2\Common\ContextCustomer;
8
9
abstract
class
PushService
10
{
11
use ContextCustomer;
12
13
protected
SendingConfig
$sendingConfig
;
14
protected
PushFormat
$pushFormatter
;
15
protected
Message\Send\Push\MobilePush
$mobilePush
;
16
protected
Message
$message
;
17
21
public
function
__construct
(
Message
$message
, ?
SendingConfig
$sendingConfig
=
null
)
22
{
23
if
(
$sendingConfig
===
null
)
24
{
25
$sendingConfig
=
new
SendingConfig
();
26
}
27
$this->sendingConfig =
$sendingConfig
;
28
$this->message =
$message
;
29
$this->pushFormatter =
new
PushFormat
(
$message
);
30
$this->mobilePush =
new
Message\Send\Push\MobilePush
(
$message
,
$sendingConfig
);
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
60
public
static
function
getEventGroupsByCounters
(
array
$event
,
array
$counters
):
array
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
94
\Bitrix\Main\Type\Collection::sortByColumn
(
$groups
, [
'count'
=> \SORT_DESC]);
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
$count
Определения
admin_tab.php:4
$userId
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения
check_mail.php:18
Bitrix\Im\V2\Message\Param\PushService
Определения
PushService.php:11
Bitrix\Im\V2\Message\PushFormat
Определения
PushFormat.php:19
Bitrix\Im\V2\Message\Send\Push\MobilePush
Определения
MobilePush.php:14
Bitrix\Im\V2\Message\Send\PushService\isPullEnable
isPullEnable()
Определения
PushService.php:33
Bitrix\Im\V2\Message\Send\PushService\getEventGroupsByCounters
static getEventGroupsByCounters(array $event, array $counters)
Определения
PushService.php:60
Bitrix\Im\V2\Message\Send\PushService\$sendingConfig
SendingConfig $sendingConfig
Определения
PushService.php:13
Bitrix\Im\V2\Message\Send\PushService\getEventByCounterGroup
static getEventByCounterGroup(array $events, int $maxUserInGroup=100)
Определения
PushService.php:80
Bitrix\Im\V2\Message\Send\PushService\$pushFormatter
PushFormat $pushFormatter
Определения
PushService.php:14
Bitrix\Im\V2\Message\Send\PushService\$mobilePush
Message Send Push MobilePush $mobilePush
Определения
PushService.php:15
Bitrix\Im\V2\Message\Send\PushService\__construct
__construct(Message $message, ?SendingConfig $sendingConfig=null)
Определения
PushService.php:21
Bitrix\Im\V2\Message\Send\PushService\$message
Message $message
Определения
PushService.php:16
Bitrix\Im\V2\Message\Send\PushService\getEventGroups
static getEventGroups(array $event, array $userIds, int $chatId)
Определения
PushService.php:53
Bitrix\Im\V2\Message\Send\PushService\sendPush
sendPush(array $counters=[])
Bitrix\Im\V2\Message\Send\SendingConfig
Определения
SendingConfig.php:68
Bitrix\Main\Loader\includeModule
static includeModule($moduleName)
Определения
loader.php:67
Bitrix\Main\Type\Collection\sortByColumn
static sortByColumn(array &$array, $columns, $callbacks='', $defaultValueIfNotSetValue=null, $preserveKeys=false)
Определения
collection.php:24
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$groups
$groups
Определения
options.php:30
Bitrix\Im\Message
Определения
Uuid.php:3
Bitrix\Im\V2\Message\CounterService
Определения
CounterServiceAgent.php:5
$counter
$counter
Определения
options.php:5
$event
$event
Определения
prolog_after.php:141
count
</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
$counters
Определения
options.php:100
bitrix
modules
im
lib
V2
Message
Send
PushService.php
Создано системой
1.14.0