Skip to content

Commit 474f8ee

Browse files
committed
Make REST file caption skip extensions configurable
1 parent 62a3f46 commit 474f8ee

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

lhc_web/design/defaulttheme/tpl/lhgenericbot/form_rest_api.tpl.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@
336336
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('genericbot/restapi','Convert to multipart/form-data if one of those API is used. Post the file using multipart/form-data in the usual way that files are uploaded via the browser.');?> E.g mp3_m4a,tgs,file_api,image_api,video_api</label>
337337
<input type="text" class="form-control form-control-sm" ng-model="param.suburl_file_convert" placeholder="mp3_m4a,tgs,file_api,image_api,video_api" value="" />
338338
</div>
339+
<div class="form-group">
340+
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('genericbot/restapi','Do not use file API with message text for these file extensions');?> E.g tgs,webp</label>
341+
<input type="text" class="form-control form-control-sm" ng-model="param.suburl_file_skip_ext" placeholder="tgs,webp" value="" />
342+
</div>
339343

340344
</div>
341345

lhc_web/lib/core/lhgenericbot/actionTypes/lhgenericbotactionrestapi.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,11 @@ public static function makeRequest($host, $methodSettings, $paramsCustomer)
607607

608608
$canSendSingleFileWithText = false;
609609
if (isset($methodSettings['body_raw_file']) && $methodSettings['body_raw_file'] != '' && count($files) == 1 && trim($msg_text_cleaned) != '' && strpos($methodSettings['body_raw_file'], '{{msg_clean}}') !== false) {
610-
$captionUnsupportedExtensions = array('tgs');
611-
$canSendSingleFileWithText = !in_array($files[0]->extension, $captionUnsupportedExtensions);
610+
$captionUnsupportedExtensions = array();
611+
if (isset($methodSettings['suburl_file_skip_ext']) && $methodSettings['suburl_file_skip_ext'] != '') {
612+
$captionUnsupportedExtensions = explode(',',str_replace(' ','',strtolower($methodSettings['suburl_file_skip_ext'])));
613+
}
614+
$canSendSingleFileWithText = !in_array(strtolower($files[0]->extension), $captionUnsupportedExtensions);
612615
}
613616

614617
// Switch to file API if it's only one file send

0 commit comments

Comments
 (0)