]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/OStatus/lib/pushrenewqueuehandler.php
Don't accept non-objects before testing with "instanceof".
[quix0rs-gnu-social.git] / plugins / OStatus / lib / pushrenewqueuehandler.php
1 <?php
2 /*
3  * This program is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU Affero General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU Affero General Public License for more details.
12  *
13  * You should have received a copy of the GNU Affero General Public License
14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15  */
16
17 if (!defined('STATUSNET')) {
18     exit(1);
19 }
20
21 /**
22  * Renew an expiring feedsub
23  * @package FeedSub
24  * @author Stephen Paul Weber <singpolyma@singpolyma.net>
25  */
26 class PushRenewQueueHandler extends QueueHandler
27 {
28     function transport()
29     {
30         return 'pushrenew';
31     }
32
33     function handle($data)
34     {
35         $feedsub_id = $data['feedsub_id'];
36         $feedsub = FeedSub::getKV('id', $feedsub_id);
37         if ($feedsub instanceof FeedSub) {
38             try {
39                 common_log(LOG_INFO, "Renewing feed subscription\n\tExp.: {$feedsub->sub_end}\n\tFeed: {$feedsub->uri}\n\tHub:  {$feedsub->huburi}");
40                 $feedsub->renew();
41             } catch(Exception $e) {
42                 common_log(LOG_ERR, "Exception during PuSH renew processing for $feedsub->uri: " . $e->getMessage());
43             }
44         } else {
45             common_log(LOG_ERR, "Discarding renew for unknown feed subscription id $feedsub_id");
46         }
47         return true;
48     }
49 }