-
- $feeds = $this->getFeeds();
-
- if (empty($feeds)) {
- $this->showResult(false,
- 'You must provide at least one feed url (url1, url2, url3 ... urlN).');
- }
-
- $endpoint = $ip . ':' . $port . $path;
-
- foreach ($feeds as $feed) {
-
- }
-
-
+
+ // We have to validate everything before saving anything.
+ // We only return one success or failure no matter how
+ // many feeds the subscriber is trying to subscribe to
+ foreach ($this->feeds as $feed) {
+
+ if (!$this->validateFeed($feed)) {
+
+ $nh = $this->getNotifyUrl();
+ common_log(LOG_WARNING,
+ "RSSCloud plugin - $nh tried to subscribe to invalid feed: $feed");
+
+ $msg = _m('Feed subscription failed: Not a valid feed.');
+ $this->showResult(false, $msg);
+ return;
+ }
+
+ if (!$this->testNotificationHandler($feed)) {
+ $msg = _m('Feed subscription failed - ' .
+ 'notification handler doesn\'t respond correctly.');
+ $this->showResult(false, $msg);
+ return;
+ }
+ }
+
+ foreach ($this->feeds as $feed) {
+ $this->saveSubscription($feed);
+ }
+
+ // XXX: What to do about deleting stale subscriptions?
+ // 25 hours seems harsh. WordPress doesn't ever remove
+ // subscriptions.
+ $msg = _m('Thanks for the subscription. ' .
+ 'When the feed(s) update(s), you will be notified.');
+
+ $this->showResult(true, $msg);