mirror of
https://git.tt-rss.org/fox/tt-rss.git
synced 2025-08-05 13:47:25 +02:00
Clean up displaying subscription error info, log more detailed info to the event log.
This commit is contained in:
parent
692c7a8949
commit
09c11df764
@ -1013,7 +1013,10 @@ class Feeds extends Handler_Protected {
|
||||
|
||||
$url = UrlHelper::validate($url);
|
||||
|
||||
if (!$url) return ["code" => 2];
|
||||
if (!$url) {
|
||||
Logger::log(E_USER_NOTICE, "An attempt to subscribe to '{$url}' failed due to URL validation (User: '{$user->login}'; ID: {$user->id}).");
|
||||
return ["code" => 2];
|
||||
}
|
||||
|
||||
PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_PRE_SUBSCRIBE,
|
||||
/** @phpstan-ignore closure.unusedUse, closure.unusedUse, closure.unusedUse */
|
||||
@ -1035,14 +1038,20 @@ class Feeds extends Handler_Protected {
|
||||
UrlHelper::$fetch_last_error .= " (feed behind Cloudflare)";
|
||||
}
|
||||
|
||||
return array("code" => 5, "message" => truncate_string(UrlHelper::$fetch_last_error, 1000, '…'));
|
||||
Logger::log(E_USER_NOTICE, "An attempt to subscribe to '{$url}' failed (User: '{$user->login}'; ID: {$user->id}).",
|
||||
truncate_string(UrlHelper::$fetch_last_error, 500, '…'));
|
||||
|
||||
return array("code" => 5, "message" => truncate_string(clean(UrlHelper::$fetch_last_error), 250, '…'));
|
||||
}
|
||||
|
||||
if (str_contains(UrlHelper::$fetch_last_content_type, "html") && self::_is_html($contents)) {
|
||||
$feedUrls = self::_get_feeds_from_html($url, $contents);
|
||||
|
||||
if (count($feedUrls) == 0) {
|
||||
return array("code" => 3, "message" => truncate_string($contents, 1000, '…'));
|
||||
Logger::log(E_USER_NOTICE, "An attempt to subscribe to '{$url}' failed due to content being HTML without detected feed URLs (User: '{$user->login}'; ID: {$user->id}).",
|
||||
truncate_string($contents, 500, '…'));
|
||||
|
||||
return array("code" => 3, "message" => truncate_string(clean($contents), 250, '…'));
|
||||
} else if (count($feedUrls) > 1) {
|
||||
return array("code" => 4, "feeds" => $feedUrls);
|
||||
}
|
||||
|
@ -118,10 +118,10 @@ const CommonDialogs = {
|
||||
</footer>
|
||||
</form>
|
||||
`,
|
||||
show_error: function (msg) {
|
||||
show_error: function (msg, additional_info) {
|
||||
const elem = App.byId("fadd_error_message");
|
||||
|
||||
elem.innerHTML = msg;
|
||||
elem.innerHTML = `${msg}${additional_info ? `<br><br><h4>${__('Additional information')}</h4>${additional_info}` : ''}`;
|
||||
|
||||
Element.show(elem);
|
||||
},
|
||||
@ -168,9 +168,7 @@ const CommonDialogs = {
|
||||
dialog.show_error(__("Specified URL seems to be invalid."));
|
||||
break;
|
||||
case 3:
|
||||
dialog.show_error(`<span title="${App.escapeHtml(rc['message'])}" style="text-decoration: underline dotted">
|
||||
${__("Specified URL doesn't seem to contain any feeds.")}
|
||||
</span>`);
|
||||
dialog.show_error(__("Specified URL doesn't seem to contain any feeds."), App.escapeHtml(rc['message']));
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
@ -195,7 +193,7 @@ const CommonDialogs = {
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
dialog.show_error(__("Couldn't download the specified URL: %s").replace("%s", App.escapeHtml(rc['message'])));
|
||||
dialog.show_error(__("Couldn't download the specified URL."), App.escapeHtml(rc['message']));
|
||||
break;
|
||||
case 7:
|
||||
dialog.show_error(__("Error while creating feed database entry."));
|
||||
|
Loading…
Reference in New Issue
Block a user