| 
									
										
										
										
											2015-01-14 01:16:28 +01:00
										 |  |  | <?php | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2017-05-01 11:04:27 +02:00
										 |  |  |  * GNU social feed polling plugin, to avoid using external WebSub hubs | 
					
						
							| 
									
										
										
										
											2015-01-14 01:16:28 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @category  Feed | 
					
						
							|  |  |  |  * @package   GNUsocial | 
					
						
							|  |  |  |  * @author    Mikael Nordfeldth <mmn@hethane.se> | 
					
						
							|  |  |  |  * @copyright 2013 Free Software Foundation, Inc. | 
					
						
							|  |  |  |  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 | 
					
						
							|  |  |  |  * @link      http://www.gnu.org/software/social/ | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if (!defined('GNUSOCIAL')) { exit(1); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class FeedPollerPlugin extends Plugin { | 
					
						
							| 
									
										
										
										
											2019-06-03 01:56:52 +01:00
										 |  |  |     const PLUGIN_VERSION = '2.0.0'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-14 01:16:28 +01:00
										 |  |  |     public $interval = 5;   // interval in minutes for feed checks
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function onEndInitializeQueueManager(QueueManager $qm) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $qm->connect(FeedPoll::QUEUE_CHECK, 'FeedPollQueueHandler'); | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function onCronMinutely() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $args = array('interval'=>$this->interval); | 
					
						
							|  |  |  |         FeedPoll::enqueueNewFeeds($args); | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function onFeedSubscribe(FeedSub $feedsub) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-05-01 11:04:27 +02:00
										 |  |  |         if (!$feedsub->isWebSub()) { | 
					
						
							| 
									
										
										
										
											2015-01-14 01:16:28 +01:00
										 |  |  |             FeedPoll::setupFeedSub($feedsub, $this->interval*60); | 
					
						
							|  |  |  |             return false;   // We're polling this feed, so stop processing FeedSubscribe
 | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function onFeedUnsubscribe(FeedSub $feedsub) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-05-01 11:04:27 +02:00
										 |  |  |         if (!$feedsub->isWebSub()) { | 
					
						
							| 
									
										
										
										
											2015-01-14 01:16:28 +01:00
										 |  |  |             // removes sub_state setting and such
 | 
					
						
							|  |  |  |             $feedsub->confirmUnsubscribe(); | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-12 15:03:30 +01:00
										 |  |  |     public function onPluginVersion(array &$versions): bool | 
					
						
							| 
									
										
										
										
											2015-01-14 01:16:28 +01:00
										 |  |  |     { | 
					
						
							|  |  |  |         $versions[] = array('name' => 'FeedPoller', | 
					
						
							| 
									
										
										
										
											2019-06-03 01:56:52 +01:00
										 |  |  |                             'version' => self::PLUGIN_VERSION, | 
					
						
							| 
									
										
										
										
											2015-01-14 01:16:28 +01:00
										 |  |  |                             'author' => 'Mikael Nordfeldth', | 
					
						
							|  |  |  |                             'homepage' => 'http://www.gnu.org/software/social/', | 
					
						
							|  |  |  |                             'description' => | 
					
						
							|  |  |  |                             // TRANS: Plugin description.
 | 
					
						
							|  |  |  |                             _m('Feed polling plugin to avoid using external push hubs.')); | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |