27 const AUDIO_DIR =
'https://dl.bitrix24.com/sender/audiocall/';
28 const RU_AUDIO_DIR =
'https://repos.1c-bitrix.ru/sender/audiocall/';
29 const METADATA_FILE =
'https://dl.bitrix24.com/sender/audiocall/metadata.json';
36 return self::RU_AUDIO_DIR;
39 return static::AUDIO_DIR;
46 return self::RU_METADATA_FILE;
49 return static::METADATA_FILE;
57 $data = self::getMetadata();
71 if ($templateType && $templateType !==
'BASE')
75 if ($messageCode && $messageCode !==
Message\iBase::CODE_AUDIO_CALL)
90 if (!self::presetExists(
$code))
94 $filePath = static::getAudioDir() . static::getCodeWithLang(
$code) .
'.mp3';
116 $data = self::getMetadata();
129 $code = mb_strtolower($item[
'CODE']);
130 if (self::presetExists(
$code))
143 private static function getCodeWithLang(
$code)
145 $lang = self::getLang();
153 private static function getLang()
155 $lang = mb_strtolower(LANGUAGE_ID);
156 $supportedLangs = static::getSupportedLangs();
157 $lang = in_array(
$lang, $supportedLangs) ?
$lang : array_shift($supportedLangs);
166 private static function getTemplates(
$templateId =
null)
173 $code = mb_strtolower($item[
'CODE']);
174 $presetCode = mb_strtolower($messageCode.
"_".
$code);
175 if (!self::presetExists(
$code))
187 'MESSAGE_CODE' =>
array($messageCode),
189 'HOT' => $item[
'HOT'],
190 'ICON' => $item[
'ICON'],
192 'NAME' => $item[
'NAME'],
193 'DESC' => $item[
'DESC'],
196 'CODE' =>
'AUDIO_FILE',
197 'VALUE' => static::getAudioFileUrlByCode(
$code),
211 private static function getMetadata()
213 static $failed =
false;
220 $cacheId =
'sender_audiocall_metadata';
221 $cachePath =
'/sender/audiocall_metadata/';
222 $cache = \Bitrix\Main\Application::getInstance()->getCache();
223 if($cache->initCache($cacheTtl, $cacheId, $cachePath))
225 return $cache->getVars();
231 $cache->startDataCache();
234 "socketTimeout" => 5,
235 "streamTimeout" => 5,
237 $request->get(static::getMetadataFile());
244 catch (ArgumentException $e)
255 $cache->abortDataCache();
static getListByType($type)
if(!defined('SITE_ID')) $lang