]> git.wh0rd.org Git - tt-rss.git/commitdiff
subscribe_to_feed: do not subscribe to feeds which can't be downloaded
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 10 Nov 2010 10:27:44 +0000 (13:27 +0300)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 10 Nov 2010 10:27:44 +0000 (13:27 +0300)
functions.js
functions.php

index 926fda2bbec9ba81ca1be832c5ac5ebca3e0da61..a0092f932fbd5e5befa818d9753172910d9ff6b7 100644 (file)
@@ -1304,6 +1304,9 @@ function subscribeToFeed() {
 
                        try {
 
+                               if (!transport.responseXML)
+                                       console.log(transport.responseText);
+
                                var result = transport.responseXML.getElementsByTagName('result')[0];
                                var rc = parseInt(result.getAttribute('code'));
        
@@ -1323,8 +1326,10 @@ function subscribeToFeed() {
                                        }
                                        break;
                                case 2:
+                                       alert(__("Specified URL seems to be invalid."));
+                                       break;
                                case 3:
-                                       alert(__("Can't subscribe to the specified URL."));
+                                       alert(__("Specified URL doesn't seem to contain any feeds."));
                                        break;
                                case 4:
                                        new Ajax.Request("backend.php", {
@@ -1349,6 +1354,9 @@ function subscribeToFeed() {
                                                }
                                        });
                                        break;
+                               case 5:
+                                       alert(__("Couldn't download the specified URL."));
+                                       break;
                                case 0:
                                        alert(__("You are already subscribed to this feed."));
                                        break;
index 73fd93682dafefd7632227aee85d32cd12245bcc..835398cd6f8fb037cd1072b6bcac2796dbd865d7 100644 (file)
                }
        }
 
-       function fetch_file_contents($url, $type) {
+       function fetch_file_contents($url, $type = false) {
                if (USE_CURL_FOR_ICONS) {
                        $ch = curl_init($url);
 
         *                 4 - URL content is HTML which contains multiple feeds.
         *                     Here you should call extractfeedurls in rpc-backend
         *                     to get all possible feeds.
+        *                 5 - Couldn't download the URL content.
         */
        function subscribe_to_feed($link, $url, $cat_id = 0, 
                        $auth_login = '', $auth_pass = '') {
 
                $url = fix_url($url);
                if (!validate_feed_url($url)) return 2;
+               if (!fetch_file_contents($url)) return 5;
 
                if (url_is_html($url)) {
                        $feedUrls = get_feeds_from_html($url);