1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
CollabOnboardingPromotionService.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
6
20
22{
23 use SingletonTrait;
24
25 private ?QueueProviderInterface $queueProvider = null;
26 private ?AbstractQueueService $queueService = null;
27
28 private function __construct()
29 {
31 {
32 return;
33 }
34
35 $this->queueProvider = ServiceLocator::getInstance()->get('socialnetwork.onboarding.queue.provider');
36 $this->queueService = ServiceLocator::getInstance()->get('socialnetwork.onboarding.queue.service');
37 }
38
39 public function getActive(DeviceType $type = DeviceType::ALL): PromotionList
40 {
41 $promotions = new PromotionList();
42
43 if ($type === DeviceType::MOBILE)
44 {
45 return $promotions;
46 }
47
48 $userId = (int)User::getCurrent()->getId();
49 if ($userId <= 0)
50 {
51 return $promotions;
52 }
53
54 if (!$this->queueProvider)
55 {
56 return $promotions;
57 }
58
59 $jobCollection = $this->queueProvider->getNotImmediatedByUserId($userId);
60
61 return $jobCollection->toPromotions() ?? $promotions;
62 }
63
65 {
66 return PromotionType::COLLAB;
67 }
68
69 public function isCurrentTypePromotion(string $promotionId): bool
70 {
71 return (bool)preg_match('/^socialnetwork:\w+-collab$/', $promotionId);
72 }
73
74 public function markAsViewed(Promotion $promotion): Result
75 {
76 $result = new Result();
77
78 if (!$this->queueService || !OnboardingFeature::isAvailable())
79 {
80 return $result;
81 }
82
83 $chat = Chat::getInstance((int)$promotion->getChatId());
84
85 $isCollabChat = $chat->getType() === Chat::IM_TYPE_COLLAB;
86 $collabId = (int)$chat->getEntityId();
87
88 $jobType = Type::createFromPromotionId($promotion->getId());
89
90 if (!$isCollabChat || $collabId <= 0 || !$jobType)
91 {
92 return $result;
93 }
94
95 $filter = [
96 'USER_IDS' => [(int)User::getCurrent()->getId()],
97 'COLLAB_IDS' => [$collabId],
98 'JOB_TYPES' => [$jobType->value],
99 ];
100
101 return $this->queueService->deleteByFilter($filter);
102 }
103}
$type
Определения options.php:106
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getInstance()
Определения application.php:98
Определения result.php:20
$result
Определения get_property_values.php:14
$filter
Определения iblock_catalog_list.php:54
trait SingletonTrait
Определения SingletonTrait.php:10