]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/FeedPoller/lib/feedpollqueuehandler.php
c80253dcbadd3480917a0d7f1b529c621f3f4004
[quix0rs-gnu-social.git] / plugins / FeedPoller / lib / feedpollqueuehandler.php
1 <?php
2
3 if (!defined('GNUSOCIAL')) { exit(1); }
4
5 /**
6  * Poll a feed based on its urlhash, the full url is in the feedsub table
7  *
8  * @author Mikael Nordfeldth <mmn@hethane.se>
9  */
10 class FeedPollQueueHandler extends QueueHandler
11 {
12     public function transport()
13     {
14         return FeedPoll::QUEUE_CHECK;
15     }
16
17     public function handle($item)
18     {
19         common_debug('Enqueueing FeedPoll feeds but actually running the queue handler!');
20         $feedsub = FeedSub::getKV('id', $item['id']);
21         if (!$feedsub instanceof FeedSub) {
22             // Removed from the feedsub table I guess
23             return true;
24         }
25         if (!$feedsub->sub_state == 'nohub') {
26             // We're not supposed to poll this (either it's PuSH or it's unsubscribed)
27             return true;
28         }
29
30         common_debug('Enqueueing FeedPoll feeds but actually checking updates');
31         try {
32             FeedPoll::checkUpdates($feedsub);
33         } catch (Exception $e) {
34             common_log(LOG_ERR, "Failed to check feedsub id= ".$feedsub->id.' ("'.$e->getMessage().'")');
35         }
36
37         common_debug('Enqueueing FeedPoll feeds but actually done with '.$feedsub->id);
38
39         return true;
40     }
41 }