static function preparePushData(int $taskId, int $userId, array $taskData): array
{
$counter = (new TaskCounter($userId))->getMobileRowCounter($taskId);
unset($counter['counters']);
$pushData = [
'id' => (string)$taskId,
'counter' => (new TaskCounter($userId))->getMobileRowCounter($taskId),
];
$data = self::getTaskData($taskId);
if (array_key_exists('ACTIVITY_DATE', $data))
{
$pushData['activityDate'] = self::prepareDate($userId, $data['ACTIVITY_DATE']);
}
if (array_key_exists('TITLE', $taskData))
{
$pushData['title'] = $taskData['TITLE'];
}
if (array_key_exists('DEADLINE', $taskData) && isset($taskData['DEADLINE']))
{
$pushData['deadline'] = self::prepareDate($userId, $taskData['DEADLINE']);
}
if (
array_key_exists('REAL_STATUS', $taskData)
|| array_key_exists('STATUS', $taskData)
)
{
$pushData['status'] = ($taskData['REAL_STATUS'] ?? $taskData['STATUS']);
}
if (array_key_exists('GROUP_ID', $taskData))
{
$groupId = $taskData['GROUP_ID'];
$pushData['groupId'] = $groupId;
$pushData['group'] = [];
if ($groupId > 0)
{
$groupData = self::getGroupData($groupId);
$pushData['group'] = [
'id' => $groupId,
'name' => $groupData['NAME'],
'image' => $groupData['IMAGE'],
];
}
}
if (array_key_exists('CREATED_BY', $taskData))
{
$pushData['creator'] = [
'id' => $taskData['CREATED_BY'],
'icon' => self::getUserAvatar($taskData['CREATED_BY']),
];
}
if (array_key_exists('RESPONSIBLE_ID', $taskData))
{
$pushData['responsible'] = [
'id' => $taskData['RESPONSIBLE_ID'],
'icon' => self::getUserAvatar($taskData['RESPONSIBLE_ID']),
];
}
if (array_key_exists('ACCOMPLICES', $taskData))
{
$pushData['accomplices'] = $taskData['ACCOMPLICES'];
}
if (array_key_exists('AUDITORS', $taskData))
{
$pushData['auditors'] = $taskData['AUDITORS'];
}
$map = [
'id' => 1,
'title' => 2,
'deadline' => 3,
'activityDate' => 4,
'status' => 5,
'groupId' => 20,
'group' => 21,
'image' => 22,
'name' => 23,
'creator' => 30,
'responsible' => 31,
'icon' => 32,
'accomplices' => 41,
'auditors' => 42,
'counter' => 50,
'counters' => 51,
'color' => 52,
'value' => 53,
'expired' => 54,
'new_comments' => 55,
'project_expired' => 56,
'project_new_comments' => 57,
];
$pushData = self::convertFields($pushData, $map);
return $pushData;
}