pushrenewqueuehandler.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. if (!defined('STATUSNET')) {
  17. exit(1);
  18. }
  19. /**
  20. * Renew an expiring feedsub
  21. * @package FeedSub
  22. * @author Stephen Paul Weber <singpolyma@singpolyma.net>
  23. */
  24. class PushRenewQueueHandler extends QueueHandler
  25. {
  26. function transport()
  27. {
  28. return 'pushrenew';
  29. }
  30. function handle($data)
  31. {
  32. $feedsub_id = $data['feedsub_id'];
  33. $feedsub = FeedSub::getKV('id', $feedsub_id);
  34. if ($feedsub instanceof FeedSub) {
  35. try {
  36. common_log(LOG_INFO, "Renewing feed subscription\n\tExp.: {$feedsub->sub_end}\n\tFeed: {$feedsub->uri}\n\tHub: {$feedsub->huburi}");
  37. $feedsub->renew();
  38. } catch(Exception $e) {
  39. common_log(LOG_ERR, "Exception during WebSub renew processing for $feedsub->uri: " . $e->getMessage());
  40. }
  41. } else {
  42. common_log(LOG_ERR, "Discarding renew for unknown feed subscription id $feedsub_id");
  43. }
  44. return true;
  45. }
  46. }