add log
This commit is contained in:
parent
da8f36730c
commit
b25c6f6402
|
|
@ -23,47 +23,35 @@ class TelegramLinkFixerExtension extends Minz_Extension
|
||||||
*/
|
*/
|
||||||
public static function fixLink($entry)
|
public static function fixLink($entry)
|
||||||
{
|
{
|
||||||
// Check if it's a telegram link
|
|
||||||
$link = $entry->link();
|
|
||||||
error_log('TelegramLinkFixer: Processing entry with link: ' . $link);
|
|
||||||
|
|
||||||
if (strpos($link, 't.me') === false) {
|
|
||||||
error_log('TelegramLinkFixer: Skipping - not a telegram link');
|
|
||||||
return; // skip if not a telegram link
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// output the $entry
|
// Check if it's a telegram link
|
||||||
error_log('TelegramLinkFixer: Entry: ' . json_encode($entry));
|
$link = $entry->link();
|
||||||
$description = $entry->description();
|
error_logg('TelegramLinkFixer: Processing entry with link: ' . $link);
|
||||||
|
|
||||||
|
if (strpos($link, 't.me') === false) {
|
||||||
|
error_logg('TelegramLinkFixer: Skipping - not a telegram link');
|
||||||
|
return; // skip if not a telegram link
|
||||||
|
}
|
||||||
|
|
||||||
|
// The correct method is content() not description()
|
||||||
|
$description = $entry->content();
|
||||||
if (empty($description)) {
|
if (empty($description)) {
|
||||||
error_log('TelegramLinkFixer: Skipping - empty description');
|
error_logg('TelegramLinkFixer: Skipping - empty content');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
|
||||||
error_log('TelegramLinkFixer: Error processing entry: ' . $e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Look specifically for Telegraph links
|
|
||||||
error_log('TelegramLinkFixer: Looking for Telegraph link in description: ' . $description);
|
|
||||||
try {
|
|
||||||
if (preg_match('/<a[^>]*?href="(https:\/\/telegra\.ph\/[^"]+)"[^>]*>Telegraph<\/a>/i', $description, $matches)) {
|
if (preg_match('/<a[^>]*?href="(https:\/\/telegra\.ph\/[^"]+)"[^>]*>Telegraph<\/a>/i', $description, $matches)) {
|
||||||
$telegraphLink = $matches[1];
|
$telegraphLink = $matches[1];
|
||||||
if (!empty($telegraphLink)) {
|
if (!empty($telegraphLink)) {
|
||||||
Minz_Log::debug('TelegramLinkFixer: Found Telegraph link: ' . $telegraphLink);
|
error_logg('TelegramLinkFixer: Found Telegraph link: ' . $telegraphLink);
|
||||||
try {
|
$entry->setLink($telegraphLink);
|
||||||
$entry->setLink($telegraphLink);
|
error_logg('TelegramLinkFixer: Successfully updated link');
|
||||||
error_log('TelegramLinkFixer: Successfully updated link');
|
|
||||||
} catch (Exception $e) {
|
|
||||||
error_log('TelegramLinkFixer: Failed to set link: ' . $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
error_log('TelegramLinkFixer: No Telegraph link found in description');
|
error_logg('TelegramLinkFixer: No Telegraph link found in content');
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
error_log('TelegramLinkFixer: Error processing entry: ' . $e->getMessage());
|
Minz_Log::error('TelegramLinkFixer: Error processing entry: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue