]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/FeedPoller/FeedPollerPlugin.php
Maximum character limit with utf8mb4 is 191 in varchar
[quix0rs-gnu-social.git] / plugins / FeedPoller / FeedPollerPlugin.php
1 <?php
2 /**
3  * GNU social feed polling plugin, to avoid using external PuSH hubs
4  *
5  * @category  Feed
6  * @package   GNUsocial
7  * @author    Mikael Nordfeldth <mmn@hethane.se>
8  * @copyright 2013 Free Software Foundation, Inc.
9  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
10  * @link      http://www.gnu.org/software/social/
11  */
12
13 if (!defined('GNUSOCIAL')) { exit(1); }
14
15 class FeedPollerPlugin extends Plugin {
16     public $interval = 5;   // interval in minutes for feed checks
17
18     public function onEndInitializeQueueManager(QueueManager $qm)
19     {
20         $qm->connect(FeedPoll::QUEUE_CHECK, 'FeedPollQueueHandler');
21         return true;
22     }
23
24     public function onCronMinutely()
25     {
26         $args = array('interval'=>$this->interval);
27         FeedPoll::enqueueNewFeeds($args);
28         return true;
29     }
30
31     public function onFeedSubscribe(FeedSub $feedsub)
32     {
33         if (!$feedsub->isPuSH()) {
34             FeedPoll::setupFeedSub($feedsub, $this->interval*60);
35             return false;   // We're polling this feed, so stop processing FeedSubscribe
36         }
37         return true;
38     }
39
40     public function onFeedUnsubscribe(FeedSub $feedsub)
41     {
42         if (!$feedsub->isPuSH()) {
43             // removes sub_state setting and such
44             $feedsub->confirmUnsubscribe();
45             return false;
46         }
47         return true;
48     }
49
50     public function onPluginVersion(array &$versions)
51     {
52         $versions[] = array('name' => 'FeedPoller',
53                             'version' => GNUSOCIAL_VERSION,
54                             'author' => 'Mikael Nordfeldth',
55                             'homepage' => 'http://www.gnu.org/software/social/',
56                             'description' =>
57                             // TRANS: Plugin description.
58                             _m('Feed polling plugin to avoid using external push hubs.'));
59         return true;
60     }
61 }