[TelegramBridge] Fix entries for "media too big" (#1184)

When a large video is posted, "Media is too big" appears in web preview. This adds code to detect this and offer a link.
This commit is contained in:
triatic 2019-06-23 07:54:52 +01:00 committed by LogMANOriginal
parent 89e3da0b6f
commit 3769850ba3

View file

@ -108,6 +108,10 @@ class TelegramBridge extends BridgeAbstract {
$message .= $this->processPhoto($messageDiv); $message .= $this->processPhoto($messageDiv);
} }
if ($messageDiv->find('a.not_supported', 0)) {
$message .= $this->processNotSupported($messageDiv);
}
if ($messageDiv->find('div.tgme_widget_message_text.js-message_text', 0)) { if ($messageDiv->find('div.tgme_widget_message_text.js-message_text', 0)) {
$message .= $messageDiv->find('div.tgme_widget_message_text.js-message_text', 0); $message .= $messageDiv->find('div.tgme_widget_message_text.js-message_text', 0);
@ -250,6 +254,24 @@ EOD;
return $photos; return $photos;
} }
private function processNotSupported($messageDiv) {
if (empty($this->itemTitle)) {
$this->itemTitle = '@' . $this->processUsername() . ' posted a video';
}
preg_match($this->backgroundImageRegex, $messageDiv->find('i.tgme_widget_message_video_thumb', 0)->style, $photo);
$this->enclosures[] = $photo[1];
return <<<EOD
<a href="{$messageDiv->find('a.not_supported', 0)->href}">
{$messageDiv->find('div.message_media_not_supported_label', 0)->innertext}<br><br>
{$messageDiv->find('span.message_media_view_in_telegram', 0)->innertext}<br><br>
<img src="{$photo[1]}"/></a>
EOD;
}
private function processDate($messageDiv) { private function processDate($messageDiv) {
$messageMeta = $messageDiv->find('span.tgme_widget_message_meta', 0); $messageMeta = $messageDiv->find('span.tgme_widget_message_meta', 0);