40 $channelResult = $this->gelAllChannelList();
41 if (!$channelResult->isSuccess())
43 return (
new Result())->addError(
new Error(
'Edna service error'));
47 foreach ($channelResult->getData() as $channel)
49 if (is_array($channel) && isset($channel[
'type']) && $channel[
'type'] === $imType)
51 $channelList[] = $channel;
54 if (empty($channelList))
56 return (
new Result())->addError(
new Error(
"There are no $imType channels in your profile"));
60 $result->setData($channelList);
86 public function setCallback(
string $callbackUrl, array $callbackTypes, ?
int $subjectId =
null):
Result
88 $typeList = Constants\CallbackType::getAllTypeList();
91 foreach ($callbackTypes as $callbackType)
93 if (in_array($callbackType, $typeList,
true))
95 $requestParams[$callbackType] = $callbackUrl;
98 if (empty($requestParams))
100 return (
new Result())->addError(
new Error(
'Invalid callback types passed'));
105 $requestParams[
'subjectId'] = $subjectId;
107 $this->externalSender->setApiKey($this->optionManager->getOption(InternalOption::API_KEY));
109 return $this->externalSender->callExternalMethod(
'callback/set', $requestParams);
115 if (!$channelListResult->isSuccess())
117 return $channelListResult;
120 $activeChannelList = [];
121 foreach ($channelListResult->getData() as $channel)
123 if (isset($channel[
'active'], $channel[
'subjectId']) && $channel[
'active'] ===
true)
125 $activeChannelList[] = $channel;
129 if (empty($activeChannelList))
131 return (
new Result())->addError(
new Error(
'There are no active channels'));
134 return (
new Result())->setData($activeChannelList);
217 if ($activeChannelListResult->isSuccess())
219 $registeredSubjectIdList = $this->optionManager->getOption(Providers\Constants\InternalOption::SENDER_ID, []);
221 foreach ($activeChannelListResult->getData() as $channel)
223 if (in_array((
int)$channel[
'subjectId'], $registeredSubjectIdList,
true))
226 'id' => $channel[
'subjectId'],
227 'name' => $channel[
'name'],
228 'channelPhone' => $channel[
'channelAttribute'] ??
'',
232 'EXTERNAL_ID' => $channel[
'subjectId'],
233 'TYPE' => $channelType,
234 'NAME' => $channel[
'name'],
235 'ADDITIONAL_PARAMS' => [
236 'channelAttribute' => $channel[
'channelAttribute'] ??
''
242 if (count($channels) > 0)
244 ChannelTable::reloadChannels($this->providerId, $channelType, $channels);
248 ChannelTable::deleteByFilter([
249 '=SENDER_ID' => $this->providerId,
250 '=TYPE' => $channelType,